58 lines
1.6 KiB
Plaintext
58 lines
1.6 KiB
Plaintext
Shader "Streamingle/CameraBlend"
|
|
{
|
|
Properties
|
|
{
|
|
_PrevTex ("Previous Camera", 2D) = "white" {}
|
|
_BlendAmount ("Blend Amount", Range(0, 1)) = 0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType" = "Opaque"
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "CameraBlend"
|
|
ZTest Always
|
|
ZWrite Off
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
|
|
|
TEXTURE2D(_PrevTex);
|
|
SAMPLER(sampler_PrevTex);
|
|
|
|
float _BlendAmount;
|
|
|
|
float4 Frag(Varyings input) : SV_Target
|
|
{
|
|
float2 uv = input.texcoord;
|
|
|
|
// 현재 카메라 (Blitter에서 전달됨) - 동일한 샘플러 사용
|
|
float4 currentColor = SAMPLE_TEXTURE2D(_BlitTexture, sampler_LinearClamp, uv);
|
|
|
|
// 이전 카메라 (캡처된 텍스처) - 동일한 Linear 샘플러 사용
|
|
float4 prevColor = SAMPLE_TEXTURE2D(_PrevTex, sampler_LinearClamp, uv);
|
|
|
|
// 리니어 공간에서 블렌딩 (BlendAmount: 1 = 이전, 0 = 현재)
|
|
// 이전 카메라(B)가 위에 덮이고 서서히 사라짐
|
|
float4 finalColor = lerp(currentColor, prevColor, _BlendAmount);
|
|
|
|
return finalColor;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
|
|
FallBack Off
|
|
}
|