From: vortex vortex@d7cf8633-e32d-0410-b094-e92efae38249 <> Date: Tue, 22 Mar 2011 15:15:59 +0000 (+0000) Subject: UNMERGE X-Git-Tag: xonotic-v0.5.0~362 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1ce5b955cc1c29b384cc48834ae2b567bcc877fb;p=xonotic%2Fdarkplaces.git UNMERGE GLSL shader: make dp_waterscroll work with dp_reflect and dp_refract git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10958 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::unmerge=dbd8e60c7e473f960271f3f52d66382e205001db --- diff --git a/gl_rmain.c b/gl_rmain.c index 3cda3276..4077fc3e 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2072,14 +2072,14 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, r_waterstate_waterplane_t *waterplane = (r_waterstate_waterplane_t *)surfacewaterplane; if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) permutation |= SHADERPERMUTATION_ALPHAKILL; - if (rsurface.texture->r_water_waterscroll[0] && rsurface.texture->r_water_waterscroll[1]) - permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; // todo: make generic if (rsurfacepass == RSURFPASS_BACKGROUND) { // distorted background if (rsurface.texture->currentmaterialflags & MATERIALFLAG_WATERSHADER) { mode = SHADERMODE_WATER; + if (rsurface.texture->r_water_waterscroll[0] && rsurface.texture->r_water_waterscroll[1]) + permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; if((r_wateralpha.value < 1) && (rsurface.texture->currentmaterialflags & MATERIALFLAG_WATERALPHA)) { // this is the right thing to do for wateralpha diff --git a/shader_glsl.h b/shader_glsl.h index 673c6a99..3e46a8fb 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -357,23 +357,13 @@ "uniform mediump vec4 ReflectColor;\n" "uniform mediump float ReflectFactor;\n" "uniform mediump float ReflectOffset;\n" -"uniform highp float ClientTime;\n" -"#ifdef USENORMALMAPSCROLLBLEND\n" -"uniform highp vec2 NormalmapScrollBlend;\n" -"#endif\n" "\n" "void main(void)\n" "{\n" " vec2 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect.xy * (1.0 / ModelViewProjectionPosition.w);\n" " //vec2 ScreenTexCoord = (ModelViewProjectionPosition.xy + normalize(vec3(dp_texture2D(Texture_Normal, TexCoord)) - vec3(0.5)).xy * DistortScaleRefractReflect.xy * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;\n" " vec2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;\n" -" #ifdef USENORMALMAPSCROLLBLEND\n" -" vec3 normal = dp_texture2D(Texture_Normal, (TexCoord + vec2(0.08, 0.08)*ClientTime*NormalmapScrollBlend.x*0.5)*NormalmapScrollBlend.y).rgb - vec3(1.0);\n" -" normal += dp_texture2D(Texture_Normal, (TexCoord + vec2(-0.06, -0.09)*ClientTime*NormalmapScrollBlend.x)*NormalmapScrollBlend.y*0.75).rgb;\n" -" vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(normal))).xy * DistortScaleRefractReflect.zw;\n" -" #else\n" -" vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n" -" #endif\n" +" vec2 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(vec3(dp_texture2D(Texture_Normal, TexCoord)) - vec3(0.5))).xy * DistortScaleRefractReflect.xy;\n" " // FIXME temporary hack to detect the case that the reflection\n" " // gets blackened at edges due to leaving the area that contains actual\n" " // content.\n" @@ -1076,10 +1066,6 @@ "uniform sampler3D Texture_BounceGrid;\n" "uniform float BounceGridIntensity;\n" "#endif\n" -"uniform highp float ClientTime;\n" -"#ifdef USENORMALMAPSCROLLBLEND\n" -"uniform highp vec2 NormalmapScrollBlend;\n" -"#endif\n" "void main(void)\n" "{\n" "#ifdef USEOFFSETMAPPING\n" @@ -1088,10 +1074,8 @@ " vec2 dPdy = dp_offsetmapping_dFdy(TexCoordSurfaceLightmap.xy);\n" " vec2 TexCoordOffset = OffsetMapping(TexCoordSurfaceLightmap.xy, dPdx, dPdy);\n" "# define offsetMappedTexture2D(t) dp_textureGrad(t, TexCoordOffset, dPdx, dPdy)\n" -"# define TexCoord TexCoordOffset\n" "#else\n" "# define offsetMappedTexture2D(t) dp_texture2D(t, TexCoordSurfaceLightmap.xy)\n" -"# define TexCoord TexCoordSurfaceLightmap.xy\n" "#endif\n" "\n" " // combine the diffuse textures (base, pants, shirt)\n" @@ -1299,13 +1283,7 @@ " vec4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);\n" " //vec4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n" " vec2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW.zw + ScreenCenterRefractReflect.zw;\n" -" #ifdef USENORMALMAPSCROLLBLEND\n" -" vec3 normal = dp_texture2D(Texture_Normal, (TexCoord + vec2(0.08, 0.08)*ClientTime*NormalmapScrollBlend.x*0.5)*NormalmapScrollBlend.y).rgb - vec3(1.0);\n" -" normal += dp_texture2D(Texture_Normal, (TexCoord + vec2(-0.06, -0.09)*ClientTime*NormalmapScrollBlend.x)*NormalmapScrollBlend.y*0.75).rgb;\n" -" vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(normal))).xy * DistortScaleRefractReflect.zw;\n" -" #else\n" -" vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n" -" #endif\n" +" vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n" " // FIXME temporary hack to detect the case that the reflection\n" " // gets blackened at edges due to leaving the area that contains actual\n" " // content.\n"