wip : fog sam

This commit is contained in:
Ferlat Thibaud
2026-06-15 16:41:00 +02:00
parent 3d3b6f59b4
commit 1681dd47dd
17 changed files with 6289 additions and 104 deletions
@@ -1,46 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: M_Fog_Samyaza Variant
m_Shader: {fileID: -6465566751694194690, guid: 0f1522c6af8cc4d47a4bbc5401f58523, type: 3}
m_Parent: {fileID: 2100000, guid: 41ae4584339083a4bba3b73730fb8511, type: 2}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats: []
m_Colors:
- _ColorA: {r: 0.5471698, g: 0.51489913, b: 0.503293, a: 1}
- _ColorB: {r: 0.24528301, g: 0.23251057, b: 0.22792807, a: 0}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &8469725941214613752
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10
@@ -21,7 +21,7 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: M_Fog_Samyaza
m_Shader: {fileID: -6465566751694194690, guid: 0f1522c6af8cc4d47a4bbc5401f58523, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: f3b7830e1c125a64197abbc99ec50eb5, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
@@ -52,12 +52,20 @@ Material:
m_Ints: []
m_Floats:
- _DepthAtten: 1
- _GrainAmount: 0.05
- _IntersectionAtten: 10
- _MaskID: 0
- _PaintSteps: 5
- _QueueControl: 0
- _QueueOffset: 0
- _SpikeAmount: 2
- _SpikeScale: 3
- _SpikeSpeed: -2
- _SpikeTilt: 50
m_Colors:
- _ColorA: {r: 0.62352943, g: 0.49019608, b: 0.5686275, a: 1}
- _ColorB: {r: 0.2784314, g: 0.19215687, b: 0.2509804, a: 1}
- _ColorA: {r: 0.8301887, g: 0.105731584, b: 0.105731584, a: 1}
- _ColorB: {r: 0, g: 0, b: 0, a: 1}
- _ColorC: {r: 0.16037738, g: 0.01891244, b: 0.018912425, a: 1}
- _ColorD: {r: 0.21698111, g: 0.023540407, b: 0.1502774, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
@@ -0,0 +1,142 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6157597664910182110
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: M_Fog_Scarecrow
m_Shader: {fileID: -6465566751694194690, guid: 0f1522c6af8cc4d47a4bbc5401f58523, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
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}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DepthAtten: 1
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _IntersectionAtten: 10
- _MaskID: 2
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueControl: 0
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorA: {r: 0.91243285, g: 0.85377645, b: 0.83422434, a: 0.43137255}
- _ColorB: {r: 0.6603774, g: 0.60306513, b: 0.5825027, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: dd3a57d041903434abcf87e60fbdf73e
guid: 117e9e9e3329f314aaaf2742287b0591
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1497f602ae30b5f44a4744a251d0f9e1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,119 @@
#ifndef FOG_INCLUDED
#define FOG_INCLUDED
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
void Fog_float
(
float4 ColorA,
float4 ColorB,
float4 ColorC,
float4 ColorD,
float DepthAtten,
float3 PositionWS,
float3 PositionOS,
float3 PivotWS,
float3 Scale,
float SpikeAmount,
float SpikeScale,
float SpikeTilt,
float SpikeSpeed,
float PaintSteps,
float GrainAmount,
out float3 Output,
out float Alpha
)
{
float3 camPos = _WorldSpaceCameraPos.xyz;
float depth = distance(camPos, PositionWS);
float depthAtten = lerp(1, smoothstep(5, 30, depth), DepthAtten);
float t = _Time.y * .7;
float s = lerp(Scale.x, 1, .3);
// Base sampling position, scrolling over time
float3 p = PositionWS;
p += float3(t, t * .2, t);
// Domain warp for organic fog shapes
float noise = RidgedNoise3D(p - PivotWS * .9, .1, 5, 1.6, 1);
p += noise * 3;
// Base fog density
float fog = saturate(FBMNoise3D((p - PivotWS * .5), 10 / s, 3, 1.5, .5));
// --- Painterly grain ---
float grain = FBMNoise3D(PositionWS * 25, 4, 2, 2, .5);
grain = grain * 2 - 1;
// --- Color bands ---
float colorMask = saturate(RidgedNoise3D((p - PivotWS * .9) * float3(1, 1.6, 1), 3 / s, 3, 1.6, 1));
float paintMask = saturate(colorMask + grain * 0.03);
paintMask = floor(paintMask * PaintSteps) / max(PaintSteps - 1, 1);
float4 col = lerp(ColorA, ColorB, smoothstep(0.0, 0.4, paintMask));
col = lerp(col, ColorC, smoothstep(0.35, 0.65, paintMask));
col = lerp(col, ColorD, smoothstep(0.6, 1.0, paintMask));
float luma = dot(col.rgb, float3(0.299, 0.587, 0.114));
col.rgb = lerp(col.rgb, luma.xxx, 0.15);
col.rgb *= (1 + grain * GrainAmount);
// --- Ground glow ---
float height01 = saturate(PositionOS.y / 0.3);
float groundMask = pow(1 - height01, 2);
// --- Reference vector from pivot ---
float2 radial = PositionWS.xz - PivotWS.xz;
// Smooth left/right factor, zero exactly at the front/back seams of the circle
float sideSign = clamp(radial.x / (Scale.x * 0.3 + 0.001), -1, 1);
// Tangential direction (= "around the circle")
float2 tangentDir = normalize(float2(-radial.y, radial.x));
// --- Spikes: lean + drift tangentially, direction flips per side ---
float2 spikeXZ = radial + tangentDir * (SpikeTilt * height01 * sideSign);
// Tangential animation, same sign as the lean -> each half rotates outward, opposite directions
spikeXZ += tangentDir * (t * SpikeSpeed * sideSign);
// Horizontal-only animation, drifting outward (same direction as the tilt)
spikeXZ.y -= t * SpikeSpeed * sideSign;
// Low frequency field defines the spike's overall height/silhouette
// (low freq -> the lean doesn't break the shape into zigzags)
float spikeField = saturate(FBMNoise3D(float3(spikeXZ.x, spikeXZ.y, 0), SpikeScale * 0.3, 3, 2, .5));
spikeField = pow(spikeField, 4) * SpikeAmount;
spikeField = min(spikeField, 0.7); // never reaches the sky
// High frequency detail -> subtle jagged/organic edges only
float edgeWarp = RidgedNoise3D(float3(spikeXZ * 4, t * 0.1), .1, 3, 2, .5);
float veins = RidgedNoise3D(float3(spikeXZ * 12, t * 0.05), .1, 4, 2.2, .6);
spikeField *= lerp(0.75, 1.0, veins);
float spikeMask = smoothstep(spikeField, spikeField - 0.04, height01 + edgeWarp * 0.02);
// --- Tall organic bars reaching toward the sky ---
float2 barXZ = radial + float2(SpikeTilt * 0.3 * height01 * sideSign, 0);
float phase = FBMNoise3D(float3(radial * 0.2, t * 0.02), 1, 2, 2, .5) * 6.2831;
float wobble = sin(height01 * 6.2831 * 1.5 + phase) * 2.5 * height01;
barXZ.x += wobble;
float barField = saturate(FBMNoise3D(float3(barXZ * 0.4, t * 0.02), 1, 3, 2, .5));
barField = saturate(pow(barField, 3) * 1.1);
float barMask = smoothstep(barField, barField - 0.2, height01);
// --- Combine ---
float combinedMask = saturate(max(groundMask, max(spikeMask, barMask)));
// Spikes read as red glowing veins; bars keep the painted color bands
col.rgb = lerp(col.rgb, ColorA.rgb, spikeMask);
// --- Final output ---
Output = saturate(col.rgb);
Alpha = saturate(fog * combinedMask * lerp(.2, 1, smoothstep(0, 15, depth)) * col.a);
}
#endif
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 956a41cfb184e464b891b730b51c4424
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f3b7830e1c125a64197abbc99ec50eb5
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
useAsTemplate: 0
exposeTemplateAsShader: 0
template:
name:
category:
description:
icon: {instanceID: 0}
thumbnail: {instanceID: 0}