Peter77
December 17, 2023, 11:11am
1
I have a Lit Shadergraph that I don’t want to be affected by fog. I don’t want to switch to Unlit because I still need the other lit properties.
In the built-in rendering pipeline, I could add “#pragma nofog”. How can I achieve this in URP and Shadergraph?
I’m currently using Unity 2022.3 with URP Forward+.
Qriva
January 15, 2024, 1:36pm
4
I also want to know that.
I took a quick look at the fog function in URP.
Will undefining FOG_LINEAR FOG_EXP and FOG_EXP2 (when they’re defined) in a custom function node work?
Qriva
January 16, 2024, 11:07am
6
I tried that before, but for some reason it didn’t work, but someone might try it to verify, maybe I did something wrong.
BTW, I think shader graph uses different function, but keywords are the same.
I managed to disable the fog by manually setting the unity_FogParams.xyz to 0. (see documentation )
unity_FogParams = half4(0.0, 0.0, 0.0, 1.0);
Maybe it’s because FOG_LINEAR (as well as the other 2) is a global keyword so we cannot undefine it like a variable?
The custom function can be linked to any fragment block.
Peter77
February 11, 2024, 3:13pm
8
@FredMoreau Can you please add support to toggle Fog to your roadmap
@FredMoreau Can you please add support to toggle Fog to your roadmap
Thanks for the heads up @Peter77 .
This already is on the roadmap here .
Since I’m toying with URP, I’m very frustrated with how limited certain parts of it are. Being unable to simply toggle fog on or off on URP’s shaders out of the box is definitely one of them.
In case you want disable the Fog in a URP Shader Duplicate just remove #pragma multi_compile_fog
This is an excerpt of an URP/Unlit shader
[...]
SubShader
{
Tags
{
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
"UniversalMaterialType" = "Unlit"
"RenderPipeline" = "UniversalPipeline"
}
LOD 100
// -------------------------------------
// Render State Commands
Blend [_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
ZWrite [_ZWrite]
Cull [_Cull]
Pass
{
Name "Unlit"
Fog {Mode Off}
// -------------------------------------
// Render State Commands
AlphaToMask[_AlphaToMask]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex UnlitPassVertex
#pragma fragment UnlitPassFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ALPHAMODULATE_ON
// -------------------------------------
// Unity defined keywords
//#pragma multi_compile_fog <--- REMOVE FOG / FOG OFF
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
[...]
The link is dead. What has been done about it?
Here’s more information about the roadmap.
Hi everyone,
Since 2021, the interactive public Unity Roadmap at Unity Product Roadmaps | Unity has been a place where creators could explore our plans and share feedback. Over time, our products, priorities, and ways of working have evolved, leading to challenges in keeping the displayed information accurate and clear.
To ensure the information we share is always current, easy to navigate, and genuinely useful, we’re retiring the existing interactive roadmap for now.
While we rethink the str…
Legend, this worked for me too. I’ve been trying to find a way all morning.
OMG thank you, this was a lifesaver! I’ve been using the old FOG_LINEAR etc keywords, and then all of a sudden they stopped working! (graphics card update, maybe?)
but everything happily works again with this new solution