Page 1 of 1

Cannot use multiple Texture Coordinates nodes with same Tex

PostPosted: Sun Feb 10, 2019 10:52 pm
by Linear
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
figure1.png (124.54 KiB) Viewed 67806 times


The orange node is my custom "UV-Set Selector" function, which looks like this:

figure2.png
figure2.png (240.24 KiB) Viewed 67806 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
figure3.png (48.64 KiB) Viewed 67806 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?

Re: Cannot use multiple Texture Coordinates nodes with same

PostPosted: Thu Feb 14, 2019 2:25 pm
by Amplify_Borba
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.

Re: Cannot use multiple Texture Coordinates nodes with same

PostPosted: Sun Feb 24, 2019 6:02 pm
by Linear
Hey guys, thanks for the quick response.

I am using release version 1.6.2 from the Asset Store.

I have zipped up the version and I will PM you the sharable link shortly (I've included Amplify Shader Editor v1.6.2 in the zip so I don't want to just post it here).

Re: Cannot use multiple Texture Coordinates nodes with same

PostPosted: Sat Mar 23, 2019 2:25 am
by Linear
Bumping this in case you guys haven't seen my PM yet.

Re: Cannot use multiple Texture Coordinates nodes with same

PostPosted: Tue Mar 26, 2019 7:14 pm
by Amplify_Borba
Hey there, apologies for not reaching out sooner, this issue should already be fixed in the latest version available through our website, please let us know if you come across any further issues, thank you!

Re: Cannot use multiple Texture Coordinates nodes with same

PostPosted: Wed Apr 10, 2019 7:50 pm
by Linear
Gotcha, I'll give it a try. Thanks!