Shader error in ‘Universal Render Pipeline/Lit (Nature Renderer)’: undeclared identifier ‘unity_ObjectToWorld’ at Renderer.templatex(94) (on gles3)
Does anyone know how to fix this. ITs from the Asset Nature Renderer, the templates code below results in errors on build and doesnt render if it does manage to build
void SetupNatureRenderer()
{
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
DecompressInstanceMatrix(unity_ObjectToWorld, _Instances[unity_InstanceID]);
unity_ObjectToWorld = mul(unity_ObjectToWorld, _InstanceMatrix);
unity_WorldToObject = inverse(unity_ObjectToWorld);
// {% hd %}
// Instances are static so the previous matrix is the same as the current one.
// These matrices are required for correct motion vectors in HDRP.
#if SHADERPASS == SHADERPASS_MOTION_VECTORS && defined(SHADERPASS_CS_HLSL)
unity_MatrixPreviousM = unity_ObjectToWorld;
unity_MatrixPreviousMI = unity_WorldToObject;
#endif
// {% endhd %}
#endif
}
“unity_ObjectToWorld” usually is a static uniform shader parameter and can not / should not be changed from inside the shader. So you should never assign a value to it. If you want to calculate an intermediate matrix, use a local variable. Though maybe it does work and it’s overwritten for every invocation.
If that isn’t the problem, you should check if the proper includes are present. The built-in shader variables are usually defined in one of the built-in include files. They are usually automatically included.
Though could also be a cross compile issue of some sorts. I never used the asset you’ve mentioned, so I can’t really help you with that. It’s possible that the replacement of the matrix does actually work. Though you’ve only shown an include file and not where it’s used.
Ok, yes the UnityShaderVaribales has those definition’s. Just Nature renderer has that template include above setting them too.
However. There may be an underlying problem because I removed nature renderer and set that grass prefab to URP Lit shader the standard unity one, and it the same problem, no world to object error/errors at all but the grass doesnt display on mobile but does in editor
Do you know what that could be or where to look or debug for it?