| Line | |
|---|
| 1 | #version 150 |
|---|
| 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 | in vec3 noiseCoord; |
|---|
| 13 | in vec4 projectionCoord; |
|---|
| 14 | in vec3 eyeDir; |
|---|
| 15 | in vec3 oNormal; |
|---|
| 16 | |
|---|
| 17 | out vec4 fragColour; |
|---|
| 18 | |
|---|
| 19 | // Fragment program for distorting a texture using a 3D noise texture |
|---|
| 20 | void 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.