Added chromatic aberration
This commit is contained in:
parent
0ca64e14cc
commit
1978e466dd
@ -112,7 +112,7 @@ void MyGlWindow::shaderSetup()
|
||||
shaders["Skybox"] = new Shader("skybox.vert", "skybox.frag");
|
||||
shaders["Skybox"]->uniformFlags = MVP_FLAG | MODEL_MATRIX_FLAG | SKYBOX_TEX_FLAG;
|
||||
shaders["Skybox"]->addUniform("ReflectFactor", (float)0.1);
|
||||
shaders["Skybox"]->addUniform("RefractionIndex", (float)0.95);
|
||||
shaders["Skybox"]->addUniform("RefractionIndex", glm::vec3(0.65, 0.67, 0.69));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,10 @@
|
||||
out vec4 FragColors;
|
||||
|
||||
in vec3 reflectDir;
|
||||
in vec3 refractDir;
|
||||
|
||||
in vec3 refractDir_R;
|
||||
in vec3 refractDir_G;
|
||||
in vec3 refractDir_B;
|
||||
|
||||
uniform float ReflectFactor;
|
||||
uniform bool DrawSkyBox;
|
||||
@ -12,7 +15,10 @@ uniform samplerCube CubeMapTex;
|
||||
void main()
|
||||
{
|
||||
vec4 reflectColor = texture(CubeMapTex, reflectDir);
|
||||
vec4 refractColor = texture(CubeMapTex, refractDir);
|
||||
float refractColor_R = texture(CubeMapTex, refractDir_R).r;
|
||||
float refractColor_G = texture(CubeMapTex, refractDir_G).g;
|
||||
float refractColor_B = texture(CubeMapTex, refractDir_B).b;
|
||||
vec4 refractColor = vec4(refractColor_R, refractColor_G, refractColor_B, 1);
|
||||
if (DrawSkyBox == true)
|
||||
FragColors = reflectColor;
|
||||
else
|
||||
|
||||
@ -6,9 +6,11 @@ layout(location=2) in vec3 v_color;
|
||||
layout(location=3) in vec2 v_texmap;
|
||||
|
||||
out vec3 reflectDir;
|
||||
out vec3 refractDir;
|
||||
out vec3 refractDir_R;
|
||||
out vec3 refractDir_G;
|
||||
out vec3 refractDir_B;
|
||||
|
||||
uniform float RefractionIndex;
|
||||
uniform vec3 RefractionIndex;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 mvp;
|
||||
uniform bool DrawSkyBox;
|
||||
@ -27,7 +29,9 @@ void main(void)
|
||||
vec3 N = normalize(ModelMatrix * vec4(v_normal, 1)).xyz;
|
||||
vec3 V = normalize(WorldCamPos - coord3d);
|
||||
reflectDir = reflect(-V, N);
|
||||
refractDir = refract(-V, N, RefractionIndex);
|
||||
refractDir_R = refract(-V, N, RefractionIndex.r);
|
||||
refractDir_G = refract(-V, N, RefractionIndex.g);
|
||||
refractDir_B = refract(-V, N, RefractionIndex.b);
|
||||
}
|
||||
|
||||
gl_Position = mvp * vec4(coord3d, 1.0f);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user