Is it possible to render DOTS incompatible shaders using hybrid renderer?

Ok so I know it sounds like a dumb question but hear me out…

I often buy assets with custom shaders and most of the time they don’t work with DOTS because the author doesn’t want to deal with updating them to keep up with DOTS changes (fair).
I really wish in these cases that the normal URP pipeline can just take over and render the shader normally.
This method works if the shader lives on a GameObject, so clearly it’s not out of the realm of possibility, i.e. DOTS and normal GameObject stuff can coexist fine.

So is it possible to do this on an Entity?

This is not currently possible. The Hybrid Renderer requires the DOTS_INSTANCING_ON shader keyword to be supported by the shader, as the entire rendering pipeline of Hybrid Renderer relies on it.

If this is a large problem, then depending on the shader, it could be simple to add support yourself:

  • You need a subshader with #pragma target 4.5
  • The subshader needs to use #pragma multi_compile _ DOTS_INSTANCING_ON
  • The shader needs to specify DOTS instanced property definitions for any properties that will be read from entity data, e.g. transform matrices. This is typically done by #including some shared headers.
  • You can look at the example shader in the Hybrid Renderer package for a simple example, or URP/Lit and URP/Unlit for a full fledged example.
1 Like

Thanks for your detailed response!

Is there a way to achieve what I’m after using HybridComponents?
https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/hybrid_component.html
i.e. just have a hidden game object that is rendered instead of using hybrid renderer?

EDIT:
Nevermind, I just saw that that hybrid components are due to be moved to internal for 0.50