diff options
| -rw-r--r-- | 2ner.cginc | 13 | ||||
| -rw-r--r-- | 2ner.shader | 11 | ||||
| -rw-r--r-- | features.cginc | 4 | ||||
| -rw-r--r-- | fog.cginc | 48 | ||||
| -rw-r--r-- | globals.cginc | 8 |
5 files changed, 84 insertions, 0 deletions
@@ -9,6 +9,7 @@ #include "face_me.cginc"
#include "false_color_visualization.cginc"
#include "features.cginc"
+#include "fog.cginc"
#include "globals.cginc"
#include "harnack_tracing.cginc"
#include "interpolators.cginc"
@@ -183,6 +184,18 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace i.tangent = UnityObjectToWorldNormal(i.tangent);
i.binormal = UnityObjectToWorldNormal(i.binormal);
+#if defined(_RAYMARCHED_FOG)
+ FogParams fog_params = {
+ _Raymarched_Fog_Steps,
+ _Raymarched_Fog_Density,
+ _Raymarched_Fog_Dithering_Noise,
+ _Raymarched_Fog_Density_Noise,
+ _Raymarched_Fog_Density_Noise_Scale
+ };
+ FogResult fog_result = raymarched_fog(i, fog_params);
+ return fog_result.color;
+#endif
+
#if defined(_SHATTER_WAVE) || defined(_TESSELLATION_HEIGHTMAP)
calcNormalInScreenSpace(i.normal, i.objPos);
#endif
diff --git a/2ner.shader b/2ner.shader index 258db61..439da3b 100644 --- a/2ner.shader +++ b/2ner.shader @@ -816,6 +816,17 @@ Shader "yum_food/2ner" //endex [HideInInspector] m_end_Decals("Decals", Float) = 0 + //ifex _Raymarched_Fog_Enabled==0 + [HideInInspector] m_start_Raymarched_Fog("Raymarched fog", Float) = 0 + [ThryToggle(_RAYMARCHED_FOG)] _Raymarched_Fog_Enabled("Enable", Float) = 0 + _Raymarched_Fog_Steps("Steps", Range(1, 32)) = 32 + _Raymarched_Fog_Density("Density", Float) = 1.0 + _Raymarched_Fog_Dithering_Noise("Dithering noise", 2D) = "black" {} + _Raymarched_Fog_Density_Noise("Density noise", 3D) = "black" {} + _Raymarched_Fog_Density_Noise_Scale("Density noise scale", Vector) = (1, 1, 1, 0) + [HideInInspector] m_end_Raymarched_Fog("Raymarched fog", Float) = 0 + //endex + //ifex _3D_SDF_Enabled==0 [HideInInspector] m_start_3D_SDF("3D SDF", Float) = 0 [ThryToggle(_3D_SDF)] _3D_SDF_Enabled("Enable", Float) = 0 diff --git a/features.cginc b/features.cginc index 5fcdfbf..40ed4a1 100644 --- a/features.cginc +++ b/features.cginc @@ -311,5 +311,9 @@ #pragma shader_feature_local _DEPTH_PREPASS //endex +//ifex _Raymarched_Fog_Enabled==0 +#pragma shader_feature_local _RAYMARCHED_FOG +//endex + #endif // __FEATURES_INC diff --git a/fog.cginc b/fog.cginc new file mode 100644 index 0000000..c0800bc --- /dev/null +++ b/fog.cginc @@ -0,0 +1,48 @@ +#ifndef __FOG_INC +#define __FOG_INC + +#include "cnlohr.cginc" +#include "interpolators.cginc" +#include "globals.cginc" + +#if defined(_RAYMARCHED_FOG) + +struct FogParams { + float steps; + float density; + texture2D dithering_noise; + texture3D density_noise; + float4 density_noise_scale; +}; + +struct FogResult { + float4 color; +}; + +float getRayLengthWorld() +{ + float2 screen_uv; + float perspective_factor; + { + float3 full_vec_eye_to_geometry = i.worldPos - _WorldSpaceCameraPos; + float3 world_dir = normalize(i.worldPos - _WorldSpaceCameraPos); + float perspective_divide = 1.0 / i.pos.w; + perspective_factor = length(full_vec_eye_to_geometry * perspective_divide); + screen_uv = i.screenPos.xy * perspective_divide; + } + float eye_depth_world = + GetLinearZFromZDepth_WorksWithMirrors( + SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, screen_uv), + screen_uv) * perspective_factor; +} + +FogResult raymarched_fog(v2f i, FogParams params) +{ + float3 ro = _WorldSpaceCameraPos; + float3 rd = normalize(i.worldPos - ray_pos); + + +} + +#endif // _RAYMARCHED_FOG +#endif // __FOG_INC diff --git a/globals.cginc b/globals.cginc index 1d9f291..80ba634 100644 --- a/globals.cginc +++ b/globals.cginc @@ -535,4 +535,12 @@ float4 _SSAO_Noise_TexelSize; float _SSAO_Bias;
#endif // _SSAO
+#if defined(_RAYMARCHED_FOG)
+float _Raymarched_Fog_Steps;
+float _Raymarched_Fog_Density;
+texture2D _Raymarched_Fog_Dithering_Noise;
+texture3D _Raymarched_Fog_Density_Noise;
+float4 _Raymarched_Fog_Density_Noise_Scale;
+#endif // _RAYMARCHED_FOG
+
#endif // __GLOBALS_INC
|
