Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

HDRP SOFTPARTICLES_ON appears to be true in some, but not all, shaders

Discussion in 'Graphics Experimental Previews' started by dgoyette, Apr 24, 2019.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    In my project, I'm still using some older 3rd party assets that weren't written with HDRP in mind. Usually not a problem, but I'm seeing some weird behavior.

    There's a shader in some version of Unity's Standard Assets named "Particles/Priority Alpha Blended". Within, I see the following code:

    Code (CSharp):
    1.             fixed4 frag (v2f i) : COLOR
    2.             {
    3.                 #ifdef SOFTPARTICLES_ON
    4.                 float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
    5.                 float partZ = i.projPos.z;
    6.                 float fade = saturate (_InvFade * (sceneZ-partZ));
    7.                 i.color.a *= fade;
    8.                 #endif
    9.                
    10.                 return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
    11.             }

    What I'm finding is that in this shader, `#ifdef SOFTPARTICLES_ON' is true, yet in a shader I've written myself, `#ifdef SOFTPARTICLES_ON' is false. With the SOFTPARTICLES_ON code enabled in this shader, it causes the particles to be rendered in a very weird way, with parts of it missing. If I comment out all of that stuff, it renders properly. However, it doesn't make sense to me why SOFTPARTICLES_ON is true in this shader at all, when it's false in other shaders.

    There are various 3rd party shaders in my project which use SOFTPARTICLES_ON, and all look bad because of it. Is there a way to turn this off globally to ensure it's really off?