What this is
Seeking Unity/URP shader expertise β either as review comments or as small PRs. Two related asks, both in client/Assets/ (URP 17.4, Unity 6000.4).
Ask 1 β SRP Batcher: enabled, but 15 of 18 custom shaders are not compatible
The SRP Batcher is on in the URP asset, but a scan of all 18 custom shaders shows only 3 (Cloud, Starfield, SunGlow) declare their material properties inside a CBUFFER_START(UnityPerMaterial) block. The other 15 declare them bare, e.g. LitColor.shader:
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
float4 _MainTex_ST;
float4 _Color; // β outside any cbuffer β SRP Batcher: not compatible
Not compatible: BlockAtlas, BlockAtlasTransparent, LitColor, ScatterLit, Atmosphere, Aurora, HeatHaze, Nebula, Particle, ParticleAlpha, SkyBodyPhase, SunRays, VertexColorOpaque, Visor, VisorGlass.
LitColor is the real prize β it shades avatars, held items, doors, ship previews and structure models across many distinct materials, exactly the many-SetPass case the batcher exists for. Terrain chunks share one material, so gains there are smaller.
The fix looks mechanical (wrap properties in CBUFFER_START(UnityPerMaterial) β¦ CBUFFER_END) and is verifiable in seconds via the Material Inspector's "SRP Batcher: compatible" line. Ways to help:
- Sanity-check the diagnosis β is there a reason not to do this we're missing?
- Convert shaders in small per-shader PRs (spike suggestion:
LitColor first)
- Advise on the follow-up: GPU Resident Drawer / GPU occlusion culling requires DOTS-instancing-compatible shaders β is that worth the extra step for a streamed voxel world?
Ask 2 β WebGL build logs ERROR: Shader on startup
The browser build prints a shader error at startup that the desktop build doesn't. Anyone with URP + WebGL shader-stripping war stories: pointers on how to corner this are very welcome.
β οΈ One repo gotcha
Several shaders are loaded via Shader.Find() and are only alive because they're listed in Always-Included Shaders β keep that list intact when touching shader files.
What this is
Seeking Unity/URP shader expertise β either as review comments or as small PRs. Two related asks, both in
client/Assets/(URP 17.4, Unity 6000.4).Ask 1 β SRP Batcher: enabled, but 15 of 18 custom shaders are not compatible
The SRP Batcher is on in the URP asset, but a scan of all 18 custom shaders shows only 3 (
Cloud,Starfield,SunGlow) declare their material properties inside aCBUFFER_START(UnityPerMaterial)block. The other 15 declare them bare, e.g.LitColor.shader:Not compatible:
BlockAtlas,BlockAtlasTransparent,LitColor,ScatterLit,Atmosphere,Aurora,HeatHaze,Nebula,Particle,ParticleAlpha,SkyBodyPhase,SunRays,VertexColorOpaque,Visor,VisorGlass.LitColoris the real prize β it shades avatars, held items, doors, ship previews and structure models across many distinct materials, exactly the many-SetPass case the batcher exists for. Terrain chunks share one material, so gains there are smaller.The fix looks mechanical (wrap properties in
CBUFFER_START(UnityPerMaterial) β¦ CBUFFER_END) and is verifiable in seconds via the Material Inspector's "SRP Batcher: compatible" line. Ways to help:LitColorfirst)Ask 2 β WebGL build logs
ERROR: Shaderon startupThe browser build prints a shader error at startup that the desktop build doesn't. Anyone with URP + WebGL shader-stripping war stories: pointers on how to corner this are very welcome.
Several shaders are loaded via
Shader.Find()and are only alive because they're listed in Always-Included Shaders β keep that list intact when touching shader files.