Unity3D/Shader
Refraction
일등하이
2020. 12. 23. 17:42
반응형
Shader "Custom/Refraction"
{
Properties
{
_MainTex ("Main Tex", 2D) = "white" {}
_RefStrength ("Reflection Strength", Range(0, 0.1)) = 0.05
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent"}
zwrite off
GrabPass {}
CGPROGRAM
#pragma surface surf _NoLight noambient alpha:fade
sampler2D _MainTex;
sampler2D _GrabTexture;
float _RefStrength;
struct Input
{
float4 color:COLOR;
float4 screenPos;
float2 uv_MainTex;
};
void surf (Input i, inout SurfaceOutput o)
{
float4 ref = tex2D(_MainTex, i.uv_MainTex);
float3 screenUV = i.screenPos.rgb / i.screenPos.a;
//o.Emission = float3(screenUV.xy, 0);
o.Emission = tex2D(_GrabTexture, screenUV.xy + ref.x * _RefStrength);
}
float4 Lighting_NoLight (SurfaceOutput s, float3 lightDir, float atten){
return float4(0, 0, 0, 1);
}
ENDCG
}
FallBack "Regacy Shaders/Transparent/Vertexlit"
}
반응형