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 | |
---|
3 | uniform vec4 tintColour; |
---|
4 | uniform float noiseScale; |
---|
5 | uniform float fresnelBias; |
---|
6 | uniform float fresnelScale; |
---|
7 | uniform float fresnelPower; |
---|
8 | uniform sampler2D noiseMap; |
---|
9 | uniform sampler2D reflectMap; |
---|
10 | uniform sampler2D refractMap; |
---|
11 | |
---|
12 | varying vec3 noiseCoord; |
---|
13 | varying vec4 projectionCoord; |
---|
14 | varying vec3 eyeDir; |
---|
15 | varying vec3 oNormal; |
---|
16 | |
---|
17 | // Fragment program for distorting a texture using a 3D noise texture |
---|
18 | void 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.