improve water, cleanup
This commit is contained in:
parent
3bbd3d9aaf
commit
93c2d5407c
1 changed files with 15 additions and 12 deletions
|
@ -22,9 +22,9 @@
|
|||
_StarTint ("Star tint", Range(0, 1)) = 0.4
|
||||
[Header(Water)]
|
||||
_WaterCol ("Water color", Color) = (0.03, 0.08, 0.12, 1.0)
|
||||
_WaveStrength ("Wave scale", Range(0, 1)) = 1
|
||||
[NoScaleOffset]
|
||||
_WaterSurface ("Surface Normal", 2D) = "white" {}
|
||||
_Temp ("Wave scale", Range(0, 1)) = 0
|
||||
[Header(Debug)]
|
||||
_Grid ("Grid visibility", Range(0, 1)) = 0
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
|||
|
||||
sampler2D _WaterSurface;
|
||||
fixed4 _WaterCol;
|
||||
float _Temp;
|
||||
float _WaveStrength;
|
||||
|
||||
float _Grid;
|
||||
|
||||
|
@ -93,15 +93,17 @@
|
|||
|
||||
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;
|
||||
float t1 = _Time.x * 0.18;
|
||||
normal += (tex2D(_WaterSurface, pos * 1.04 + float2(t1, t1 * 0.5)) - 0.5);
|
||||
float t2 = _Time.x * 0.37;
|
||||
normal += (tex2D(_WaterSurface, pos * 0.276 + float2(t2 * 0.8, t2)) - 0.5);
|
||||
float t3 = _Time.x * 0.08;
|
||||
normal += (tex2D(_WaterSurface, pos * 0.07 + float2(t3 * 0.8, -t3)) - 0.5);
|
||||
|
||||
return normalize(normal.zxy);
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float water_mod = 0.0;
|
||||
|
||||
|
@ -116,6 +118,7 @@
|
|||
camera_local_pos.z - camera_local_pos.y / (real_dir.y / real_dir.z)
|
||||
);
|
||||
float3 water_normal = get_water_normal(surface_pos.xz);
|
||||
water_normal = lerp(UP, water_normal, _WaveStrength);
|
||||
|
||||
dir = reflect(dir, water_normal);
|
||||
water_mod = dot(dir, water_normal);
|
||||
|
@ -152,10 +155,10 @@
|
|||
float star_size = _StarSize * (rnum * _StarSizeRandom + (1 - _StarSizeRandom));
|
||||
|
||||
float distance = length(pos - star_pos);
|
||||
float star_strength = max(min(star_size/distance*0.5, 1.25)-0.25, 0); // star glow
|
||||
float star_strength = max(min(star_size / distance * 0.5, 1.25) - 0.25, 0); // star glow
|
||||
|
||||
star_strength *= clamp(sin(y*2) - 0.1, 0, 1); // fade stars near/under horizon
|
||||
star_strength *= length(r)/2; // fade stars
|
||||
star_strength *= clamp(sin(y * 2) - 0.1, 0, 1); // fade stars near/under horizon
|
||||
star_strength *= length(r) / 2; // fade stars
|
||||
star_strength *= rnum2 > _StarsMissing; // remove stars
|
||||
|
||||
fixed3 star_col = lerp(1.0, r, _StarTint);
|
||||
|
@ -164,14 +167,14 @@
|
|||
|
||||
|
||||
/// debug grid
|
||||
col = lerp(col, WHITE, _Grid * (frac(cellx) < 0.04 || frac(celly) < 0.04) );
|
||||
col = lerp(col, WHITE, _Grid * (frac(cellx) < 0.04 || frac(celly) < 0.04));
|
||||
|
||||
/// sun
|
||||
float3 sun_dir = float3(sin(_SunAngle), 0.0, cos(_SunAngle));
|
||||
float alignment = min(acos(dot(dir, sun_dir)), 1);
|
||||
// float sun_gradient = pow(y-1, 2) * 0.5 + 0.8;
|
||||
float sun_gradient = 1;
|
||||
float sun_amount = max(min(_SunRadius/alignment * sun_gradient, 5) - _SunCutoff, 0);
|
||||
float sun_amount = max(min(_SunRadius / alignment * sun_gradient, 5) - _SunCutoff, 0);
|
||||
|
||||
col = lerp(col, _SunCol, sun_amount);
|
||||
col = lerp(col, _WaterCol, water_mod);
|
||||
|
|
Loading…
Reference in a new issue