turning reflection into sun or light direction
|
@ -1,10 +1,8 @@
|
|||
|
||||
uniform sampler2D water_normalmap;
|
||||
uniform sampler2D water_reflection;
|
||||
uniform sampler2D water_refraction;
|
||||
uniform sampler2D water_dudvmap;
|
||||
uniform sampler2D water_depthmap;
|
||||
//uniform vec4 waterColor, waterDepth;
|
||||
|
||||
vec4 waterColor = vec4(0.0,0.2,1.0,1.0);
|
||||
vec4 waterDepth = vec4(0.0,0.2,1.0,1.0);
|
||||
|
@ -14,6 +12,7 @@ varying vec4 waterTex1; //moving texcoords
|
|||
varying vec4 waterTex2; //moving texcoords
|
||||
varying vec4 waterTex3; //for projection
|
||||
varying vec4 waterTex4; //viewts
|
||||
varying float fogCoord;
|
||||
|
||||
//unit 0 = water_reflection
|
||||
//unit 1 = water_refraction
|
||||
|
@ -33,6 +32,8 @@ const vec4 ofive = vec4(0.5,0.5,0.5,1.0);
|
|||
|
||||
const float exponent = 64.0;
|
||||
|
||||
float fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
|
||||
|
||||
vec4 lightTS = normalize(waterTex0);
|
||||
vec4 viewt = normalize(waterTex4);
|
||||
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale));
|
||||
|
@ -68,7 +69,7 @@ wdepth = vec4(pow(wdepth.x, 4.0));
|
|||
vec4 invdepth = 1.0 - wdepth;
|
||||
|
||||
//calculate specular highlight
|
||||
vec4 vRef = normalize(reflect(-lightTS, vNorm));
|
||||
vec4 vRef = normalize(reflect(lightTS, vNorm));
|
||||
float stemp =max(0.0, dot(viewt, vRef) );
|
||||
stemp = pow(stemp, exponent);
|
||||
vec4 specular = vec4(stemp);
|
||||
|
@ -87,5 +88,10 @@ refl *= fres;
|
|||
//add reflection and refraction
|
||||
tmp = refr + refl;
|
||||
|
||||
gl_FragColor = tmp + specular;
|
||||
if(gl_Fog.density == 1.0)
|
||||
fogFactor=1.0;
|
||||
|
||||
vec4 finalColor = tmp + specular;
|
||||
|
||||
gl_FragColor = mix(gl_Fog.color,finalColor, fogFactor);
|
||||
}
|
||||
|
|
|
@ -1,48 +1,47 @@
|
|||
|
||||
varying vec4 waterTex0;
|
||||
varying vec4 waterTex1;
|
||||
varying vec4 waterTex2;
|
||||
varying vec4 waterTex3;
|
||||
varying vec4 waterTex4;
|
||||
uniform vec4 viewpos, lightpos;
|
||||
uniform float time, time2;
|
||||
//unit 0 = water_reflection
|
||||
//unit 1 = water_refraction
|
||||
//unit 2 = water_normalmap
|
||||
//unit 3 = water_dudvmap
|
||||
//unit 4 = water_depthmap
|
||||
uniform float osg_SimulationTime;
|
||||
varying vec3 lightVec;
|
||||
varying float fogCoord;
|
||||
varying vec4 ecPosition;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 mpos, temp;
|
||||
|
||||
lightVec = normalize(gl_LightSource[0].position.xyz);
|
||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
vec4 lightpos = vec4(lightVec, 1.0);
|
||||
|
||||
vec4 temp;
|
||||
vec4 tangent = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
vec4 norm = vec4(0.0, 1.0, 0.0, 0.0);
|
||||
vec4 binormal = vec4(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
mat4 mvp = gl_ModelViewProjectionMatrix;
|
||||
mat4 mtx = gl_TextureMatrix[0];
|
||||
|
||||
temp = viewpos - gl_Vertex;
|
||||
temp = gl_ModelViewMatrix * gl_Vertex;
|
||||
waterTex4.x = dot(temp, tangent);
|
||||
waterTex4.y = dot(temp, binormal);
|
||||
waterTex4.z = dot(temp, norm);
|
||||
waterTex4.w = 0.0;
|
||||
|
||||
temp = lightpos - gl_Vertex;
|
||||
temp = lightpos;
|
||||
waterTex0.x = dot(temp, tangent);
|
||||
waterTex0.y = dot(temp, binormal);
|
||||
waterTex0.z = dot(temp, norm);
|
||||
waterTex0.w = 0.0;
|
||||
|
||||
mpos = mvp * gl_Vertex;
|
||||
|
||||
vec4 t1 = vec4(0.0, -time, 0.0,0.0);
|
||||
vec4 t2 = vec4(0.0, -time2, 0.0,0.0);
|
||||
vec4 t1 = vec4(0.0, osg_SimulationTime*0.035217, 0.0,0.0);
|
||||
vec4 t2 = vec4(0.0, osg_SimulationTime*-0.0212, 0.0,0.0);
|
||||
|
||||
waterTex1 = gl_MultiTexCoord0 + t1;
|
||||
waterTex2 = gl_MultiTexCoord0 + t2;
|
||||
|
||||
waterTex3 = mpos;
|
||||
waterTex3 = gl_MultiTexCoord0;
|
||||
|
||||
fogCoord = abs(ecPosition.z / ecPosition.w);
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 430 KiB After Width: | Height: | Size: 502 KiB |
Before Width: | Height: | Size: 618 KiB After Width: | Height: | Size: 745 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 1.8 KiB |