Skip to content

🎨 Unity/URP expertise: 15 of 18 shaders not SRP-Batcher compatible (+ WebGL shader error) #573

Description

@marceld23

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clientUnity client / Client.Coreexpertise neededSeeking expert feedback in a comment; no code change requiredhelp wantedExtra attention is neededperformanceRuntime/loading performance work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions