Platform dependent compilation

Hello,
Is there a way to check which rendering version is being used? Default rednering or LWRP/HDRP?
I write my own shaders for assetstore and want to do uber shader and script for different renderings.

Interested in having this info too. Did you find something?
Thanks

Yes, I find.

You can check the name of rendering

var rpa = GraphicsSettings.renderPipelineAsset;
Debug.Log(rpa.name);
//This would print the name of the used SRP Asset. ie: LWRP-HighQuality, LWRP-LowQuality, LWRP-MediumQuality, HDRenderPipelineAsset

and then you can use define symbols of unity editor (editor → settings → player → other → script define symols

I use it for change my shaders for lwrp/hdrp in runtime.

3971161–340951–RFX4_Unity_Pain.cs (5.73 KB)

1 Like

Many thanks for the info and for the code snippet. I am not a big fan of comparing asset name strings like this:

if (rpa.name.ToUpper().Contains("LWR")) return FX_RenderingType.LWRP

But I don’t see any other ways.

Did you find a way to access the HDRP or LWRP version to know if the user has the version 3.2.0 or 3.3.0 of the package for example? Couldn’t find any variables in the SRP API about it, even if it seems like a very basic info to provide.

You can check the version there
“unity folder\Packages\manifest.json”
or using native unity file “packages->lightweight RP->package.json” (but I don’t know how to read this file using c#"

1 Like

Is there a way to do this instead with Platform Specific includes, so that if it is a line a code that won’t compile if UDP/HDRP is pipeline.
For Example:

#if HDRP_PIPELINE
// Do HDRP stuff
#endif