Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/Example_FresnelFp.glsl @ 12091

Last change on this file since 12091 was 12083, checked in by wiesep, 6 years ago

Reorganised shader programs

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