Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/Example_FresnelFp.glsles @ 12091

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

Updated programs and adjusted Material to work with GLSL>150

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