]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Use wider vector for postproc with bloom instead of 2 smaller vectors
authoruis <uis9936@gmail.com>
Wed, 3 Jan 2024 18:39:27 +0000 (21:39 +0300)
committeruis <uis9936@gmail.com>
Wed, 3 Jan 2024 23:36:36 +0000 (02:36 +0300)
shader_glsl.h

index 4f9488c6b3f7e0c6827849bb13365019baecbb71..35f8b50bab23b289ef1507183cd7590f602678cf 100644 (file)
 "\n",
 "\n",
 "#ifdef MODE_POSTPROCESS\n",
+"#ifdef USEBLOOM\n",
+"dp_varying mediump vec4 TexCoord1;\n",
+"#else\n",
 "dp_varying mediump vec2 TexCoord1;\n",
-"dp_varying mediump vec2 TexCoord2;\n",
+"#endif\n",
 "\n",
 "#ifdef VERTEX_SHADER\n",
 "void main(void)\n",
 "{\n",
 "      gl_Position = ModelViewProjectionMatrix * Attrib_Position;\n",
-"      TexCoord1 = Attrib_TexCoord0.xy;\n",
+"      TexCoord1.xy = Attrib_TexCoord0.xy;\n",
 "#ifdef USEBLOOM\n",
-"      TexCoord2 = Attrib_TexCoord4.xy;\n",
+"      TexCoord1.zw = Attrib_TexCoord4.xy;\n",
 "#endif\n",
 "}\n",
 "#endif\n",
 "      float minreduct = (1.0 / 128.0);\n",
 "\n",
 "      // directions\n",
-"      vec3 NW = dp_texture2D(Texture_First, TexCoord1 + (vec2(-1.0, -1.0) * PixelSize)).xyz;\n",
-"      vec3 NE = dp_texture2D(Texture_First, TexCoord1 + (vec2(+1.0, -1.0) * PixelSize)).xyz;\n",
-"      vec3 SW = dp_texture2D(Texture_First, TexCoord1 + (vec2(-1.0, +1.0) * PixelSize)).xyz;\n",
-"      vec3 SE = dp_texture2D(Texture_First, TexCoord1 + (vec2(+1.0, +1.0) * PixelSize)).xyz;\n",
-"      vec3 M = dp_texture2D(Texture_First, TexCoord1).xyz;\n",
+"      vec3 NW = dp_texture2D(Texture_First, TexCoord1.xy + (vec2(-1.0, -1.0) * PixelSize)).xyz;\n",
+"      vec3 NE = dp_texture2D(Texture_First, TexCoord1.xy + (vec2(+1.0, -1.0) * PixelSize)).xyz;\n",
+"      vec3 SW = dp_texture2D(Texture_First, TexCoord1.xy + (vec2(-1.0, +1.0) * PixelSize)).xyz;\n",
+"      vec3 SE = dp_texture2D(Texture_First, TexCoord1.xy + (vec2(+1.0, +1.0) * PixelSize)).xyz;\n",
+"      vec3 M = dp_texture2D(Texture_First, TexCoord1.xy).xyz;\n",
 "\n",
 "      // luminance directions\n",
 "      vec3 luma = vec3(0.299, 0.587, 0.114);\n",
 "      dir = min(vec2(maxspan, maxspan), max(vec2(-maxspan, -maxspan), dir * rcp)) * PixelSize;\n",
 "\n",
 "      vec3 rA = (1.0/2.0) * (\n",
-"              dp_texture2D(Texture_First, TexCoord1 + dir * (1.0/3.0 - 0.5)).xyz +\n",
-"              dp_texture2D(Texture_First, TexCoord1 + dir * (2.0/3.0 - 0.5)).xyz);\n",
+"              dp_texture2D(Texture_First, TexCoord1.xy + dir * (1.0/3.0 - 0.5)).xyz +\n",
+"              dp_texture2D(Texture_First, TexCoord1.xy + dir * (2.0/3.0 - 0.5)).xyz);\n",
 "      vec3 rB = rA * (1.0/2.0) + (1.0/4.0) * (\n",
-"              dp_texture2D(Texture_First, TexCoord1 + dir * (0.0/3.0 - 0.5)).xyz +\n",
-"              dp_texture2D(Texture_First, TexCoord1 + dir * (3.0/3.0 - 0.5)).xyz);\n",
+"              dp_texture2D(Texture_First, TexCoord1.xy + dir * (0.0/3.0 - 0.5)).xyz +\n",
+"              dp_texture2D(Texture_First, TexCoord1.xy + dir * (3.0/3.0 - 0.5)).xyz);\n",
 "      float lB = dot(rB, luma);\n",
 "\n",
 "      ret.xyz = ((lB < lMin) || (lB > lMax)) ? rA : rB;\n",
 "{\n",
 "#ifdef USECOLORFRINGE\n",
 "      float fringe = ColorFringe;//.0033f;\n",
-"      float amount = distance(TexCoord1, vec2(.5f,.5f));\n",
+"      float amount = distance(TexCoord1.xy, vec2(.5f,.5f));\n",
 "      vec2 offset = vec2(amount*fringe,amount*fringe);\n",
