fix: restore DOTS-instanced material props and Unity 6000.5 shader compat - #95
Open
eordano wants to merge 1 commit into
Open
fix: restore DOTS-instanced material props and Unity 6000.5 shader compat#95eordano wants to merge 1 commit into
eordano wants to merge 1 commit into
Conversation
🔗 Merge Alignment ReminderIf this PR targets Both repos should be merged in coordination to avoid breaking changes. Do not merge one without the other being ready. |
eordano
force-pushed
the
fix/unity-6000.5-shader-compat
branch
from
July 20, 2026 19:23
de4cce8 to
5261933
Compare
- DCL_Toon ForwardLit: claim UNIVERSAL_LIT_INPUT_INCLUDED, inline IsSurfaceTypeTransparent (6000.4 URP has no SurfaceType.hlsl). - Toon outline/highlight and CelShading depth-normals: GetObjectToWorldMatrix instead of unity_ObjectToWorld; carry the instance id into the toon outline fragment stage. - Scene URP Lit/Unlit input: UNITY_ACCESS_DOTS_INSTANCED_PROP replaces the removed _FROM_MACRO accessor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
eordano
force-pushed
the
fix/unity-6000.5-shader-compat
branch
from
July 27, 2026 14:37
5261933 to
952a977
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three independent shader fixes, all surfaced by compiling the DOTS-instancing (
*_INSTANCING_ON) variants that editor compiles skip and player builds do not. The first is a live bug onmaintoday, independent of any Unity upgrade.1.
UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACROno longer existsScene/URP/LitInput.hlslandScene/URP/UnlitInput.hlsldefine every instanced material property throughUNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(...). That macro is not defined anywhere in the URP we currently ship — the only references to it in the whole package tree are these two files. Unity removed it when the override-mode system landed; the surviving macro isIt also takes a different argument: the bare property name, composing the metadata symbol itself via
UNITY_DOTS_INSTANCED_METADATA_NAME. So the call sites move from(float4, Metadata__BaseColor)to(float4, _BaseColor)— theMetadata_prefix is dropped, not just the macro renamed.This is why it only shows up in player builds: nothing compiles those defines until
UNITY_DOTS_INSTANCING_ENABLEDis set.Codegen is unchanged. Both predicates compare
static const intvalues, so the ternaries fold at compile time and the emitted code is a singleLoadDOTSInstancedData_##type(metadata)— exactly what the old spelling produced. No extra load, no runtime branch, no register pressure.Why the plain macro and not
_WITH_DEFAULT: the two differ only when the override mode is disabled, where plain yields((type)0)and_WITH_DEFAULTyields the CBUFFER value.UNITY_DOTS_INSTANCED_PROPexpands to..._OVERRIDE_SUPPORTEDunlessUNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED_BY_DEFAULTis defined, and we never define it — soIS_OVERRIDE_ENABLEDis true and the load branch is taken. Plain is correct here.2.
unity_ObjectToWorld->GetObjectToWorldMatrix()Four call sites across
Avatar_CelShading_DepthNormalsPass,DCL_ToonHighlightandDCL_ToonOutline.GetObjectToWorldMatrix()isUNITY_MATRIX_M, which under BRG/DOTS instancing resolves to the instanced matrix instead of the raw builtin. Same matrix load, no added cost — a correctness fix for the instanced variants, where the builtin is not the right source.3.
DCL_ToonOutlineinstance ID plumbingfragalready calledUNITY_SETUP_INSTANCE_ID(i)on aVertexOutputthat never carried an instance ID. AddsUNITY_VERTEX_INPUT_INSTANCE_IDto the struct andUNITY_TRANSFER_INSTANCE_ID(v, o)invert, completing a contract that was already half-written. Cost is one extra interpolator, and only under instancing —UNITY_VERTEX_INPUT_INSTANCE_IDcompiles to nothing otherwise.4. URP 17.5
LitInputcollision (the 6000.5 item)Unity 6000.5's URP added
#include "LitInput.hlsl"toLitForwardPass.hlsl, pullingShaderLibrary/SurfaceInput.hlslinto the one DCL translation unit that includes URP's real LitForwardPass (DCL_Toon ForwardLit) — colliding withDCL_ToonInput.hlsl(_BaseMap,Alpha, UnityPerMaterial members) and rendering avatars magenta.Pre-claims URP's
UNIVERSAL_LIT_INPUT_INCLUDEDguard so the new self-include no-ops (the same guard-reuse pattern this repo already uses inScene/URP/LitInput.hlsl), and inlines the parameterlessIsSurfaceTypeTransparent()that 6000.5's LitForwardPass calls — under the real file's own guard, sinceShaders/Utils/SurfaceType.hlsldoes not exist in 6000.4's URP. With_Surfacedefined0.0fit returns false, matching 6000.4 behaviour exactly.Verification
Both editors, zero errors and zero shader errors:
devon Unity 6000.4.0f1 — editor and macOS player buildExplorer.exeproduced. DCL_Toon ForwardLit, DCL/Scene, and all DOTS-instancing variants compiled clean.