]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - shader_hlsl.h
Fix compile of vid_glx.c after the update on hwgamma.
[xonotic/darkplaces.git] / shader_hlsl.h
index e81e603990d4912e3bb1d7545f4c875eb5fcce64..9b3f04c3faa71d9e5e0a4a3192c7d5e04904144c 100644 (file)
 "#ifdef USEPOSTPROCESSING\n",
 "// do r_glsl_dumpshader, edit glsl/default.glsl, and replace this by your own postprocessing if you want\n",
 "// this code does a blur with the radius specified in the first component of r_glsl_postprocess_uservec1 and blends it using the second component\n",
+"#if defined(USERVEC1) || defined(USERVEC2)\n",
 "      float sobel = 1.0;\n",
 "      // float2 ts = textureSize(Texture_First, 0);\n",
 "      // float2 px = float2(1/ts.x, 1/ts.y);\n",
 "      dp_FragColor /= (1.0 + 5.0 * UserVec1.y);\n",
 "      dp_FragColor.rgb = dp_FragColor.rgb * (1.0 + UserVec2.x) + float3(1,1,1)*max(0.0, sobel - UserVec2.z)*UserVec2.y;\n",
 "#endif\n",
+"#endif\n",
 "\n",
 "#ifdef USEBLOOM\n",
 "      dp_FragColor += max(float4(0,0,0,0), tex2D(Texture_Second, TexCoord2) - BloomColorSubtract);\n",
 "#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USESHADOWMAPORTHO)\n",
 "#if defined(USESHADOWMAP2D)\n",
 "# ifdef USESHADOWMAPORTHO\n",
-"#  define GetShadowMapTC2D(dir, ShadowMap_Parameters) (min(dir, ShadowMap_Parameters.xyz))\n",
+"#  define GetShadowMapTC2D(dir, ShadowMap_Parameters) (max(float3(0.0, 0.0, 0.0), min(dir, ShadowMap_Parameters.xyz)))\n",
 "# else\n",
 "#  ifdef USESHADOWMAPVSDCT\n",
 "float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters, samplerCUBE Texture_CubeProjection)\n",
 "\n",
 "# ifdef USESHADOWMAP2D\n",
 "#ifdef USESHADOWMAPVSDCT\n",
-"float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float2 ShadowMap_TextureScale, samplerCUBE Texture_CubeProjection)\n",
+"float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float4 ShadowMap_TextureScale, samplerCUBE Texture_CubeProjection)\n",
 "#else\n",
-"float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float2 ShadowMap_TextureScale)\n",
+"float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float4 ShadowMap_TextureScale)\n",
 "#endif\n",
 "{\n",
 "#ifdef USESHADOWMAPVSDCT\n",
-"      float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters, Texture_CubeProjection);\n",
+"      float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters, Texture_CubeProjection) + float3(ShadowMap_TextureScale.zw, 0.0f);\n",
 "#else\n",
-"      float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters);\n",
+"      float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters) + float3(ShadowMap_TextureScale.zw, 0.0f);\n",
 "#endif\n",
 "      float f;\n",
 "\n",
 "#  ifdef USESHADOWSAMPLER\n",
 "#    ifdef USESHADOWMAPPCF\n",
-"#      define texval(x, y) tex2Dproj(Texture_ShadowMap2D, float4(center + float2(x, y)*ShadowMap_TextureScale, shadowmaptc.z, 1.0)).r  \n",
-"      float2 center = shadowmaptc.xy*ShadowMap_TextureScale;\n",
+"#      define texval(x, y) tex2Dproj(Texture_ShadowMap2D, float4(center + float2(x, y)*ShadowMap_TextureScale.xy, shadowmaptc.z, 1.0)).r  \n",
+"      float2 center = shadowmaptc.xy*ShadowMap_TextureScale.xy;\n",
 "      f = dot(float4(0.25,0.25,0.25,0.25), float4(texval(-0.4, 1.0), texval(-1.0, -0.4), texval(0.4, -1.0), texval(1.0, 0.4)));\n",
 "#    else\n",
-"      f = tex2Dproj(Texture_ShadowMap2D, float4(shadowmaptc.xy*ShadowMap_TextureScale, shadowmaptc.z, 1.0)).r;\n",
+"      f = tex2Dproj(Texture_ShadowMap2D, float4(shadowmaptc.xy*ShadowMap_TextureScale.xy, shadowmaptc.z, 1.0)).r;\n",
 "#    endif\n",
 "#  else\n",
 "#    ifdef USESHADOWMAPPCF\n",
 "#      ifdef GL_ARB_texture_gather\n",
 "#        define texval(x, y) textureGatherOffset(Texture_ShadowMap2D, center, int2(x, y))\n",
 "#      else\n",
-"#        define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale)\n",
+"#        define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale.xy)\n",
 "#      endif\n",
