Diffuse Warping
Unity3D/Shader 2020. 12. 21. 18:11반응형
Shader "Custom/Warp"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RampTex ("Ram Tex", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf _Warp
sampler2D _MainTex;
sampler2D _RampTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
float4 Lighting_Warp(SurfaceOutput s, float3 lightDir, float atten){
float ndotl = dot(s.Normal, lightDir) * 0.5 + 0.5;
float4 ramp = tex2D(_RampTex, float2(ndotl, 0.5));
return fixed4(s.Albedo.rgb * ramp.rgb, 1);
}
ENDCG
}
FallBack "Diffuse"
}
반응형
'Unity3D > Shader' 카테고리의 다른 글
흔들리는 풀 (0) | 2020.12.23 |
---|---|
Unity Unlit Shader (vertex & fragment shader) (0) | 2020.12.22 |
끊어지는 음영 (0) | 2020.12.21 |
Vertex Shader (0) | 2020.12.21 |
Introduction to Shaders in Unity (0) | 2020.06.16 |