Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // RenderDoc compatible
- // No HLSL available - function stub generated
- //SamplerComparisonState sampler0 : register(s0); // can't disambiguate
- SamplerState sampler0 : register(s0); // can't disambiguate
- //SamplerComparisonState sampler1 : register(s1); // can't disambiguate
- SamplerState sampler1 : register(s1); // can't disambiguate
- Texture2D texOutlineMap : register(t0);
- Texture2D texIntensityMap : register(t1);
- cbuffer cbuffer3 : register(b3) {
- float4 cb3_v0;
- };
- struct FSInput
- {
- float4 param0 : SV_Position;
- float4 param1 : COLOR;
- float4 param2 : TEXCOORD;
- };
- struct FSOutput
- {
- float4 param0 : SV_Target0;
- };
- float getParams(float2 uv)
- {
- float d = dot(uv, uv);
- d = 1.0 - d;
- d = max( d, 0.0 );
- return d;
- }
- // For more details see: http://libnoise.sourceforge.net/noisegen/
- float integerNoise( int n )
- {
- n = (n >> 13) ^ n;
- int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
- return ((float)nn / 1073741824.0);
- }
- FSOutput EditedShaderPS(in FSInput IN)
- {
- FSOutput OUT = (FSOutput)0;
- // * Inputs
- float2 uv = IN.param2.xy;
- float dampingParam = saturate( cb3_v0.x );
- float2 noiseAnimation = cb3_v0.zw;
- // * Split texture in four equal parts
- // 0: add r0.xyzw, v2.xyxy, v2.xyxy
- float2 TextureUV = 2 * uv;
- // 1: round_ni r1.xy, r0.zwzz
- float2 flooredTextureUV = floor( TextureUV );
- // 2: frc r0.xyzw, r0.xyzw
- TextureUV = frac( TextureUV );
- // 3-14
- float2 uv1 = flooredTextureUV;
- float2 uv2 = flooredTextureUV + float2(-1.0, -0.0);
- float2 uv3 = flooredTextureUV + float2( -0.0, -1.0);
- float2 uv4 = flooredTextureUV + float2(-1.0, -1.0);
- float4 corners;
- corners.x = getParams( uv1 );
- corners.y = getParams( uv2 );
- corners.z = getParams( uv3 );
- corners.w = getParams( uv4 );
- // 15: sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.zwzz, t1.xyzw, s1
- float4 texIntensity = texIntensityMap.Sample( sampler1, TextureUV );
- float masterFilter = dot(texIntensity, corners);
- // 17: add r2.xyzw, r0.zwzw, l(0.003906, 0.000000, -0.003906, 0.000000)
- // 18: add r0.xyzw, r0.xyzw, l(0.000000, 0.003906, 0.000000, -0.003906)
- // * Generate outlines
- float fTexel = 1.0 / 256;
- float2 sampling1 = TextureUV + float2( fTexel, 0 );
- float2 sampling2 = TextureUV + float2( -fTexel, 0 );
- float2 sampling3 = TextureUV + float2( 0, fTexel );
- float2 sampling4 = TextureUV + float2( 0, -fTexel );
- float2 intensity_x0 = texIntensityMap.Sample( sampler1, sampling1 ).xy;
- float2 intensity_x1 = texIntensityMap.Sample( sampler1, sampling2 ).xy;
- float2 intensity_diff_x = intensity_x0 - intensity_x1;
- float2 intensity_y0 = texIntensityMap.Sample( sampler1, sampling3 ).xy;
- float2 intensity_y1 = texIntensityMap.Sample( sampler1, sampling4 ).xy;
- float2 intensity_diff_y = intensity_y0 - intensity_y1;
- float2 maxAbsDifference = max( abs(intensity_diff_x), abs(intensity_diff_y) );
- maxAbsDifference = saturate(maxAbsDifference);
- // Outlines here
- float2 outlines = masterFilter * maxAbsDifference;
- // Sample outline map
- float2 outlineMap = texOutlineMap.Sample( sampler0, uv ).xy;
- float paramOutline = masterFilter*0.15 + outlineMap.y;
- paramOutline += 0.35 * outlines.r;
- paramOutline += 0.35 * outlines.g;
- // input for integer noise
- float2 noiseInputs = 150*uv + 300.0 * noiseAnimation;
- int2 iNoiseInputs = (int2) noiseInputs;
- // calc noise
- float noise0 = 0.65 + integerNoise( iNoiseInputs.x + reversebits(iNoiseInputs.y) ); // r0.y
- // sampling of outline map
- fTexel = 1.0 / 512.0;
- sampling1 = saturate( uv + float2( fTexel, 0 ) );
- sampling2 = saturate( uv + float2( -fTexel, 0 ) );
- sampling3 = saturate( uv + float2( 0, fTexel ) );
- sampling4 = saturate( uv + float2( 0, -fTexel ) );
- float outline_x0 = texOutlineMap.Sample( sampler0, sampling1 ).x;
- float outline_x1 = texOutlineMap.Sample( sampler0, sampling2 ).x;
- float outline_y0 = texOutlineMap.Sample( sampler0, sampling3 ).x;
- float outline_y1 = texOutlineMap.Sample( sampler0, sampling4 ).x;
- float averageOutline = (outline_x0+outline_x1+outline_y0+outline_y1) / 4.0;
- // * perturb the difference with noise
- float frameOutlineDifference = averageOutline - outlineMap.x;
- frameOutlineDifference *= noise0;
- // 56: mul r0.y, r0.y, r0.z
- // the main place with gives blocky look of texture
- float newNoise = outlineMap.x * noise0;
- float newOutline = frameOutlineDifference * 0.9 + paramOutline;
- newOutline -= 0.24*newNoise;
- // 59: add r0.x, r0.y, r0.z
- float2 finalOutline = float2( outlineMap.x + newOutline, newOutline);
- // * calculate damping
- dampingParam = pow( dampingParam, 100 );
- float damping = 0.7 + 0.16*dampingParam;
- // * final multiplication
- OUT.param0.xy = finalOutline * damping;
- return OUT;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement