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:
figure1.png (124.54 KiB) Viewed 8990 times
The orange node is my custom "UV-Set Selector" function, which looks like this:
figure2.png (240.24 KiB) Viewed 8990 times
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:
figure3.png (48.64 KiB) Viewed 8990 times
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?
Hello, thank you for getting in touch and for your support!
Are you using the latest ASE version from our website?
If so, can you send us a sample with the issue present as we haven't been able to replicate it on our side?
Regarding your request for a UV Selector, I believe that the workaround you've come up with is the only viable way of achieving what you pretend, as it's not possible to switch UV channels via inspector.