59 lines
1.7 KiB
HLSL
59 lines
1.7 KiB
HLSL
#ifndef FOG_INCLUDED
|
|
#define FOG_INCLUDED
|
|
|
|
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
|
|
|
|
void Fog_float
|
|
(
|
|
float4 ColorA,
|
|
float4 ColorB,
|
|
float DepthAtten,
|
|
float3 PositionWS,
|
|
float3 PositionOS,
|
|
float3 PivotWS,
|
|
float3 Scale,
|
|
out float3 Output,
|
|
out float Alpha
|
|
)
|
|
{
|
|
// Test
|
|
|
|
//float test = ValueNoise3D(PositionWS, 40);
|
|
//float test = PerlinNoise3D(PositionWS, 40);
|
|
//float test = PerlinNoise3DLOD(PositionWS, 100, 3.5);
|
|
//float test = SimplexNoise3D(PositionWS, 40);
|
|
//float test = WorleyNoise3D(PositionWS, 40, 1);
|
|
//float id;
|
|
//float test = VoronoiNoise3D(PositionWS, 10, 1, .05, id);
|
|
//float test = FBMNoise3D(PositionWS, 10, 2, 2, .5);
|
|
//float test = RidgedNoise3D(PositionWS, 10, 2, 2, .5);
|
|
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);
|
|
|
|
|
|
float3 p = PositionWS;// - PivotWS;
|
|
p += float3(t, t * .2, t);
|
|
|
|
float noise = RidgedNoise3D(p - PivotWS * .9, .1, 5, 1.6, 1);
|
|
|
|
p += noise * 3;
|
|
|
|
float fog = FBMNoise3D((p - PivotWS * .5), 10 / s, 3, 1.5, .5);
|
|
|
|
float4 col = lerp(ColorA, ColorB, saturate(RidgedNoise3D((p - PivotWS * .9) * float3(1, 1.6, 1), 3 / s, 3, 1.6, 1)));
|
|
|
|
float mask = smoothstep(0, lerp(.3, .1, depthAtten), PositionOS.y) * pow(smoothstep(1, .5, PositionOS.y - .15 + noise * .3), 2);
|
|
|
|
// Output
|
|
|
|
Output = col.rgb;
|
|
Alpha = lerp(fog, smoothstep(1, .5, PositionOS.y), depthAtten * mask) * lerp(.2, 1, smoothstep(0, 15, depth)) * mask * col.a;
|
|
}
|
|
|
|
#endif
|