FullScreenPassサンプル
Glitch
https://gyazo.com/3271040273fccb3f547868baa64e1904
code:FullScreenPassGlitch.hlsl
float4 FullScreenPass(Varyings varyings) : SV_Target
{
float depth = LoadCameraDepth(varyings.positionCS.xy);
PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
float3 viewDirection = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
float4 color = float4(0.0, 0.0, 0.0, 0.0);
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING)
color = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1);
// Add your custom pass code here
float2 uv = varyings.positionCS.xy;
float time = _Time.y;
float n = sin(floor(uv.y * 23. + time * 3.)) * sin(floor(uv.y * 17. + time * 39.));
float _Threshold = .05;
float _Intensity = .01;
float4 _OverlayColor = float4(.0,.0,.0,1.);
if (frac(n * 170.) < _Threshold) {
uv.x = frac(uv.x + n * _Intensity);
uv.x = frac(uv.x + n * 3.);
uv.y = frac(uv.x + n * 9.);
uv.x += frac(4.*uv.y + n * 81.);
uv.y *= frac(16.*uv.y + n * 9.);
color = float4(CustomPassSampleCameraColor(uv * posInput.positionNDC.xy, 0), 1);
color += _OverlayColor * _OverlayColor.a;
}
return color;
}
Mosaic
https://gyazo.com/c4cfd9c6ab5e22df0dd53733c0f6e9b6
code:FullScreenPassMosaic.hlsl
float4 FullScreenPass(Varyings varyings) : SV_Target
{
float depth = LoadCameraDepth(varyings.positionCS.xy);
PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
float3 viewDirection = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
float4 color = float4(0.0, 0.0, 0.0, 0.0);
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING)
color = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1);
// Add your custom pass code here
float _Size = 50.;
float2 uv = posInput.positionNDC.xy;
float2 m = posInput.positionSS.xy / min(posInput.positionSS.x, posInput.positionSS.y);
uv = floor(m * _Size * uv) / (m * _Size);
color = float4(CustomPassSampleCameraColor(uv, 0), 1);
return color;
}
RGB Shift
https://gyazo.com/20055df0cf942b3e12d3689e21df5a8a
code:FullScreenRGBShift.hlsl
float4 FullScreenPass(Varyings varyings) : SV_Target
{
float depth = LoadCameraDepth(varyings.positionCS.xy);
PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
float3 viewDirection = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
float4 color = float4(0.0, 0.0, 0.0, 1.0);
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING)
color = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1);
// Add your custom pass code here
float _Shift = 1000.;
float time = 10.*frac(.5*_Time.y)/ _Shift;
float4 outColor = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1);
float4 outColorL = float4(CustomPassSampleCameraColor(float2(time * _Shift, .0)/ _Shift + posInput.positionNDC.xy, 0), 1);
float4 outColorR = float4(CustomPassSampleCameraColor(float2(-time * _Shift, .0) / _Shift + posInput.positionNDC.xy, 0), 1);
color = float4(outColor.r, outColorL.g, outColorR.b, outColor.a);
return color;
}