-"      float2 offset = frac(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale;\n",
+"      float2 offset = frac(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale.xy;\n",
 "#      if USESHADOWMAPPCF > 1\n",
 "      float4 group1 = step(shadowmaptc.z, texval(-2.0, -2.0));\n",
 "      float4 group2 = step(shadowmaptc.z, texval( 0.0, -2.0));\n",
 "#      ifdef GL_EXT_gpu_shader4\n",
 "#        define texval(x, y) tex2DOffset(Texture_ShadowMap2D, center, int2(x, y)).r\n",
 "#      else\n",
-"#        define texval(x, y) texDepth2D(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale).r  \n",
+"#        define texval(x, y) texDepth2D(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale.xy).r  \n",
 "#      endif\n",
 "#      if USESHADOWMAPPCF > 1\n",
 "      float2 center = shadowmaptc.xy - 0.5, offset = frac(center);\n",
-"      center *= ShadowMap_TextureScale;\n",
+"      center *= ShadowMap_TextureScale.xy;\n",
 "      float4 row1 = step(shadowmaptc.z, float4(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0), texval( 2.0, -1.0)));\n",
 "      float4 row2 = step(shadowmaptc.z, float4(texval(-1.0,  0.0), texval( 0.0,  0.0), texval( 1.0,  0.0), texval( 2.0,  0.0)));\n",
 "      float4 row3 = step(shadowmaptc.z, float4(texval(-1.0,  1.0), texval( 0.0,  1.0), texval( 1.0,  1.0), texval( 2.0,  1.0)));\n",
 "      float4 cols = row2 + row3 + lerp(row1, row4, offset.y);\n",
 "      f = dot(lerp(cols.xyz, cols.yzw, offset.x), float3(1.0/9.0));\n",
 "#      else\n",
-"      float2 center = shadowmaptc.xy*ShadowMap_TextureScale, offset = frac(shadowmaptc.xy);\n",
+"      float2 center = shadowmaptc.xy*ShadowMap_TextureScale.xy, offset = frac(shadowmaptc.xy);\n",
 "      float3 row1 = step(shadowmaptc.z, float3(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0)));\n",
 "      float3 row2 = step(shadowmaptc.z, float3(texval(-1.0,  0.0), texval( 0.0,  0.0), texval( 1.0,  0.0)));\n",
 "      float3 row3 = step(shadowmaptc.z, float3(texval(-1.0,  1.0), texval( 0.0,  1.0), texval( 1.0,  1.0)));\n",
 "#      endif\n",
 "#     endif\n",
 "#    else\n",
-"      f = step(shadowmaptc.z, tex2D(Texture_ShadowMap2D, shadowmaptc.xy*ShadowMap_TextureScale).r);\n",
+"      f = step(shadowmaptc.z, tex2D(Texture_ShadowMap2D, shadowmaptc.xy*ShadowMap_TextureScale.xy).r);\n",
 "#    endif\n",
 "#  endif\n",
 "#  ifdef USESHADOWMAPORTHO\n",
 "#endif\n",
 "\n",
 "#if defined(USESHADOWMAP2D)\n",
-"uniform float2 ShadowMap_TextureScale : register(c35),\n",
+"uniform float4 ShadowMap_TextureScale : register(c35),\n",
 "uniform float4 ShadowMap_Parameters : register(c34),\n",
 "#endif\n",
 "\n",
 "#endif\n",
 "\n",
 "#if defined(USESHADOWMAP2D)\n",
-"uniform float2 ShadowMap_TextureScale : register(c35),\n",
+"uniform float4 ShadowMap_TextureScale : register(c35),\n",
 "uniform float4 ShadowMap_Parameters : register(c34),\n",
 "#endif\n",
 "#endif // !defined(MODE_LIGHTSOURCE) && !defined(MODE_DEFERREDLIGHTSOURCE) && !defined(USESHADOWMAPORTHO)\n",
 "//    float3 shadowmaptc = GetShadowMapTC2D(CubeVector, ShadowMap_Parameters);\n",
 "#endif\n",
 "//    color.rgb = half3(tex2D(Texture_ShadowMap2D, float2(0.1,0.1)).rgb);\n",
-"//    color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale).rgb);\n",
-"//    color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale,1.0));\n",
-"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n",
+"//    color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy).rgb);\n",
+"//    color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale.xy,1.0));\n",
+"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy));\n",
 "//    color.rgb = half3(tex2D(Texture_ShadowMap2D, float2(0.1,0.1)).rgb);\n",
-"//    color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale).rgb);\n",
-"//    color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale,1.0));\n",
-"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n",
-"//    color.r = half(shadowmaptc.z - texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n",
+"//    color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy).rgb);\n",
+"//    color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale.xy,1.0));\n",
+"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy));\n",
+"//    color.r = half(shadowmaptc.z - texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy));\n",
 "//    color.r = half(shadowmaptc.z);\n",
-"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n",
+"//    color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale.xy));\n",
 "//    color.r = half(shadowmaptc.z);\n",
 "//    color.r = 1;\n",
 "//    color.rgb = abs(CubeVector);\n",