refraction shading
This commit is contained in:
parent
6667d75455
commit
94428d43c9
23
shader.fs
23
shader.fs
@ -10,10 +10,31 @@ uniform samplerCube skybox;
|
|||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
uniform sampler2D texture_diffuse1;
|
uniform sampler2D texture_diffuse1;
|
||||||
|
|
||||||
|
const float air_ri = 1.00;
|
||||||
|
const float water_ri = 1.33;
|
||||||
|
const float Ice_ri = 1.309;
|
||||||
|
const float glass_ri = 1.52;
|
||||||
|
const float diamond_ri = 2.42;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// Regular shading
|
||||||
|
// texture( texture_diffuse1, TexCoords) ;
|
||||||
|
|
||||||
|
|
||||||
|
// Reflective shading
|
||||||
|
/*
|
||||||
vec3 I = normalize(Position - cameraPos);
|
vec3 I = normalize(Position - cameraPos);
|
||||||
vec3 R = reflect(I, normalize(Normal));
|
vec3 R = reflect(I, normalize(Normal));
|
||||||
|
|
||||||
FragColor = vec4(texture(skybox,R).rgb, 1.0); // texture( texture_diffuse1, TexCoords) ;
|
FragColor = vec4(texture(skybox,R).rgb, 1.0);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// Refractive shading
|
||||||
|
float ratio = air_ri/water_ri;
|
||||||
|
vec3 I = normalize(Position-cameraPos);
|
||||||
|
vec3 R = refract(I, normalize(Normal), ratio);
|
||||||
|
FragColor = vec4(texture(skybox, R).rgb, 1.0);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user