From f0d21c1f6088a34ae31bcc2689bd8a0e5f2dd737 Mon Sep 17 00:00:00 2001 From: Vivian Meazza Date: Mon, 7 May 2012 19:11:34 +0100 Subject: [PATCH] Optimisation and tidying Signed-off-by: Vivian Meazza --- Shaders/bowwave.frag | 20 ++++---------------- Shaders/wake.vert | 13 +------------ Shaders/water.vert | 5 ----- Shaders/water_sine.frag | 4 ++-- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/Shaders/bowwave.frag b/Shaders/bowwave.frag index ae667f56c..f25e0b082 100644 --- a/Shaders/bowwave.frag +++ b/Shaders/bowwave.frag @@ -24,8 +24,6 @@ uniform int Status; varying vec4 waterTex1; //moving texcoords varying vec4 waterTex2; //moving texcoords -//varying vec4 waterTex4; //viewts -//varying vec4 ecPosition; varying vec3 viewerdir; varying vec3 lightdir; varying vec3 normal; @@ -147,10 +145,10 @@ void main(void) vNorm = -vNorm; //load reflection - vec4 tmp = vec4(lightdir, 0.0); - vec4 refTex = texture2D(water_reflection, vec2(tmp)) ; - vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp)) ; - vec4 refl ; + vec4 tmp = vec4(lightdir, 0.0); + vec4 refTex = texture2D(water_reflection, vec2(tmp + waterTex1) * 32.0) ; + vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp + waterTex1) * 32.0) ; + vec4 refl ; // cover = 0; if(cover >= 1.5){ @@ -185,16 +183,6 @@ void main(void) refl *= fres; vec4 alpha0 = texture2D(alpha_tex, gl_TexCoord[0].st); - //refl.a *= alpha0.a; - - ////calculate the fog factor - //float fogFactor; - //float fogCoord = ecPosition.z; - //const float LOG2 = 1.442695; - //fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - - //if(gl_Fog.density == 1.0) - // fogFactor=1.0; //calculate final colour vec4 ambient_light = gl_LightSource[0].diffuse; diff --git a/Shaders/wake.vert b/Shaders/wake.vert index 810ab2c44..d95ba57ec 100644 --- a/Shaders/wake.vert +++ b/Shaders/wake.vert @@ -12,8 +12,6 @@ varying vec4 waterTex1; varying vec4 waterTex2; -//varying vec4 waterTex4; -//varying vec4 ecPosition; varying vec3 viewerdir; varying vec3 lightdir; varying vec3 normal; @@ -21,10 +19,6 @@ varying vec3 normal; uniform float osg_SimulationTime; uniform float WindE, WindN, spd, hdg; -////fog "include"//////// -// uniform int fogType; -// -// void fog_Func(int type); ///////////////////////// @@ -58,13 +52,9 @@ void main(void) vec3 N = normalize(gl_Normal); normal = N; -// ecPosition = gl_ModelViewMatrix * gl_Vertex; - viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex); lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position)); -// waterTex4 = vec4( ecPosition.xzy, 0.0 ); - vec4 t1 = vec4(osg_SimulationTime*0.005217, 0.0, 0.0, 0.0); vec4 t2 = vec4(osg_SimulationTime*-0.0012, 0.0, 0.0, 0.0); @@ -77,5 +67,4 @@ void main(void) gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; gl_Position = ftransform(); -// fog_Func(fogType); -} \ No newline at end of file +} diff --git a/Shaders/water.vert b/Shaders/water.vert index 614f84f0e..39cd6b352 100644 --- a/Shaders/water.vert +++ b/Shaders/water.vert @@ -9,7 +9,6 @@ varying vec4 waterTex1; varying vec4 waterTex2; -//varying vec4 waterTex4; varying vec3 viewerdir; varying vec3 lightdir; @@ -34,13 +33,9 @@ void main(void) vec3 N = normalize(gl_Normal); normal = N; - vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; - viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex); lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position)); - //waterTex4 = vec4(ecPosition.xzy, 0.0 ); - vec4 t1 = vec4(0.0, osg_SimulationTime * 0.005217, 0.0, 0.0); vec4 t2 = vec4(0.0, osg_SimulationTime * -0.0012, 0.0, 0.0); diff --git a/Shaders/water_sine.frag b/Shaders/water_sine.frag index 506782391..abd1302b7 100644 --- a/Shaders/water_sine.frag +++ b/Shaders/water_sine.frag @@ -283,8 +283,8 @@ void main(void) //load reflection vec4 tmp = vec4(lightdir, 0.0); - vec4 refTex = texture2D(water_reflection, vec2(tmp + waterTex1) * 32.0) ; - vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp * waterTex1)) ; + vec4 refTex = texture2D(water_reflection, vec2(tmp + waterTex1) * 32.0) ; + vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp + waterTex1) * 32.0) ; vec4 refl ; // Test data