animate water
This commit is contained in:
parent
e70b55ff58
commit
3bbd3d9aaf
1 changed files with 12 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
|||
_StarTint ("Star tint", Range(0, 1)) = 0.4
|
||||
[Header(Water)]
|
||||
_WaterCol ("Water color", Color) = (0.03, 0.08, 0.12, 1.0)
|
||||
[NoScaleOffset]
|
||||
_WaterSurface ("Surface Normal", 2D) = "white" {}
|
||||
_Temp ("Wave scale", Range(0, 1)) = 0
|
||||
[Header(Debug)]
|
||||
|
@ -90,6 +91,16 @@
|
|||
return o;
|
||||
}
|
||||
|
||||
fixed3 get_water_normal(float2 pos) {
|
||||
float3 normal = 0.0;
|
||||
float t1 = _Time.x * 0.2;
|
||||
normal += (tex2D(_WaterSurface, pos * 1.0 + float2(t1, t1*0.5)) - 0.5);
|
||||
float t2 = _Time.x * 0.5;
|
||||
normal += (tex2D(_WaterSurface, pos * 0.2 + float2(t2*0.5, t2)) - 0.5) * 0.25;
|
||||
|
||||
return normalize(normal.zxy);
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float water_mod = 0.0;
|
||||
|
@ -104,7 +115,7 @@
|
|||
0.0,
|
||||
camera_local_pos.z - camera_local_pos.y / (real_dir.y / real_dir.z)
|
||||
);
|
||||
float3 water_normal = normalize((tex2D(_WaterSurface, surface_pos.xz * _Temp) - 0.5).zxy);
|
||||
float3 water_normal = get_water_normal(surface_pos.xz);
|
||||
|
||||
dir = reflect(dir, water_normal);
|
||||
water_mod = dot(dir, water_normal);
|
||||
|
@ -163,13 +174,7 @@
|
|||
float sun_amount = max(min(_SunRadius/alignment * sun_gradient, 5) - _SunCutoff, 0);
|
||||
|
||||
col = lerp(col, _SunCol, sun_amount);
|
||||
|
||||
col = lerp(col, _WaterCol, water_mod);
|
||||
|
||||
// debug, this should not be visible
|
||||
if (dir.y < 0) {
|
||||
return fixed4(1, 0, 0, 1);
|
||||
}
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
|
|
Loading…
Reference in a new issue