From: uis Date: Wed, 3 Jan 2024 23:02:09 +0000 (+0300) Subject: More saturated math X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4b610cc0e1b87ef311368d30bb78dd98db2ca0fb;p=xonotic%2Fdarkplaces.git More saturated math --- diff --git a/shader_glsl.h b/shader_glsl.h index 36c8e265..8bd032ef 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -676,7 +676,7 @@ " #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", -" vec4 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(normal) + vec3(0.15)).xyxy * distort;\n", +" vec4 ScreenTexCoord = SafeScreenTexCoord + (normalize(normal) + vec3(0.15)).xyxy * distort;\n", " #else\n", " vec4 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(vec3(dp_texture2D(Texture_Normal, TexCoord)) - vec3(0.5))).xyxy * distort;\n", " #endif\n", @@ -842,7 +842,7 @@ " return mix(fogheightpixel.rgb * fc, surfacecolor.rgb, dp_texture2D(Texture_FogMask, cast_myhalf2(length(EyeVectorModelSpace)*fogfrac*FogRangeRecip, 0.0)).r);\n", "#else\n", "# ifdef USEFOGOUTSIDE\n", -" fogfrac = min(0.0, FogPlaneVertexDist) / (FogPlaneVertexDist - FogPlaneViewDist) * min(1.0, min(0.0, FogPlaneVertexDist) * FogHeightFade);\n", +" fogfrac = min(0.0, FogPlaneVertexDist) / (FogPlaneVertexDist - FogPlaneViewDist) * min(1.0, min(0.0, FogPlaneVertexDist) * FogHeightFade);\n",//TODO: can saturate? "# else\n", " fogfrac = FogPlaneViewDist / (FogPlaneViewDist - max(0.0, FogPlaneVertexDist)) * min(1.0, (min(0.0, FogPlaneVertexDist) + FogPlaneViewDist) * FogHeightFade);\n", "# endif\n", @@ -1370,9 +1370,10 @@ "\n", "#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(USEREFLECTCUBE) || defined(USEBOUNCEGRIDDIRECTIONAL)\n", "# ifdef USEFOG\n", -" VectorS = vec4(Attrib_TexCoord1.xyz, EyePosition.x - Attrib_Position.x);\n", -" VectorT = vec4(Attrib_TexCoord2.xyz, EyePosition.y - Attrib_Position.y);\n", -" VectorR = vec4(Attrib_TexCoord3.xyz, EyePosition.z - Attrib_Position.z);\n", +" vec3 EyeDir = EyePosition - Attrib_Position.xyz;\n", +" VectorS = vec4(Attrib_TexCoord1.xyz, EyeDir.x);\n", +" VectorT = vec4(Attrib_TexCoord2.xyz, EyeDir.y);\n", +" VectorR = vec4(Attrib_TexCoord3.xyz, EyeDir.z);\n", "# else\n", " VectorS = vec4(Attrib_TexCoord1, 0);\n", " VectorT = vec4(Attrib_TexCoord2, 0);\n", @@ -1470,10 +1471,10 @@ "#ifdef USEVERTEXTEXTUREBLEND\n", "#ifdef USEBOTHALPHAS\n", " myhalf4 color2 = cast_myhalf4(dp_texture2D(Texture_SecondaryColor, TexCoord2));\n", -" myhalf terrainblend = clamp(cast_myhalf(VertexColor.a) * color.a, cast_myhalf(1.0 - color2.a), cast_myhalf(1.0));\n", +" myhalf terrainblend = max(sat(cast_myhalf(VertexColor.a) * color.a), cast_myhalf(1.0 - color2.a));\n",//move sat outside? " color.rgb = mix(color2.rgb, color.rgb, terrainblend);\n", "#else\n", -" myhalf terrainblend = clamp(cast_myhalf(VertexColor.a) * color.a * 2.0 - 0.5, cast_myhalf(0.0), cast_myhalf(1.0));\n", +" myhalf terrainblend = sat(cast_myhalf(VertexColor.a) * color.a * 2.0 - 0.5);\n", " //myhalf terrainblend = min(cast_myhalf(VertexColor.a) * color.a * 2.0, cast_myhalf(1.0));\n", " //myhalf terrainblend = cast_myhalf(VertexColor.a) * color.a > 0.5;\n", " color.rgb = mix(cast_myhalf3(dp_texture2D(Texture_SecondaryColor, TexCoord2)), color.rgb, terrainblend);\n", @@ -1644,8 +1645,8 @@ " myhalf4 bouncegrid_coeff7 = cast_myhalf4(dp_texture3D(Texture_BounceGrid, BounceGridTexCoord + vec3(0.0, 0.0, 0.750)));\n", " myhalf4 bouncegrid_coeff8 = cast_myhalf4(dp_texture3D(Texture_BounceGrid, BounceGridTexCoord + vec3(0.0, 0.0, 0.875)));\n", " myhalf3 bouncegrid_dir = normalize(mat3(BounceGridMatrix) * (surfacenormal.x * VectorS.xyz + surfacenormal.y * VectorT.xyz + surfacenormal.z * VectorR.xyz));\n", -" myhalf3 bouncegrid_dirp = max(cast_myhalf3(0.0, 0.0, 0.0), bouncegrid_dir);\n", -" myhalf3 bouncegrid_dirn = max(cast_myhalf3(0.0, 0.0, 0.0), -bouncegrid_dir);\n", +" myhalf3 bouncegrid_dirp = possat(bouncegrid_dir);\n", +" myhalf3 bouncegrid_dirn = possat(-bouncegrid_dir);\n", "// bouncegrid_dirp = bouncegrid_dirn = cast_myhalf3(1.0,1.0,1.0);\n", " myhalf3 bouncegrid_light = cast_myhalf3(\n", " dot(bouncegrid_coeff3.xyz, bouncegrid_dirp) + dot(bouncegrid_coeff6.xyz, bouncegrid_dirn),\n", @@ -1692,12 +1693,12 @@ " float DepthScale1 = 4.0 / DepthCenter; // inner ink (shadow on object)\n", "// float DepthScale1 = -4.0 / DepthCenter; // outer ink (shadow around object)\n", "// float DepthScale1 = 0.003;\n", -" float DepthScale2 = DepthScale1 / 2.0;\n", +" float DepthScale2 = DepthScale1 * 0.5;\n", "// float DepthScale3 = DepthScale1 / 4.0;\n", " float DepthBias1 = -DepthCenter * DepthScale1;\n", " float DepthBias2 = -DepthCenter * DepthScale2;\n", "// float DepthBias3 = -DepthCenter * DepthScale3;\n", -" float DepthShadow = max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2(-1.0, 0.0)).b * DepthScale1 + DepthBias1)\n", +" float DepthShadow = max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2(-1.0, 0.0)).b * DepthScale1 + DepthBias1)\n",//TODO: can saturate? " + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 1.0, 0.0)).b * DepthScale1 + DepthBias1)\n", " + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, -1.0)).b * DepthScale1 + DepthBias1)\n", " + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, 1.0)).b * DepthScale1 + DepthBias1)\n", @@ -1710,7 +1711,7 @@ "// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, -3.0)).b * DepthScale3 + DepthBias3)\n", "// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, 3.0)).b * DepthScale3 + DepthBias3)\n", " - 0.0;\n", -" color.rgb *= 1.0 - max(0.0, min(DepthShadow, 1.0));\n", +" color.rgb *= sat(1.0 - DepthShadow);\n", "// color.r = DepthCenter / -1024.0;\n", "# endif\n", "#endif\n",