Shader "Custom/18-7"
{
Properties
{
_Bumpmap("NormapMap", 2D) = "white" {}
_Cube("Cube", Cube) = ""{}
_SPColor("S Color", color) = (1,1,1,1)
_SPPower("S Power", Range(50,300)) = 150
_SPMulti("S Mulit", Range(1,10)) = 3
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent"}
CGPROGRAM
#pragma surface surf WaterSpecular alpha:fade
sampler2D _Bumpmap;
samplerCUBE _Cube;
float4 _SPColor;
float _SPPower;
float _SPMulti;
struct Input
{
float2 uv_Bumpmap;
float3 worldRefl;
float3 viewDir;
INTERNAL_DATA
};
void surf(Input IN, inout SurfaceOutput o)
{
float3 normal1 = UnpackNormal(tex2D(_Bumpmap, IN.uv_Bumpmap + _Time.x*0.1));
float3 normal2 = UnpackNormal(tex2D(_Bumpmap, IN.uv_Bumpmap - _Time.x*0.15));
o.Normal = (normal1 + normal2) / 2;
float3 refcolor = texCUBE(_Cube, WorldReflectionVector(IN, o.Normal).rgb);
// rim term
float rim = saturate(dot(o.Normal, IN.viewDir));
rim = pow(1 - rim, 3);
o.Emission = refcolor * rim * 2;
o.Alpha = saturate(rim + 0.5);
}
float4 LightingWaterSpecular(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
{
float3 H = normalize(lightDir + viewDir);
float spec = saturate(dot(H, s.Normal));
spec = pow(spec, _SPPower);
float4 finalColor;
finalColor.rgb = spec * _SPColor.rgb*_SPMulti;
finalColor.a = s.Alpha + spec;
return finalColor;
}
ENDCG
}
FallBack "Diffuse"
}
'Shader > Shader - SurfaceShader' 카테고리의 다른 글
18-8 물 버텍스 이동 (0) | 2020.04.30 |
---|---|
18-6 외곡 (0) | 2020.04.23 |
18-4 풀흔들기 (0) | 2020.04.22 |
18-3타들어가는 (0) | 2020.04.15 |
18-2 (0) | 2020.04.15 |