Hot answers tagged

1

Here's a modified version of the default unlit vertex shader that shows how to break UnityObjectToClipPos into two steps, with a layover in camera view space in between. v2f vert (appdata v) { v2f o; // Ordinarily, we'd go all the way from object space to clip space in one operation: // o.vertex = UnityObjectToClipPos(v.vertex); // But ...


1

vec2 ofs = horizontal ? vec2(offset.x, 0) : vec2(0, offset.y); Simple ternary expressions like this can be compiled to a conditional move instruction, with no branching. So your second version eliminates all overhead that might be needed to support the branch.


1

Ok, this problem apparently occurs because at some point I enabled "GPU Instancing" under the materials "Advanced" options. Material is using the shader "URP/SimpleLit" with its Albedo set to the sprite texture. So if anyone else runs into this kind of lighting problem in their projects "GPU Instancing" might be why ...


Only top voted, non community-wiki answers of a minimum length are eligible