Page 1 of 1

Alpha cutout in unlit mode

PostPosted: Thu Nov 29, 2018 9:09 am
by andreas45
Hello,
I was wondering if there is a way to achieve alpha cutout/clip in unlit mode?

Thank you!

Re: Alpha cutout in unlit mode

PostPosted: Thu Nov 29, 2018 12:47 pm
by Ricardo Teixeira
andreas45 wrote:Hello,
I was wondering if there is a way to achieve alpha cutout/clip in unlit mode?

Thank you!


Hello,

What's your shader type?

Thanks!

Re: Alpha cutout in unlit mode

PostPosted: Fri Nov 30, 2018 1:43 am
by andreas45
It's "Unlit".

Thank you!

Re: Alpha cutout in unlit mode

PostPosted: Fri Nov 30, 2018 11:21 am
by Ricardo Teixeira
andreas45 wrote:It's "Unlit".
Thank you!


You'll have to adjust your Rendering Options.

Image

It's quite flexible, be sure to let me know if you have any additional questions.

Thanks!

Re: Alpha cutout in unlit mode

PostPosted: Sat Dec 01, 2018 1:27 am
by andreas45
Hi Ricardo,
Thank you for the reply.
I'm afraid that I don't really understand why your directing me to the blend settings. Alpha clip is a feature that works independently of the blend mode, and in fact, should work quite well with the default blend settings. The render settings, sure, they should be set to "AlphaTest" for efficiency, but again, this is not be required for a working alpha clip shader.

Alpha clip is achieved by selectively calling the "discard" function from inside the pixel shader. For reference (and posterity) I've managed to achieve alpha clip in a "Custom Expression node" using the following code (Note that I'm using the "r" channel to control the clip value. change 0 to 3 to use the actual alpha value for clip):
Code: Select all
if (ColIn[0] < Cutoff) discard; return ColIn;

With the following settings:
Image
And used in the following way (Note that the expression node must me set up inline as shown, or the code will not be compiled into the shader):
Image
This is the result
Image

I could have done this from the start, but figured there might have been a more sensible way to use this feature. If there is not, is there any chance we could get this functionality into the output node of the unlit shader type in a future version?

Thank you!

Re: Alpha cutout in unlit mode

PostPosted: Mon Dec 03, 2018 1:57 pm
by Ricardo Teixeira
My apologies, I was thinking of the HD template. You do indeed need to discard them manually with the Standard Unlit, we actually had a specific node for that but it was a removed a couple of builds ago due to a few recent changes in our template system.

We'll add it in the upcoming update, apologies for the inconvenience.

Thank you for the heads-up!

Re: Alpha cutout in unlit mode

PostPosted: Wed Dec 05, 2018 8:53 pm
by andreas45
Thank you Ricardo!