#version 140 #pragma optionNV(fastmath on) #pragma optionNV(ifcvt none) #pragma optionNV(inline all) #pragma optionNV(strict on) #pragma optionNV(unroll all) in vec2 frag_TEXCOORD0; in vec2 frag_TEXCOORD1; in vec2 frag_TEXCOORD2; in vec2 frag_TEXCOORD3; out vec4 rast_SV_Target; // // Structure definitions // struct VS_OUTPUT { vec4 position; vec2 uvr; vec2 uvg; vec2 uvb; vec2 uvn; }; // // Global variable definitions // layout (std140) uniform timewarpBuffer { mat4 timewarp; mat4 proj; mat4 invProj; vec4 colorMask; float vignette; float blackLevel; float gamma; }; //uniform float blackLevel; //uniform vec4 colorMask; //uniform float gamma; //uniform mat4 invProj; //uniform float vignette; layout (std140) uniform overlayBuffer { mat4 rot; vec4 P0; vec4 coef; // CURVED x: 2.0 * theta, y: aspect / scale, z: aspect // FLAT x: 1 / scale, y: aspect / scale, z: distance vec4 kernel[2]; vec4 uvOffset; float alpha; }; //uniform vec4 P0; //uniform float alpha; //uniform vec4 coef; //uniform mat4 rot; //uniform vec4 uvOffset; uniform sampler2D g_txScene; uniform sampler2D g_txOverlay; // // Function declarations // vec4 FadeEdges( in vec4 color, in vec2 uv ); vec4 scene( in vec2 uv ); vec4 cylinder( in vec2 uv ); vec4 cylinder4( in vec2 uv ); vec4 CalcRay( in vec2 uv ); vec4 PSAA_CURVED( in VS_OUTPUT xlat_var_input ); // // Function definitions // vec4 FadeEdges( in vec4 color, in vec2 uv ) { vec2 edge; edge = (clamp(((abs((uv - vec2 (0.5))) + vec2 (vignette)) - vec2 (0.5)), 0.0, 1.0) / vignette); color.xyz = mix( color.xyz , colorMask.xyz , vec3( dot( edge, edge))); color.xyz = max( color.xyz , vec3( blackLevel)); return color; } vec4 cylinder( in vec2 uv ) { float opacity = 0.000000; vec4 V; float a; float b; float c; float det; float t; vec3 P; vec2 edge; float bg; vec4 color; V = CalcRay( uv); a = dot( V.xz , V.xz ); b = (2.00000 * dot( V.xz , P0.xz )); c = (dot( P0.xz , P0.xz ) - P0.w ); det = ((b * b) - ((4.00000 * a) * c)); if ( (det > 0.000000) ){ t = ((sqrt( det ) - b) / (2.00000 * a)); if ( (t > 0.000000) ){ P = (P0.xyz + (V.xyz * t)); P.x = (atan( P.x , ( -P.z )) / coef.x ); P.y *= coef.y ; uv = (P.xy + 0.500000); uv += uvOffset.xy ; uv *= uvOffset.zw ; edge = vec2( greaterThan( abs( (uv - 0.500000) ), vec2( 0.500000 )) ); bg = dot( edge, edge); opacity = (alpha * clamp( (1.00000 - bg), 0.0, 1.0)); } } color = texture( g_txOverlay, uv); color.w *= opacity; return color; } vec4 cylinder4( in vec2 uv ) { vec4 c1; vec4 c2; vec4 c3; vec4 c4; c1 = cylinder( (uv + kernel[ 0 ].xy )); c2 = cylinder( (uv + kernel[ 0 ].zw )); c3 = cylinder( (uv + kernel[ 1 ].xy )); c4 = cylinder( (uv + kernel[ 1 ].zw )); return ((((c1 + c2) + c3) + c4) / 4.00000); } vec4 scene( in vec2 uv ) { return pow( texture( g_txScene, uv), vec4( gamma)); } vec4 CalcRay( in vec2 uv ) { vec4 ndc; ndc = vec4( ((2.00000 * uv.x ) - 1.00000), ((2.00000 * uv.y ) - 1.00000), 1.00000, 1.00000); ndc = ( invProj * ndc ); ndc /= ndc.w ; return normalize( ( rot * ndc ) ); } vec4 PSAA_CURVED( in VS_OUTPUT xlat_var_input ) { vec4 rsamp; vec4 gsamp; vec4 bsamp; vec4 color; rsamp = cylinder4( xlat_var_input.uvr); gsamp = cylinder4( xlat_var_input.uvg); bsamp = cylinder4( xlat_var_input.uvb); color = vec4( mix( scene( xlat_var_input.uvr).x , rsamp.x , rsamp.w ), mix( scene( xlat_var_input.uvg).y , gsamp.y , gsamp.w ), mix( scene( xlat_var_input.uvb).z , bsamp.z , bsamp.w ), 1.00000); return FadeEdges( color, xlat_var_input.uvn); } // // User varying // in vec4 xlat_varying_SV_POSITION; // // Translator's entry point // void main() { VS_OUTPUT xlat_temp_xlat_var_input; xlat_temp_xlat_var_input.position = vec4( xlat_varying_SV_POSITION); xlat_temp_xlat_var_input.uvr = frag_TEXCOORD0; xlat_temp_xlat_var_input.uvg = frag_TEXCOORD1; xlat_temp_xlat_var_input.uvb = frag_TEXCOORD2; xlat_temp_xlat_var_input.uvn = frag_TEXCOORD3; rast_SV_Target = PSAA_CURVED( xlat_temp_xlat_var_input); }