- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359

- 纳金币
- 335582
- 精华
- 0
|
先看效果:
![]()
![]()
Shader "Aubergine/Fake Transcluency" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_MatThickness ("Material Thickness", Range(0.1,1.0)) = 0.5
_Coeff ("Extinction", Vector) = (0,0,0,0)
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Transcluent
sampler2D _MainTex;
float _MatThickness;
float4 _Coeff;
half4 LightingTranscluent (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
float halfLambert = (dot(lightDir, s.Normal) * 0.5 + 0.5);
float4 dotLN = float4(halfLambert * atten * 2);
dotLN *= float4(s.Albedo, 1.0);
float3 indirectLight = float3(_MatThickness * max(0.0, dot(-s.Normal, lightDir)));
indirectLight += _MatThickness * (dot(-viewDir, lightDir) * 0.5 + 0.5);
indirectLight *= atten;
indirectLight.x *= _Coeff.x;
indirectLight.y *= _Coeff.y;
indirectLight.z *= _Coeff.z;
float3 rim = float3(1.0 - max(0.0, dot(s.Normal, viewDir)));
rim *= rim;
rim *= max(0.0, dot(s.Normal, lightDir));
half4 c = dotLN + half4(indirectLight, s.Alpha);
c += (float4(rim * atten * c.a, c.a));
return c;
}
s***ct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
Fallback "Diffuse"
} |
|