[F] refraction miss match water albedo
This commit is contained in:
@@ -9,7 +9,7 @@ namespace zz.water.editor
|
||||
[ScriptedImporter(1, FILE_EXTENSION)]
|
||||
public class WaterMeshImporter : ScriptedImporter
|
||||
{
|
||||
private const string FILE_EXTENSION = "watermesh";
|
||||
private const string FILE_EXTENSION = "zwatermesh";
|
||||
|
||||
[SerializeField] public WaterMesh waterMesh = new WaterMesh();
|
||||
|
||||
|
||||
@@ -107,14 +107,14 @@ Material:
|
||||
- _GlossyReflections: 0
|
||||
- _HorizonDistance: 26.6
|
||||
- _InterscetionSpeed: 1
|
||||
- _IntersectionClipping: 0.407
|
||||
- _IntersectionClipping: 0.553
|
||||
- _IntersectionDurationMulti: 1
|
||||
- _IntersectionDurationMulti1: 2.53
|
||||
- _IntersectionDurationMulti2: 0.83
|
||||
- _IntersectionFalloff: 0.73
|
||||
- _IntersectionFalloff: 1
|
||||
- _IntersectionLength: 2.03
|
||||
- _IntersectionSpeed: 0.2
|
||||
- _IntersectionTiling: 0.82
|
||||
- _IntersectionTiling: 1
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
@@ -123,7 +123,7 @@ Material:
|
||||
- _ReflectionBlur: 0.049
|
||||
- _ReflectionFresnel: 4.92
|
||||
- _ReflectionStrength: 1
|
||||
- _RefractionStrength: 0.278
|
||||
- _RefractionStrength: 0.367
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
|
||||
@@ -34,7 +34,7 @@ TextureImporter:
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
filterMode: 2
|
||||
aniso: 3
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
@@ -71,7 +71,7 @@ TextureImporter:
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 9
|
||||
textureFormat: 18
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
|
||||
@@ -20,8 +20,10 @@ void PopulateSceneData(inout SceneData scene, in Varyings input, in WaterSurface
|
||||
scene.viewDepth = 1;
|
||||
scene.verticalDepth = 1;
|
||||
|
||||
float2 refractionOffset = input.normalWS.xz * 0.5 * _RefractionStrength + screenPos;
|
||||
|
||||
//Screen depth Projection to world position
|
||||
SceneDepth depth = SampleDepth(screenPos);
|
||||
SceneDepth depth = SampleDepth(refractionOffset);
|
||||
float3 projWorldPos = depth.eye * (water.viewDelta / input.positionNDC.w) - _WorldSpaceCameraPos;
|
||||
scene.positionWS = -projWorldPos;
|
||||
|
||||
@@ -32,8 +34,8 @@ void PopulateSceneData(inout SceneData scene, in Varyings input, in WaterSurface
|
||||
|
||||
//Distance to opaque geometry in normal direction
|
||||
scene.verticalDepth = length((water.positionWS - scene.positionWS) * water.vertexNormal);
|
||||
scene.color = SampleSceneColor(refractionOffset);
|
||||
|
||||
scene.color = SampleSceneColor(screenPos + input.normalWS.xz * 0.5 * _RefractionStrength);
|
||||
}
|
||||
|
||||
float GetWaterDensity(SceneData scene, float heightScalar, float viewDepthScalar)
|
||||
@@ -76,8 +78,8 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
||||
|
||||
PopulateSceneData(scene, input, water);
|
||||
|
||||
//return float4(scene.verticalDepth.xxx, 0.7);
|
||||
//return float4(scene.viewDepth.xxx, 0.7);
|
||||
//return float4(scene.verticalDepth.xxx, 1);
|
||||
//return float4(scene.viewDepth.xxx, 1);
|
||||
//return float4(scene.color, 1);
|
||||
|
||||
water.fog = GetWaterDensity(scene, _DepthHorizontal, _DepthVertical);
|
||||
@@ -93,8 +95,7 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
||||
water.albedo = lerp(baseColor.rgb, _HorizonColor.rgb, fresnel);
|
||||
|
||||
water.edgeFade = saturate(scene.verticalDepth / (_EdgeFade * 0.01));
|
||||
|
||||
water.alpha *= water.edgeFade;
|
||||
water.alpha *= water.edgeFade;
|
||||
|
||||
|
||||
// Wave Mesure
|
||||
@@ -119,11 +120,12 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
||||
|
||||
float dist = saturate(interSecGradient / _IntersectionFalloff);
|
||||
|
||||
float inersecNoise = saturate(foamTexNoise + intersecMesure) * dist + dist;
|
||||
inersecNoise = smoothstep(_IntersectionClipping, 1, inersecNoise);
|
||||
float intersecNoise = saturate(foamTexNoise + intersecMesure) * dist + dist;
|
||||
intersecNoise = smoothstep(_IntersectionClipping, 1, intersecNoise);
|
||||
|
||||
|
||||
float noise = saturate(inersecNoise + waveFoamNoise);
|
||||
float noise = saturate(intersecNoise + waveFoamNoise);
|
||||
//float noise = intersecNoise;
|
||||
|
||||
water.albedo.rgb = lerp(water.albedo.rgb, _IntersectionColor.rgb, noise);
|
||||
water.alpha = saturate(water.alpha + interSecGradient);
|
||||
@@ -173,7 +175,7 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
||||
|
||||
finalColor = lerp(finalColor, _IntersectionColor.rgb, noise);
|
||||
|
||||
// =================== Make ApplyLight simple =========================
|
||||
// =================== Make ApplyLight simple end =========================
|
||||
|
||||
finalColor = lerp(scene.color, finalColor, water.fog + noise);
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ Shader "zzwater/ocean"
|
||||
//Intersection
|
||||
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
|
||||
_IntersectionTiling("Noise Tiling", float) = 0.2
|
||||
_IntersectionColor("Color", Color) = (1,1,1,1)
|
||||
_IntersectionColor("Foam Color", Color) = (1,1,1,1)
|
||||
_IntersectionSpeed("Intersection Speed Multi", Float) = 1
|
||||
_IntersectionClipping("Cutoff", Range(0.01, 1)) = 0.5
|
||||
_IntersectionFalloff("Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionClipping("Intersection Cutoff", Range(0.01, 1)) = 0.5
|
||||
_IntersectionFalloff("Intersection Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
|
||||
|
||||
// Wave foam
|
||||
@@ -37,8 +37,8 @@ Shader "zzwater/ocean"
|
||||
|
||||
|
||||
//waves
|
||||
_WaveSpeed("Speed", Float) = 2
|
||||
_WaveHeight("Height", Range(0 , 10)) = 0.25
|
||||
_WaveSpeed("Wave Speed", Float) = 2
|
||||
_WaveHeight("Wave Height", Range(0 , 10)) = 0.25
|
||||
|
||||
_WaveNormalStr("Normal Strength", Range(0 , 32)) = 0.5
|
||||
_WaveDistance("Distance", Range(0 , 1)) = 0.8
|
||||
|
||||
@@ -30,10 +30,10 @@ Shader "zzwater/ocean_tess"
|
||||
//Intersection
|
||||
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
|
||||
_IntersectionTiling("Noise Tiling", float) = 0.2
|
||||
_IntersectionColor("Color", Color) = (1,1,1,1)
|
||||
_IntersectionColor("Foam Color", Color) = (1,1,1,1)
|
||||
_IntersectionSpeed("Intersection Speed Multi", Float) = 1
|
||||
_IntersectionClipping("Cutoff", Range(0.01, 1)) = 0.5
|
||||
_IntersectionFalloff("Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionClipping("Intersection Cutoff", Range(0.01, 1)) = 0.5
|
||||
_IntersectionFalloff("Intersection Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
|
||||
|
||||
// Wave foam
|
||||
@@ -43,8 +43,8 @@ Shader "zzwater/ocean_tess"
|
||||
|
||||
|
||||
//waves
|
||||
_WaveSpeed("Speed", Float) = 2
|
||||
_WaveHeight("Height", Range(0 , 10)) = 0.25
|
||||
_WaveSpeed("Wave Speed", Float) = 2
|
||||
_WaveHeight("Wave Height", Range(0 , 10)) = 0.25
|
||||
|
||||
_WaveNormalStr("Normal Strength", Range(0 , 32)) = 0.5
|
||||
_WaveDistance("Distance", Range(0 , 1)) = 0.8
|
||||
|
||||
Reference in New Issue
Block a user