GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/NVIDIA Corporation/Ansel/ShaderMod/ |
Upload File : |
cbuffer globalParams { float2 screenSize; int captureState; float4 tileUV; } cbuffer controlBuf { float g_sldSketch; float g_sldHalfTone; float g_sldRetro; float g_sldSepia; } Texture2D texColor; Texture2D texNoise; SamplerState samLinear; // This should move to a centralized file but not appropriate to make that change now. #ifndef NV_COMMON #define NV_COMMON #define CAPTURE_STATE_NOT_STARTED 0 #define CAPTURE_STATE_REGULAR 1 #define CAPTURE_STATE_REGULARSTEREO 2 #define CAPTURE_STATE_HIGHRES 3 #define CAPTURE_STATE_360 4 #define CAPTURE_STATE_360STEREO 5 #endif //SKETCH float3 sketch(float3 colorInput, float2 uv, Texture2D texColor) { const int ks = 3; // Sobel Horizontal //vertical is just transposed float filterKernelH[ks * ks] = { -1, 0, 1, -2, 0, 2, -1, 0, 1 }; float3 clrH = 0; float3 clrV = 0; float3 clr; [unroll]for(int i = -1; i <=1; i++) [unroll]for(int j = -1; j <=1; j++) { clr = texColor.Sample(samLinear, uv, int2(i, j)).rgb; clrH += clr * filterKernelH[(i+1) + (j+1) * ks]; clrV += clr * filterKernelH[(j+1) + (i+1) * ks]; } float3 sobelLengths = sqrt(clrH * clrH + clrV * clrV); #define INVERT #ifndef INVERT float3 outputColor = lerp(colorInput, sobelLengths, 0.45); #else float3 outputColor = lerp(colorInput, 1-sobelLengths, 0.45); #endif return lerp(colorInput, outputColor, g_sldSketch); } //HALFTONE #define FREQUENCY ((float)(screenSize.x) / 6.0) #define CONTRAST 0.7 float AntiAlias(float threshold, float value) { float width = 0.75 * fwidth(value); return smoothstep(threshold - width, threshold + width, value); } float DotGrid(float2 uvSquare, float angle, float radius, float noise, float coeff) { noise *= 0.1; // Noise breaks up moire etc float s = sin(angle); float c = cos(angle); float2 uvRot = mul(float2x2(c, -s, s, c), uvSquare); float2 nearest = 2.0 * frac(FREQUENCY / coeff * uvRot) - 1.0; return AntiAlias(1.0 - radius, length(nearest) * CONTRAST - noise) + noise; } float4 CmykFromRgb(float3 c) { float k = 1.0 - max(max(c.r, c.g), c.b); float4 cmyk; cmyk.rgb = (1.0.xxx - c.rgb - k.xxx) / (1.0 - k); cmyk.a = k; return cmyk; } float3 RgbFromCmyk(float4 c) { return (1.0.xxx - c.rgb) * (1.0 - c.a); } float3 halftone(float3 color, float2 uv) { if (captureState == CAPTURE_STATE_360 || captureState == CAPTURE_STATE_360STEREO) return color; float aspect = screenSize.y / screenSize.x; float2 uvSquare = float2(uv.x, uv.y * aspect); float3 noise = texNoise.Sample(samLinear, uv).rgb; float4 cmyk = 1.0.xxxx - CmykFromRgb(color); float coeff = 1.0; float4 cmykDot; cmykDot.r = DotGrid(uvSquare, 0.261799, cmyk.r, noise.x, coeff); // C 15 degrees cmykDot.g = DotGrid(uvSquare, 1.309, cmyk.g, noise.y, coeff); // M 75 degrees cmykDot.b = DotGrid(uvSquare, 0, cmyk.b, noise.z, coeff); // Y 0 degrees cmykDot.a = DotGrid(uvSquare, 0.785398, cmyk.a, noise.x, coeff); // K 45 degrees // Convert to RGB return lerp(color, RgbFromCmyk(1.0.xxxx - cmykDot), g_sldHalfTone); } // Blur #define fBlurSpeed 0.4 // [0.0 to 0.5] Speed at which to lerp to blur texture in half uv // Toning (for the actual curves, see the shader) #define fToningSpeed 0.4 // [0.0 to 0.5] Speed of toning change from center, in half uv // Distort #define fDistortStrength 0.2 // Desat #define fDesat 0.2 // Vignette #define g_sldVignette 1.5 //[0.0 to 1.0] Vignette amount // Parameters for smart fetch #define SMART_CLAMP_CONSTR_BORDER 2.0 #define SMART_CLAMP_FETCH_BORDER 15.0 float Curve(float x, float contrast, float scale) { x -= 0.5; x *= contrast; x += 0.5; x *= scale; return x; } // special clamping for games that have garbage on the edge of the frame float2 smartClampUV(float2 uvTexCoord, float constrainBorderWidth, float fetchBorderWidth) { const float2 oneTexel = float2(1.0/screenSize.x, 1.0/screenSize.y); if (uvTexCoord.x > 1.0 - constrainBorderWidth*oneTexel.x) uvTexCoord.x = 1.0 - constrainBorderWidth*oneTexel.x - fetchBorderWidth*oneTexel.x; if (uvTexCoord.x < 0.0 + constrainBorderWidth*oneTexel.x) uvTexCoord.x = 0.0 + constrainBorderWidth*oneTexel.x + fetchBorderWidth*oneTexel.x; if (uvTexCoord.y > 1.0 - constrainBorderWidth*oneTexel.y) uvTexCoord.y = 1.0 - constrainBorderWidth*oneTexel.y - fetchBorderWidth*oneTexel.y; if (uvTexCoord.y < 0.0 + constrainBorderWidth*oneTexel.y) uvTexCoord.y = 0.0 + constrainBorderWidth*oneTexel.y + fetchBorderWidth*oneTexel.y; return uvTexCoord; } float3 retro(float3 color, inout float2 inout_tile_uv) { //porting this with no warranty .. float2 uv = (tileUV.zw - tileUV.xy) * inout_tile_uv.xy + tileUV.xy; //convert local tile uv to global screen uv float2 uvScreen = uv; //doing this in main pass //bool arePartsAllowed = (captureState != CAPTURE_STATE_360 && captureState != CAPTURE_STATE_360STEREO); // Barrel distortion float2 uvDistort = (uv - 0.5); float2 uvTexCoord = inout_tile_uv; //if (arePartsAllowed) //{ float maxDistort = (1.0 - 0.5) * (fDistortStrength / (tileUV.z - tileUV.x)); float distortNrm = 1.0; // For highres pictures, we need to limit distortion to avoid artifacts if (captureState == CAPTURE_STATE_HIGHRES) { const float maxDistortAllowed = 0.2; if (maxDistort > maxDistortAllowed) distortNrm = maxDistortAllowed / maxDistort; } float distort = saturate(dot(uvDistort, uvDistort)) * (fDistortStrength / (tileUV.z - tileUV.x)) * distortNrm; uvTexCoord -= normalize(uvDistort) * distort * g_sldRetro; if (captureState == CAPTURE_STATE_HIGHRES) { uvTexCoord = smartClampUV(uvTexCoord, SMART_CLAMP_CONSTR_BORDER, SMART_CLAMP_FETCH_BORDER); } //} inout_tile_uv = uvTexCoord; color = texColor.Sample(samLinear, uvTexCoord).rgb; color = lerp(color, dot(color, 0.333), fDesat * g_sldRetro); // Toning //if (arePartsAllowed) //{ float toning = saturate(smoothstep(0.0, fToningSpeed, dot(uvDistort, uvDistort))); float3 colorCenter = color.rgb; colorCenter.r = Curve(colorCenter.r, 1.3, 1.4); colorCenter.g = Curve(colorCenter.g, 1.3, 1.3); colorCenter.b = Curve(colorCenter.b, 0.7, 0.8); float3 colorEdge = color.rgb; colorEdge.r = Curve(colorEdge.r, 1.0, 0.6); colorEdge.g = Curve(colorEdge.g, 1.0, 0.7); colorEdge.b = Curve(colorEdge.b, 0.5, 1.5); color.xyz = lerp(color.xyz, saturate(lerp(colorCenter, colorEdge, toning)), g_sldRetro); //} // Apply vignette //if (arePartsAllowed) //{ float2 inTex = uv - 0.5.xx; // Distance from center inTex.x *= 1.2; // Slight aspect ratio correction float vignette = saturate(1.0 - dot( inTex, inTex )); // Length vignette = saturate(smoothstep(0.3, 1.0, vignette)); // Smoothstep color.xyz = lerp(color.xyz, float3(0.0, 0.0, 0.0), (1.0 - vignette) * g_sldVignette * g_sldRetro); //} return color; } float3 sepia(float3 color) { return lerp(color, dot(color, float3( 0.2126, 0.7152, 0.0722)) * float3(1.2, 1.0, 0.8), g_sldSepia); } void PS(in float4 position : SV_Position, in float2 uv : TexCoord, out float4 color : SV_Target) { color = texColor.Sample(samLinear, uv); if(captureState != CAPTURE_STATE_360 && captureState != CAPTURE_STATE_360STEREO) { if(g_sldRetro != 0) color.rgb = retro(color, uv); if(g_sldSketch != 0) color.rgb = sketch(color.rgb, uv, texColor); if(g_sldHalfTone != 0) color.rgb = halftone(color.rgb, uv); if(g_sldSepia != 0) color.rgb = sepia(color.rgb); } }