]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - shader_glsl.h
we need one more glsl 130 compat ifdef...
[xonotic/darkplaces.git] / shader_glsl.h
index 0801e6d711a749c0420e31c42baa732c8c9bb75f..673c6a99de86383f0e0ea06e5d9be690a6cbca31 100644 (file)
@@ -9,7 +9,7 @@
 "#define highp\n"
 "#endif\n"
 "\n"
-"#if __VERSION__ >= 130\n"
+"#ifdef GLSL130\n"
 "# ifdef VERTEX_SHADER\n"
 "#  define dp_varying out\n"
 "#  define dp_attribute in\n"
 "# define dp_texture2D texture\n"
 "# define dp_texture3D texture\n"
 "# define dp_textureCube texture\n"
+"# define dp_shadow2D texture\n"
 "#else\n"
 "# ifdef FRAGMENT_SHADER\n"
 "#  define dp_FragColor gl_FragColor\n"
 "# endif\n"
 "# define dp_varying varying\n"
 "# define dp_attribute attribute\n"
-"# define dp_offsetmapping_dFdx(a) 0\n"
-"# define dp_offsetmapping_dFdy(a) 0\n"
+"# define dp_offsetmapping_dFdx(a) vec2(0.0, 0.0)\n"
+"# define dp_offsetmapping_dFdy(a) vec2(0.0, 0.0)\n"
 "# define dp_textureGrad(a,b,c,d) texture2D(a,b)\n"
 "# define dp_texture2D texture2D\n"
 "# define dp_texture3D texture3D\n"
 "# define dp_textureCube textureCube\n"
+"# define dp_shadow2D shadow2D\n"
 "#endif\n"
 "\n"
 "#ifdef VERTEX_SHADER\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"
+"#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"
-"      vec2 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(vec3(dp_texture2D(Texture_Normal, TexCoord)) - vec3(0.5))).xy * DistortScaleRefractReflect.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"
 "      // 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"
 "\n"
 "#  ifdef USESHADOWSAMPLER\n"
 "#    ifdef USESHADOWMAPPCF\n"
-"#      define texval(x, y) shadow2D(Texture_ShadowMap2D, vec3(center + vec2(x, y)*ShadowMap_TextureScale, shadowmaptc.z)).r  \n"
+"#      define texval(x, y) dp_shadow2D(Texture_ShadowMap2D, vec3(center + vec2(x, y)*ShadowMap_TextureScale, shadowmaptc.z)).r  \n"
 "      vec2 center = shadowmaptc.xy*ShadowMap_TextureScale;\n"
 "      f = dot(vec4(0.25), vec4(texval(-0.4, 1.0), texval(-1.0, -0.4), texval(0.4, -1.0), texval(1.0, 0.4)));\n"
 "#    else\n"
-"      f = shadow2D(Texture_ShadowMap2D, vec3(shadowmaptc.xy*ShadowMap_TextureScale, shadowmaptc.z)).r;\n"
+"      f = dp_shadow2D(Texture_ShadowMap2D, vec3(shadowmaptc.xy*ShadowMap_TextureScale, shadowmaptc.z)).r;\n"
 "#    endif\n"
 "#  else\n"
 "#    ifdef USESHADOWMAPPCF\n"
 "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"
 "      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"
 "      color.rgb += myhalf3(offsetMappedTexture2D(Texture_Pants)) * Color_Pants + myhalf3(offsetMappedTexture2D(Texture_Shirt)) * Color_Shirt;\n"
 "#endif\n"
 "#ifdef USEVERTEXTEXTUREBLEND\n"
+"#ifdef USEBOTHALPHAS\n"
+"      myhalf4 color2 = myhalf4(dp_texture2D(Texture_SecondaryColor, TexCoord2));\n"
+"      myhalf terrainblend = clamp(myhalf(VertexColor.a) * color.a, myhalf(1.0 - color2.a), myhalf(1.0));\n"
+"      color.rgb = mix(color2.rgb, color.rgb, terrainblend);\n"
+"#else\n"
 "      myhalf terrainblend = clamp(myhalf(VertexColor.a) * color.a * 2.0 - 0.5, myhalf(0.0), myhalf(1.0));\n"
 "      //myhalf terrainblend = min(myhalf(VertexColor.a) * color.a * 2.0, myhalf(1.0));\n"
 "      //myhalf terrainblend = myhalf(VertexColor.a) * color.a > 0.5;\n"
 "      color.rgb = mix(myhalf3(dp_texture2D(Texture_SecondaryColor, TexCoord2)), color.rgb, terrainblend);\n"
+"#endif\n"
 "      color.a = 1.0;\n"
 "      //color = mix(myhalf4(1, 0, 0, 1), color, terrainblend);\n"
 "#endif\n"
 "      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"
-"      vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(offsetMappedTexture2D(Texture_Normal)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.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"
 "      // 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"