[A] Edge foam

This commit is contained in:
2024-07-22 13:46:54 +08:00
parent 3758ba0a99
commit c75c054ec3
12 changed files with 277 additions and 11 deletions

View File

@@ -1259,7 +1259,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1753403296}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 24, y: -2.68, z: 56}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0

View File

@@ -47,6 +47,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IntersectionNoise:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
@@ -102,6 +106,13 @@ Material:
- _Glossiness: 0
- _GlossyReflections: 0
- _HorizonDistance: 26.6
- _IntersectionClipping: 0.5
- _IntersectionDurationMulti1: 0.5
- _IntersectionDurationMulti2: 0.5
- _IntersectionFalloff: 0.525
- _IntersectionLength: 2
- _IntersectionSpeed: 1
- _IntersectionTiling: 0.2
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005

View File

@@ -47,6 +47,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _IntersectionNoise:
m_Texture: {fileID: 2800000, guid: 6e4f6abf9612841adaf37e0d026dd5a4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
@@ -90,7 +94,7 @@ Material:
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DepthHorizontal: 2.36
- _DepthHorizontal: 1.78
- _DepthVertical: 7.44
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
@@ -102,6 +106,15 @@ Material:
- _Glossiness: 0
- _GlossyReflections: 0
- _HorizonDistance: 26.6
- _InterscetionSpeed: 1
- _IntersectionClipping: 0.717
- _IntersectionDurationMulti: 1
- _IntersectionDurationMulti1: 3.45
- _IntersectionDurationMulti2: 1.45
- _IntersectionFalloff: 0.368
- _IntersectionLength: 1.43
- _IntersectionSpeed: -0.21
- _IntersectionTiling: 1.27
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
@@ -109,7 +122,7 @@ Material:
- _ReceiveShadows: 1
- _ReflectionBlur: 0.049
- _ReflectionFresnel: 4.92
- _ReflectionStrength: 0.913
- _ReflectionStrength: 1
- _RefractionStrength: 0.278
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
@@ -125,7 +138,7 @@ Material:
- _TranslucencyExp: 10
- _TranslucencyReflectionMask: 0.764
- _TranslucencyStrength: 0.7
- _TranslucencyStrengthDirect: 0.421
- _TranslucencyStrengthDirect: 0.443
- _WaveCount: 3
- _WaveDistance: 0.764
- _WaveHeight: 0.17
@@ -135,12 +148,13 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.1254902, g: 0.2901961, b: 0.34509805, a: 0.9490196}
- _BaseColor: {r: 0.01619794, g: 0.20062576, b: 0.26415092, a: 0.9490196}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Direction: {r: 1, g: 1, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _HorizonColor: {r: 0.09376113, g: 0.10980392, b: 0.32156864, a: 1}
- _ShallowColor: {r: 0.105882354, g: 0.4117647, b: 0.62352943, a: 0.9019608}
- _IntersectionColor: {r: 1, g: 1, b: 1, a: 1}
- _ShallowColor: {r: 0.105882354, g: 0.4117647, b: 0.62352943, a: 0.9372549}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- _WaveDirection: {r: 1, g: 1, b: 1, a: 2}
- _WaveFadeDistance: {r: 0, g: 200, b: 0, a: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a0a3403eb805d4102b2cc105ade1985f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 KiB

View File

@@ -0,0 +1,153 @@
fileFormatVersion: 2
guid: 6e4f6abf9612841adaf37e0d026dd5a4
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 0
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 9
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -30,6 +30,7 @@ struct WaterSurface
float alpha;
float fog;
float edgeFade;
float intersection;
float3 reflections;
float reflectionMask;

View File

@@ -96,6 +96,30 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
water.alpha *= water.edgeFade;
/* ========
// Intercection
=========== */
float interSecGradient = 1-saturate(exp(scene.verticalDepth) / _IntersectionLength);
float sine1 = sin(_TimeParameters.x * _IntersectionDurationMulti1 - interSecGradient );
float sine2 = sin(_TimeParameters.x * _IntersectionDurationMulti2 - interSecGradient );
float sine = sine1 * sine2 * interSecGradient;
float2 nUV = positionWS.xz * _IntersectionTiling;
float dist = saturate(interSecGradient / _IntersectionFalloff);
float noise = SAMPLE_TEXTURE2D(_IntersectionNoise, sampler_IntersectionNoise, nUV + TIME_VERTEX/_IntersectionTiling * _IntersectionSpeed).r;
noise = saturate(noise + sine) * dist + dist;
//noise = smoothstep(_IntersectionClipping, 1, noise);
noise = step(_IntersectionClipping, noise);
//water.albedo.rgb = lerp(water.albedo.rgb, _IntersectionColor.rgb, noise);
water.alpha = saturate(water.alpha + interSecGradient);
//water.intersection = SampleIntersection(positionWS, interSecGradient, TIME * _IntersectionSpeed) * _IntersectionColor.a;
/* ========
// Reflection Prob
=========== */
@@ -136,9 +160,12 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
float3 finalColor = (water.albedo * diffuseColor) + emission + specular;
finalColor = lerp(finalColor, _IntersectionColor.rgb, noise);
// =================== Make ApplyLight simple =========================
finalColor = lerp(scene.color, finalColor, water.fog);
finalColor = lerp(scene.color, finalColor, water.fog + interSecGradient);
finalColor = lerp(scene.color, finalColor, 1);
return float4(finalColor, water.alpha);
}

View File

@@ -1,4 +1,8 @@
TEXTURE2D(_IntersectionNoise);
SAMPLER(sampler_IntersectionNoise);
CBUFFER_START(UnityPerMaterial)
float2 _Direction;
@@ -21,12 +25,23 @@ CBUFFER_START(UnityPerMaterial)
half _TranslucencyStrengthDirect;
//Reflection + Refraction
float _ReflectionBlur;
float _ReflectionFresnel;
float _ReflectionStrength;
float _RefractionStrength;
//Intercection
float4 _IntersectionColor;
float _IntersectionLength;
half _IntersectionTiling;
half _IntersectionSpeed;
half _IntersectionClipping;
half _IntersectionFalloff;
half _IntersectionDurationMulti1;
half _IntersectionDurationMulti2;
//Waves
float _WaveSpeed;

View File

@@ -13,15 +13,25 @@ Shader "zzwater/ocean"
_DepthVertical("View Depth", Range(0.01 , 16)) = 4
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
_EdgeFade("Edge Fade", Float) = 0.1
_TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05
//Reflection + Refraction
_ReflectionStrength("Reflection Strength", Range(0, 1)) = 1
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
_ReflectionFresnel("Reflection Curvature mask", Range(0.01, 20)) = 5
_RefractionStrength("Refraction Strength", Range(0, 1)) = 0.1
//Intersection
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
_IntersectionTiling("Noise Tiling", float) = 0.2
_IntersectionColor("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
_IntersectionDurationMulti1("Intersection Duration Multi 1", Range(0.01, 10)) = 0.5
_IntersectionDurationMulti2("Intersection Duration Multi 2", Range(0.01, 10)) = 0.5
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
//waves
_WaveSpeed("Speed", Float) = 2

View File

@@ -18,15 +18,26 @@ Shader "zzwater/ocean_tess"
_DepthVertical("View Depth", Range(0.01 , 16)) = 4
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
_EdgeFade("Edge Fade", Float) = 0.1
_TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05
//Reflection + Refraction
_ReflectionStrength("Reflection Strength", Range(0, 1)) = 1
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
_ReflectionFresnel("Reflection Curvature mask", Range(0.01, 20)) = 5
_RefractionStrength("Refraction Strength", Range(0, 1)) = 0.1
//Intersection
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
_IntersectionTiling("Noise Tiling", float) = 0.2
_IntersectionColor("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
_IntersectionDurationMulti1("Intersection Duration Multi 1", Range(0.01, 10)) = 0.5
_IntersectionDurationMulti2("Intersection Duration Multi 2", Range(0.01, 10)) = 0.5
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
//waves
_WaveSpeed("Speed", Float) = 2

View File

@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 53
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60
m_DefaultFrameRate: 60