-"      dp_FragColor.xy = dp_texture2D(Texture_First, TexCoord1-offset).xy;\n",
-"      dp_FragColor.z = dp_texture2D(Texture_First, TexCoord1+offset).z;\n",
+"      dp_FragColor.xy = dp_texture2D(Texture_First, TexCoord1.xy-offset).xy;\n",
+"      dp_FragColor.z = dp_texture2D(Texture_First, TexCoord1.xy+offset).z;\n",
 "#else\n",
-"      dp_FragColor = dp_texture2D(Texture_First, TexCoord1);\n",
+"      dp_FragColor = dp_texture2D(Texture_First, TexCoord1.xy);\n",
 "#endif\n",
 "\n",
 "#ifdef USEFXAA\n",
 "      // vec2 ts = textureSize(Texture_First, 0);\n",
 "      // vec2 px = vec2(1/ts.x, 1/ts.y);\n",
 "      vec2 px = PixelSize;\n",
-"      vec3 x1 = dp_texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y)).rgb;\n",
-"      vec3 x2 = dp_texture2D(Texture_First, TexCoord1 + vec2(-px.x,  0.0)).rgb;\n",
-"      vec3 x3 = dp_texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y)).rgb;\n",
-"      vec3 x4 = dp_texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y)).rgb;\n",
-"      vec3 x5 = dp_texture2D(Texture_First, TexCoord1 + vec2( px.x,  0.0)).rgb;\n",
-"      vec3 x6 = dp_texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y)).rgb;\n",
-"      vec3 y1 = dp_texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y)).rgb;\n",
-"      vec3 y2 = dp_texture2D(Texture_First, TexCoord1 + vec2(  0.0,-px.y)).rgb;\n",
-"      vec3 y3 = dp_texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y)).rgb;\n",
-"      vec3 y4 = dp_texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y)).rgb;\n",
-"      vec3 y5 = dp_texture2D(Texture_First, TexCoord1 + vec2(  0.0, px.y)).rgb;\n",
-"      vec3 y6 = dp_texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y)).rgb;\n",
+"      vec3 x1 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x, px.y)).rgb;\n",
+"      vec3 x2 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x,  0.0)).rgb;\n",
+"      vec3 x3 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x,-px.y)).rgb;\n",
+"      vec3 x4 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x, px.y)).rgb;\n",
+"      vec3 x5 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x,  0.0)).rgb;\n",
+"      vec3 x6 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x,-px.y)).rgb;\n",
+"      vec3 y1 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x,-px.y)).rgb;\n",
+"      vec3 y2 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(  0.0,-px.y)).rgb;\n",
+"      vec3 y3 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x,-px.y)).rgb;\n",
+"      vec3 y4 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x, px.y)).rgb;\n",
+"      vec3 y5 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(  0.0, px.y)).rgb;\n",
+"      vec3 y6 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x, px.y)).rgb;\n",
 "      float px1 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x1);\n",
 "      float px2 = -2.0 * dot(vec3(0.3, 0.59, 0.11), x2);\n",
 "      float px3 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x3);\n",
 "      float py5 =  2.0 * dot(vec3(0.3, 0.59, 0.11), y5);\n",
 "      float py6 =  1.0 * dot(vec3(0.3, 0.59, 0.11), y6);\n",
 "      sobel = 0.25 * abs(px1 + px2 + px3 + px4 + px5 + px6) + 0.25 * abs(py1 + py2 + py3 + py4 + py5 + py6);\n",
-"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.987688, -0.156434)) * UserVec1.y;\n",
-"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.156434, -0.891007)) * UserVec1.y;\n",
-"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.891007, -0.453990)) * UserVec1.y;\n",
-"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.707107,  0.707107)) * UserVec1.y;\n",
-"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.453990,  0.891007)) * UserVec1.y;\n",
+"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2(-0.987688, -0.156434)) * UserVec1.y;\n",
+"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2(-0.156434, -0.891007)) * UserVec1.y;\n",
+"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2( 0.891007, -0.453990)) * UserVec1.y;\n",
+"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2( 0.707107,  0.707107)) * UserVec1.y;\n",
+"      dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2(-0.453990,  0.891007)) * UserVec1.y;\n",
 "      dp_FragColor /= (1.0 + 5.0 * UserVec1.y);\n",
 "      dp_FragColor.rgb = dp_FragColor.rgb * (1.0 + UserVec2.x) + vec3(max(0.0, sobel - UserVec2.z))*UserVec2.y;\n",
 "#endif\n",
 "#endif\n",
 "\n",
 "#ifdef USEBLOOM\n",
-"      dp_FragColor += max(vec4(0,0,0,0), dp_texture2D(Texture_Second, TexCoord2) - BloomColorSubtract);\n",
+"      dp_FragColor += max(vec4(0,0,0,0), dp_texture2D(Texture_Second, TexCoord1.zw) - BloomColorSubtract);\n",
 "#endif\n",
 "\n",
 "#ifdef USEVIEWTINT\n",