|
Last change
on this file since 12091 was
12091,
checked in by wiesep, 7 years ago
|
|
Updated programs and adjusted Material to work with GLSL>150
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | #version 100 |
|---|
| 2 | |
|---|
| 3 | precision mediump int; |
|---|
| 4 | precision mediump float; |
|---|
| 5 | |
|---|
| 6 | uniform vec4 tintColour; |
|---|
| 7 | uniform float noiseScale; |
|---|
| 8 | uniform float fresnelBias; |
|---|
| 9 | uniform float fresnelScale; |
|---|
| 10 | uniform float fresnelPower; |
|---|
| 11 | uniform sampler2D noiseMap; |
|---|
| 12 | uniform sampler2D reflectMap; |
|---|
| 13 | uniform sampler2D refractMap; |
|---|
| 14 | |
|---|
| 15 | varying vec3 noiseCoord; |
|---|
| 16 | varying vec4 projectionCoord; |
|---|
| 17 | varying vec3 eyeDir; |
|---|
| 18 | varying vec3 oNormal; |
|---|
| 19 | |
|---|
| 20 | // Fragment program for distorting a texture using a 3D noise texture |
|---|
| 21 | void 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.