Page 1 of 1

Can ASE reuse samplers?

PostPosted: Tue Nov 20, 2018 1:36 am
by jake_from_bend
I'm working on a custom Terrain shader, and am hitting the 14 sampler wall.
We're stuffing the textures to the gills. Each texture set is 5 textures packed into 2 RGBA maps (Color, Gloss, Derivative, AO, and Displacement all packed into 8 channels.)

Unity has macros that allow you to reuse samplers, for example: "UNITY_DECLARE_TEX2D_NOSAMPLER()"
So if i hand edit the shader code, I can get past the limit, but at that point, I can no longer use ASE to modify the shader graph.

Is there any workaround? Texture Arrays are a dealbreaker due to the GPU stalls we've encountered on some of the target hardware.

Re: Can ASE reuse samplers?

PostPosted: Tue Nov 20, 2018 12:33 pm
by Amplify_Borba
Hello, you can set your Texture Samplers' Mode to Reference, so it uses a Sampler property from another Texture Sample node instead of creating a new one:

Image

You can also use a Texture Object node connected to different Samplers:

Image

Please let me know if this helps, thanks!

Re: Can ASE reuse samplers?

PostPosted: Tue Nov 20, 2018 7:02 pm
by jake_from_bend
Unless I'm doing something incorrectly, I can't connect the 'reference' sampler to a second texture object.
sharedSampler.JPG
sharedSampler.JPG (63.58 KiB) Viewed 4108 times

Re: Can ASE reuse samplers?

PostPosted: Wed Nov 21, 2018 11:34 am
by Amplify_Borba
Apologies for not being clear enough, the Texture Object can only connect to Texture Samples in Object Mode, since when they are set to Reference they are already using the Sampler property from another Texture Sample node.

Both images I shared above are for two distinct scenarios, in the first one a single Texture Sample is used, and referenced by another, while in the second one a Texture Object is connected to two Texture Samples in Object Mode.

To prevent the needless duplication of textures, you can either use a Texture Object and connect it to several Texture Sample nodes in Object Mode, or use one or more Texture Samples in Reference Mode, pointing to an already existing Texture Sample.

Re: Can ASE reuse samplers?

PostPosted: Tue Nov 27, 2018 2:31 am
by jake_from_bend
Okay, i think i understand both of those scenarios, but i'm not sure that either of them are applicable to what i'm trying to do.

What I'd like to do is reuse the same sampler with multiple textures. Not multiple samplers with the same texture. I think this is where the confusion is.

This is something you can do in Unity's shader code by using their built-in macros (https://docs.unity3d.com/Manual/SL-SamplerStates.html). You can also do this in UE4 by setting the sample type to "shared."

My use case is that i have a landscape shader I've written by hand that blends between 9 layers (x2 textures per layer), a world-space normal-map, and a macro color map. That's 21 textures total, which would be impossible to do in a single pass if each texture used a unique sampler. (I don't want to use an add-pass shader since it effectively renders the terrain twice.)
I technically only need to use 2 samplers, since the macro textures all share UVs as do the detail maps, but to make the shader a little faster on the GPU, i'm using one sampler for each detail layer and one for the macros. (10 total).

This works great, but since it isn't in ASE, I can't hand it off to an artist to maintain, which is the desired goal.

Re: Can ASE reuse samplers?

PostPosted: Tue Nov 27, 2018 11:33 am
by Amplify_Borba
I see, thank you for elaborating!

Unfortunately, this is not something that we support at this time, but I'm going to register this as a request for our developer to consider.

We'll be sure to let you know as soon as we have any developments regarding this matter, please let us know if you have any further questions.

Re: Can ASE reuse samplers?

PostPosted: Tue Nov 27, 2018 7:04 pm
by jake_from_bend
Thanks!
Yeah, that's kinda what i figured. It would be a great addition. I'm positive that feature would make Amplify even more valuable to shader artists.

Re: Can ASE reuse samplers?

PostPosted: Tue Feb 26, 2019 5:19 pm
by Arugin
Any news on this? This feature is super usefull for terrain/planetary shaders. And this is only one that prevents me from transition from Unity shader graph to Amplify.

Re: Can ASE reuse samplers?

PostPosted: Wed Feb 27, 2019 10:03 am
by bitassembler
This feature would be super great. Looking forward to this one too. Currently, you have to do this with tedious texture arrays.

Re: Can ASE reuse samplers?

PostPosted: Thu Feb 28, 2019 3:57 pm
by Amplify_Borba
Hey guys, our developer hasn't been able to tackle this feature just yet, but please rest assured that it is registered and will be considered as soon as it's possible!