]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - shader_glsl.h
don't use GL_RGBA internalformat on opaque textures (thanks to Rock for
[xonotic/darkplaces.git] / shader_glsl.h
index 2883a4c1f58d04f50541772f63d08707b2527083..3e529d751786531dde7a32403a5da82a08e1ae4f 100644 (file)
 "#ifdef FRAGMENT_SHADER\n"
 "uniform sampler2D Texture_Normal;\n"
 "uniform sampler2D Texture_Refraction;\n"
-"uniform sampler2D Texture_Reflection;\n"
 "\n"
 "uniform mediump vec4 DistortScaleRefractReflect;\n"
 "uniform mediump vec4 ScreenScaleRefractReflect;\n"
 "uniform mediump vec4 ScreenCenterRefractReflect;\n"
 "uniform mediump vec4 RefractColor;\n"
 "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"
 "      #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"
+"              vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(normal))).xy * DistortScaleRefractReflect.xy;\n"
 "      #else\n"
-"              vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(dp_texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n"
+"              vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(dp_texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.xy;\n"
 "      #endif\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"
 "      fade *= ShadowMapCompare(CubeVector);\n"
 "#endif\n"
 "\n"
-"#ifdef USEDIFFUSE\n"
-"      gl_FragData[0] = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n"
-"#else\n"
-"      gl_FragData[0] = vec4(DeferredColor_Ambient * fade, 1.0);\n"
-"#endif\n"
 "#ifdef USESPECULAR\n"
+"      gl_FragData[0] = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n"
 "      gl_FragData[1] = vec4(DeferredColor_Specular * (specular * fade), 1.0);\n"
-"#else\n"
-"      gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);\n"
-"#endif\n"
-"\n"
 "# ifdef USECUBEFILTER\n"
 "      vec3 cubecolor = dp_textureCube(Texture_Cube, CubeVector).rgb;\n"
 "      gl_FragData[0].rgb *= cubecolor;\n"
 "      gl_FragData[1].rgb *= cubecolor;\n"
 "# endif\n"
+"#else\n"
+"# ifdef USEDIFFUSE\n"
+"      gl_FragColor = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n"
+"# else\n"
+"      gl_FragColor = vec4(DeferredColor_Ambient * fade, 1.0);\n"
+"# endif\n"
+"# ifdef USECUBEFILTER\n"
+"      vec3 cubecolor = dp_textureCube(Texture_Cube, CubeVector).rgb;\n"
+"      gl_FragColor.rgb *= cubecolor;\n"
+"# endif\n"
+"#endif\n"
+"      \n"
 "}\n"
 "#endif // FRAGMENT_SHADER\n"
 "#else // !MODE_DEFERREDLIGHTSOURCE\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"
+"# ifdef USEOFFSETMAPPING\n"
+"              vec3 normal = dp_textureGrad(Texture_Normal, (TexCoord + vec2(0.08, 0.08)*ClientTime*NormalmapScrollBlend.x*0.5)*NormalmapScrollBlend.y, dPdx*NormalmapScrollBlend.y, dPdy*NormalmapScrollBlend.y).rgb - vec3(1.0);\n"
+"# else\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"
+"# endif\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(dp_texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n"
+"              vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;\n"
 "      #endif\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"