water
Unity3D/Shader 2020. 12. 23. 18:10반응형
Shader "Custom/Water"
{
Properties
{
_BumpMap ("Normal Map", 2D) = "white" {}
_Cube ("Cube", Cube) = ""{}
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
CGPROGRAM
#pragma surface surf Lambert alpha:premul
sampler2D _BumpMap;
samplerCUBE _Cube;
struct Input
{
float2 uv_BumpMap;
float3 worldRefl;
float3 viewDir;
INTERNAL_DATA
};
void surf (Input i, inout SurfaceOutput o)
{
float3 normal1 = UnpackNormal(tex2D (_BumpMap, i.uv_BumpMap + _Time.x * 0.1));
float3 normal2 = UnpackNormal(tex2D (_BumpMap, i.uv_BumpMap - _Time.x * 0.1));
o.Normal = (normal1 + normal2)/2;
float3 refColor = texCUBE(_Cube, WorldReflectionVector(i, o.Normal));
float rim = saturate(dot(o.Normal, i.viewDir));
rim = pow(1-rim, 1.5);
o.Emission = refColor * rim * 2;
//o.Emission = refColor;
//o.Alpha = 0.2;
o.Alpha = saturate(rim +0.5);
}
ENDCG
}
FallBack "Lagacy Shaders/Transparent/VertexLit"
}
반응형
'Unity3D > Shader' 카테고리의 다른 글
URP Shader Training #1-1 (0) | 2021.07.27 |
---|---|
Dev Weeks: URP 셰이더 뜯어보기 (0) | 2021.07.27 |
Refraction (0) | 2020.12.23 |
Matcap (0) | 2020.12.23 |
흔들리는 풀 (0) | 2020.12.23 |