Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL120/Example_FresnelFp.glsl @ 12412

Last change on this file since 12412 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.0 KB
Line 
1#version 120
2
3uniform vec4 tintColour;
4uniform float noiseScale;
5uniform float fresnelBias;
6uniform float fresnelScale;
7uniform float fresnelPower;
8uniform sampler2D noiseMap;
9uniform sampler2D reflectMap;
10uniform sampler2D refractMap;
11
12varying vec3 noiseCoord;
13varying vec4 projectionCoord;
14varying vec3 eyeDir;
15varying vec3 oNormal;
16
17// Fragment program for distorting a texture using a 3D noise texture
18void main()
19{
20        // Do the tex projection manually so we can distort _after_
21        vec2 final = projectionCoord.xy / projectionCoord.w;
22
23        // Noise
24        vec3 noiseNormal = (texture2D(noiseMap, (noiseCoord.xy / 5.0)).rgb - 0.5).rbg * noiseScale;
25        final += noiseNormal.xz;
26
27        // Fresnel
28        //normal = normalize(normal + noiseNormal.xz);
29        float fresnel = fresnelBias + fresnelScale * pow(1.0 + dot(eyeDir, oNormal), fresnelPower);
30
31        // Reflection / refraction
32        vec4 reflectionColour = texture2D(reflectMap, final);
33        vec4 refractionColour = texture2D(refractMap, final) + tintColour;
34
35        // Final colour
36        gl_FragColor = mix(refractionColour, reflectionColour, fresnel);
37}
Note: See TracBrowser for help on using the repository browser.