From da84f5552731e1ece3a463c4c385bb327f1048a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2011 12:40:53 -0500 Subject: SH-2243 work in progress -- don't use deprecated shader state --- indra/newview/app_settings/shaders/class1/environment/waterF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/environment/waterF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 4d555b566a..1bb04ceb34 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -50,9 +50,9 @@ uniform float blurMultiplier; uniform vec4 fogCol; //bigWave is (refCoord.w, view.w); -varying vec4 refCoord; -varying vec4 littleWave; -varying vec4 view; +VARYING vec4 refCoord; +VARYING vec4 littleWave; +VARYING vec4 view; void main() { -- cgit v1.2.3 From 8a1baaea6c0462b645499e8e7b88345e46b92621 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2011 17:08:39 -0500 Subject: SH-2243 work in progress -- don't use gl_FragColor or gl_FragData for outputs -- no more deprecation warnings on nvidia --- indra/newview/app_settings/shaders/class1/environment/waterF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/environment/waterF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 1bb04ceb34..8aa4cb5434 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -23,7 +23,9 @@ * $/LicenseInfo$ */ - +#ifndef gl_FragColor +out vec4 gl_FragColor; +#endif vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); -- cgit v1.2.3 From 183fe0d14c48ebeb174567304cea197e7ea443fa Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 24 Sep 2011 03:09:32 -0500 Subject: SH-2244 Fix for shaders not compiling on pre-GL-3.0 ATI drivers --- indra/newview/app_settings/shaders/class1/environment/waterF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/environment/waterF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 8aa4cb5434..1512074dda 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -23,7 +23,7 @@ * $/LicenseInfo$ */ -#ifndef gl_FragColor +#ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; #endif -- cgit v1.2.3 From 7238714634e72dacc4b09c1c4ee98b16fb0c91fe Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 29 Sep 2011 19:32:56 -0500 Subject: SH-2507 Potential fix for basic shaders causing objects to disappear with some drivers (prune shader tree of unused shaders while we're at it) --- .../shaders/class1/environment/waterF.glsl | 80 ++++++++++++++-------- 1 file changed, 51 insertions(+), 29 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/environment/waterF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 1512074dda..444c896d38 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -29,16 +29,13 @@ out vec4 gl_FragColor; vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); -vec3 applyWaterFog(vec4 inColor); -uniform sampler2D diffuseMap; uniform sampler2D bumpMap; uniform sampler2D screenTex; uniform sampler2D refTex; uniform float sunAngle; uniform float sunAngle2; -uniform float scaledAngle; uniform vec3 lightDir; uniform vec3 specular; uniform float lightExp; @@ -49,7 +46,7 @@ uniform vec3 normScale; uniform float fresnelScale; uniform float fresnelOffset; uniform float blurMultiplier; -uniform vec4 fogCol; + //bigWave is (refCoord.w, view.w); VARYING vec4 refCoord; @@ -58,58 +55,83 @@ VARYING vec4 view; void main() { - vec3 viewVec = view.xyz; vec4 color; - float dist = length(viewVec.xy); + float dist = length(view.xy); //normalize view vector - viewVec = normalize(viewVec); + vec3 viewVec = normalize(view.xyz); //get wave normals - vec3 wavef = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0; - - //get detail normals - vec3 dcol = texture2D(bumpMap, littleWave.xy).rgb*0.75; - dcol += texture2D(bumpMap, littleWave.zw).rgb*1.25; - - //interpolate between big waves and little waves (big waves in deep water) - wavef = (wavef + dcol) * 0.5; - - //crunch normal to range [-1,1] - wavef -= vec3(1,1,1); - wavef = normalize(wavef); - + vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; //get base fresnel components - float df = dot(viewVec,wavef) * fresnelScale + fresnelOffset; + vec3 df = vec3( + dot(viewVec, wave1), + dot(viewVec, (wave2 + wave3) * 0.5), + dot(viewVec, wave3) + ) * fresnelScale + fresnelOffset; + df *= df; vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; float dist2 = dist; dist = max(dist, 5.0); + float dmod = sqrt(dist); + + vec2 dmod_scale = vec2(dmod*dmod, dmod); + //get reflected color - vec2 refdistort = wavef.xy*dot(normScale, vec3(0.333)); - vec2 refvec = distort+refdistort/dist; - vec4 refcol = texture2D(refTex, refvec); + vec2 refdistort1 = wave1.xy*normScale.x; + vec2 refvec1 = distort+refdistort1/dmod_scale; + vec4 refcol1 = texture2D(refTex, refvec1); + + vec2 refdistort2 = wave2.xy*normScale.y; + vec2 refvec2 = distort+refdistort2/dmod_scale; + vec4 refcol2 = texture2D(refTex, refvec2); + + vec2 refdistort3 = wave3.xy*normScale.z; + vec2 refvec3 = distort+refdistort3/dmod_scale; + vec4 refcol3 = texture2D(refTex, refvec3); + + vec4 refcol = refcol1 + refcol2 + refcol3; + float df1 = df.x + df.y + df.z; + refcol *= df1 * 0.333; + + vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; + + wavef.z *= max(-viewVec.z, 0.1); + wavef = normalize(wavef); + + float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; + + vec2 refdistort4 = wavef.xy*0.125; + refdistort4.y -= abs(refdistort4.y); + vec2 refvec4 = distort+refdistort4/dmod; + float dweight = min(dist2*blurMultiplier, 1.0); + vec4 baseCol = texture2D(refTex, refvec4); + refcol = mix(baseCol*df2, refcol, dweight); //get specular component float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); - + //harden specular - spec = pow(spec, lightExp); + spec = pow(spec, 128.0); //figure out distortion vector (ripply) - vec2 distort2 = distort+wavef.xy*refScale/max(dist*df, 1.0); + vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); vec4 fb = texture2D(screenTex, distort2); //mix with reflection - color.rgb = mix(mix(fogCol.rgb, fb.rgb, fogCol.a), refcol.rgb, df); + // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); color.rgb += spec * specular; - //color.rgb = applyWaterFog(color);//atmosTransport(color.rgb); + color.rgb = atmosTransport(color.rgb); color.rgb = scaleSoftClip(color.rgb); color.a = spec * sunAngle2; -- cgit v1.2.3