"// uniform mediump vec4 UserVec4;\n",
"// uniform highp float ClientTime;\n",
"uniform mediump vec2 PixelSize;\n",
+"\n",
+"#ifdef USEFXAA\n",
+"// graphitemaster: based off the white paper by Timothy Lottes\n",
+"// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf\n",
+"vec4 fxaa(vec4 inColor, float maxspan)\n",
+"{\n",
+" vec4 ret = inColor; // preserve old\n",
+" float mulreduct = 1.0/maxspan;\n",
+" float minreduct = (1.0 / 128.0);\n",
+"\n",
+" // directions\n",
+" vec3 NW = texture2D(Texture_First, TexCoord1 + (vec2(-1.0, -1.0) * PixelSize)).xyz;\n",
+" vec3 NE = texture2D(Texture_First, TexCoord1 + (vec2(+1.0, -1.0) * PixelSize)).xyz;\n",
+" vec3 SW = texture2D(Texture_First, TexCoord1 + (vec2(-1.0, +1.0) * PixelSize)).xyz;\n",
+" vec3 SE = texture2D(Texture_First, TexCoord1 + (vec2(+1.0, +1.0) * PixelSize)).xyz;\n",
+" vec3 M = texture2D(Texture_First, TexCoord1).xyz;\n",
+"\n",
+" // luminance directions\n",
+" vec3 luma = vec3(0.299, 0.587, 0.114);\n",
+" float lNW = dot(NW, luma);\n",
+" float lNE = dot(NE, luma);\n",
+" float lSW = dot(SW, luma);\n",
+" float lSE = dot(SE, luma);\n",
+" float lM = dot(M, luma);\n",
+" float lMin = min(lM, min(min(lNW, lNE), min(lSW, lSE)));\n",
+" float lMax = max(lM, max(max(lNW, lNE), max(lSW, lSE)));\n",
+"\n",
+" // direction and reciprocal\n",
+" vec2 dir = vec2(-((lNW + lNE) - (lSW + lSE)), ((lNW + lSW) - (lNE + lSE)));\n",
+" float rcp = 1.0/(min(abs(dir.x), abs(dir.y)) + max((lNW + lNE + lSW + lSE) * (0.25 * mulreduct), minreduct));\n",
+"\n",
+" // span\n",
+" dir = min(vec2(maxspan, maxspan), max(vec2(-maxspan, -maxspan), dir * rcp)) * PixelSize;\n",
+"\n",
+" vec3 rA = (1.0/2.0) * (\n",
+" texture2D(Texture_First, TexCoord1 + dir * (1.0/3.0 - 0.5)).xyz +\n",
+" texture2D(Texture_First, TexCoord1 + dir * (2.0/3.0 - 0.5)).xyz);\n",
+" vec3 rB = rA * (1.0/2.0) + (1.0/4.0) * (\n",
+" texture2D(Texture_First, TexCoord1 + dir * (0.0/3.0 - 0.5)).xyz +\n",
+" texture2D(Texture_First, TexCoord1 + 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",
+" ret.a = 1.0;\n",
+" return ret;\n",
+"}\n",
+"#endif\n",
+"\n",
"void main(void)\n",
"{\n",
" dp_FragColor = dp_texture2D(Texture_First, TexCoord1);\n",
"\n",
+"#ifdef USEFXAA\n",
+" dp_FragColor = fxaa(dp_FragColor, 8.0); // 8.0 can be changed for larger span\n",
+"#endif\n",
+"\n",
"#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",
"#ifdef USETRIPPY\n",
"// LordHavoc: based on shader code linked at: http://www.youtube.com/watch?v=JpksyojwqzE\n",
"// tweaked scale\n",
-"float4 TrippyVertex(float4 position)\n",
+"float4 TrippyVertex\n",
"(\n",
-"uniform float ClientTime : register(c2)\n",
+"float4 position,\n",
+"float ClientTime\n",
")\n",
"{\n",
" float worldTime = ClientTime;\n",
"(\n",
"float4 gl_Vertex : POSITION,\n",
"uniform float4x4 ModelViewProjectionMatrix : register(c8),\n",
+"uniform float ClientTime : register(c2),\n",
"out float4 gl_Position : POSITION,\n",
"out float Depth : TEXCOORD0\n",
")\n",
"{\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
" Depth = gl_Position.z;\n",
"}\n",
"float4 gl_MultiTexCoord0 : TEXCOORD0,\n",
"float4 gl_MultiTexCoord4 : TEXCOORD4,\n",
"out float4 gl_Position : POSITION,\n",
-"out float2 TexCoord1 : TEXCOORD0,\n",
-"out float2 TexCoord2 : TEXCOORD1\n",
+"out float2 TexCoord1 : TEXCOORD0\n",
+"#ifdef USEBLOOM\n",
+", out float2 TexCoord2 : TEXCOORD1\n",
+"#endif\n",
")\n",
"{\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
"#endif\n",
"\n",
"#ifdef FRAGMENT_SHADER\n",
+"#ifdef USEFXAA\n",
+"// graphitemaster: based off the white paper by Timothy Lottes\n",
+"// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf\n",
+"float4 fxaa\n",
+"(\n",
+" float4 inColor,\n",
+" float maxspan,\n",
+" float2 TexCoord1,\n",
+" uniform sampler Texture_First,\n",
+" uniform float2 PixelSize\n",
+")\n",
+"{\n",
+" float4 ret = inColor; // preserve old\n",
+" float mulreduct = 1.0/maxspan;\n",
+" float minreduct = (1.0 / 128.0);\n",
+"\n",
+" float3 NW = tex2D(Texture_First, TexCoord1 + (float2(-1.0, -1.0) * PixelSize)).xyz;\n",
+" float3 NE = tex2D(Texture_First, TexCoord1 + (float2(+1.0, -1.0) * PixelSize)).xyz;\n",
+" float3 SW = tex2D(Texture_First, TexCoord1 + (float2(-1.0, +1.0) * PixelSize)).xyz;\n",
+" float3 SE = tex2D(Texture_First, TexCoord1 + (float2(+1.0, +1.0) * PixelSize)).xyz;\n",
+" float3 M = tex2D(Texture_First, TexCoord1).xyz;\n",
+"\n",
+" // luminance directions\n",
+" float3 luma = float3(0.299, 0.587, 0.114);\n",
+" float lNW = dot(NW, luma);\n",
+" float lNE = dot(NE, luma);\n",
+" float lSW = dot(SW, luma);\n",
+" float lSE = dot(SE, luma);\n",
+" float lM = dot(M, luma);\n",
+" float lMin = min(lM, min(min(lNW, lNE), min(lSW, lSE)));\n",
+" float lMax = max(lM, max(max(lNW, lNE), max(lSW, lSE)));\n",
+"\n",
+" // direction and reciprocal\n",
+" float2 dir = float2(-((lNW + lNE) - (lSW + lSE)), ((lNW + lSW) - (lNE + lSE)));\n",
+" float rcp = 1.0/(min(abs(dir.x), abs(dir.y)) + max((lNW + lNE + lSW + lSE) * (0.25 * mulreduct), minreduct));\n",
+"\n",
+" // span\n",
+" dir = min(float2(maxspan, maxspan), max(float2(-maxspan, -maxspan), dir * rcp)) * PixelSize;\n",
+"\n",
+" float3 rA = (1.0/2.0) * (\n",
+" tex2D(Texture_First, TexCoord1 + dir * (1.0/3.0 - 0.5)).xyz +\n",
+" tex2D(Texture_First, TexCoord1 + dir * (2.0/3.0 - 0.5)).xyz);\n",
+" float3 rB = rA * (1.0/2.0) + (1.0/4.0) * (\n",
+" tex2D(Texture_First, TexCoord1 + dir * (0.0/3.0 - 0.5)).xyz +\n",
+" tex2D(Texture_First, TexCoord1 + 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",
+" ret.a = 1.0;\n",
+" return ret;\n",
+"}\n",
+"#endif\n",
+"\n",
"void main\n",
"(\n",
"float2 TexCoord1 : TEXCOORD0,\n",
+"#ifdef USEBLOOM\n",
"float2 TexCoord2 : TEXCOORD1,\n",
+"#endif\n",
"uniform sampler Texture_First : register(s0),\n",
"#ifdef USEBLOOM\n",
"uniform sampler Texture_Second : register(s1),\n",
"{\n",
" dp_FragColor = tex2D(Texture_First, TexCoord1);\n",
"\n",
+"#ifdef USEFXAA\n",
+" dp_FragColor = fxaa(dp_FragColor, 8.0, TexCoord1, Texture_First, PixelSize); // 8.0 can be changed for larger span\n",
+"#endif\n",
+"\n",
"#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",
"float4 gl_Color : COLOR0,\n",
"float4 gl_MultiTexCoord0 : TEXCOORD0,\n",
"float4 gl_MultiTexCoord1 : TEXCOORD1,\n",
+"uniform float ClientTime : register(c2),\n",
"out float4 gl_Position : POSITION,\n",
"#ifdef USEDIFFUSE\n",
"out float2 TexCoord1 : TEXCOORD0,\n",
"#endif\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
"}\n",
"#endif\n",
"float4 gl_MultiTexCoord0 : TEXCOORD0,\n",
"uniform float4x4 TexMatrix : register(c0),\n",
"uniform float3 EyePosition : register(c24),\n",
+"uniform float ClientTime : register(c2),\n",
"#ifdef USEALPHAGENVERTEX\n",
"out float4 gl_FrontColor : COLOR,\n",
"#endif\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
" ModelViewProjectionPosition = gl_Position;\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
"}\n",
"#endif\n",
"float4 gl_MultiTexCoord3 : TEXCOORD3,\n",
"uniform float4x4 TexMatrix : register(c0),\n",
"uniform float3 EyePosition : register(c24),\n",
+"uniform float ClientTime : register(c2),\n",
"#ifdef USEALPHAGENVERTEX\n",
"out float4 gl_FrontColor : COLOR,\n",
"#endif\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
" ModelViewProjectionPosition = gl_Position;\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
"}\n",
"#endif\n",
"#ifdef USEOFFSETMAPPING\n",
"uniform float3 EyePosition : register(c24),\n",
"#endif\n",
+"uniform float ClientTime : register(c2),\n",
"out float4 gl_Position : POSITION,\n",
"#ifdef USEVERTEXTEXTUREBLEND\n",
"out float4 gl_FrontColor : COLOR,\n",
" VectorR.xyz = mul(ModelViewMatrix, float4(gl_MultiTexCoord3.xyz, 0)).xyz;\n",
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
" VectorR.w = mul(ModelViewMatrix, gl_Vertex).z;\n",
"}\n",
"#ifdef USESHADOWMAPORTHO\n",
"uniform float4x4 ShadowMapMatrix : register(c16),\n",
"#endif\n",
+"uniform float ClientTime : register(c2),\n",
"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n",
"out float4 gl_FrontColor : COLOR,\n",
"#endif\n",
" ModelViewProjectionPosition = gl_Position;\n",
"#endif\n",
"#ifdef USETRIPPY\n",
-" gl_Position = TrippyVertex(gl_Position);\n",
+" gl_Position = TrippyVertex(gl_Position, ClientTime);\n",
"#endif\n",
"}\n",
"#endif // VERTEX_SHADER\n",