Hey, so I just started using Amplify Shader Editor today, and I noticed something conspicuously lacking. There's no way to create a UV set switch property. As in, I need my Material to have a dropdown for which UV set a particular sampler should pull from. I need this to be exposed in the inspector, and I need it to adhere to the tiling/offset of the sampler.
So I did a bit of research, and come up with this solution:
The orange node is my custom "UV-Set Selector" function, which looks like this:
This exposes a nice enum dropdown in my shader where I can choose UV0, UV1, UV2, or UV3. However, when I use this function, the shader does not compile, and Unity presents this error:
Shader error in 'Tesselated 2-Detail': redefinition of 'uv_Diffuse' at line 62 (on d3d11)
The surface shader ends up compiling like this:
As you can see, somewhere in the code generation step for a Texture Coordinates node, it attempts to define a local float2 named "uv" + samplerName. When you have multiple of these nodes connecting to the same Tex input, as I do, they all want to define the exact same local variable. Is there any workaround to this?
I've tried everything I could think of from the node graph, but stopped short of changing how TextureCoordinatesNode works internally. Even if I wanted to go that route, there's problems there. Changing the built-in node itself would mean having to maintain my changes across upgrades of Amplify Shader Editor, and cloning the node would be tricky. The source is 559 lines long with hardcoded GUIDs and references to shader versions. I'm not sure if there a guide to custom nodes somewhere that will explain how best to duplicate a node (what do I need to change in my copy of the node so that it's unique?).
Has anyone encountered this issue? I feel like a UV selector property should already be a built-in node, as it's a very common operation. I'm coming from UBER shader, and all of their shaders have UV set selectors. Even the Standard Unity shader has a UV selector for the secondary maps. Maybe there's a node I should be using?