Cutout alpha with transparent output

Hey.

Is there a way to get something rendered with opaque alpha cutout clip but have the final output of it like %20 transparent ? And possibly use multiple passes on the same mesh that has %20 final transparency but with different UVs and stack them all together ?

Sure, you can write a shader that uses clip(tex.a - _Cutout) and Blend at the same time. The question is what exactly are you trying to accomplish, and why multiple passes?

I had an idea I wanted to experiment on as an alternative to transparent shading. I’ve got Shader Forge but it doesn’t allow multiple passes and I’m a noob when it comes to coding shaders. Would you be willing to help me out with the shader ?

Generally when it comes to transparent rendering if you can do something in one pass you should. Multi pass compositing tends to cause unwanted artifacts when not using a zwrite pass which transparency generally does not use. But otherwise sure.

Not in this case. All the passes are using correct Z depth which doesn’t deal with any kind of transparent sorting issues, so all multipass layers will be sorted correctly. I made an example to see how it would look if you stacked the layers with different UVs. It’s just a bunch of planes with a 128x128 cutoff dry lawn texture that’s multisampled 8 times. The result gives you a much smoother and feathery looking plants which have correct depths despite the single alpha cutoff pass instance is very low res and just looks ugly.

So I’m a little confused as to what exactly you’re doing in the second image, and what you want to do that’s different if that already works. By multisampling do you mean just having multiple texture sample nodes in your shader? Because that’s way cheaper than multi pass.

Second image is done in photoshop. As I said, I don’t know a way to multisample renders in Unity. Multisampling your texture won’t work because in the end, it will give you a cutout result per triangle and you won’t have this smooth look, but blending the final results will do the trick.

So how can I take the cutout alpha passes with different UVs and sample them on top of each other with different transparencies ?

Do you know a way I can use “clip(tex.a - _Cutout)” to make that ?

So what you could do is sample the texture then do something like this:

fixed4 tex1 = tex2d(texture, uv + uvoffset1);
tex1.a = saturate((tex1.a - _Cutoff) * 10.0) * _Alpha;

Do that a few times, you can do a lazy add together for a first pass, then use that as the alpha and clip() the alpha straight with out - _Cutoff.

I got no clue how to include that in the shader :frowning: That’s the biggest part I need help with.
Does this do the multipass trick with panned UVs as well or should that be implemented seperately ?

I would suggest reading this:

Then look at this:

See how far you can get with those.

The basic description of how to do what you’re looking to do is to not use any built in alpha test stuff and call clip() yourself, that and you want multiple versions of the same shader over and over as individual passes with a hand set “offset” either applied to the UVs or possibly the vertex positions.

Alternatively you can translate the little snippet of code I gave you into ShaderLab nodes that do the same thing in one pass.

Know that by making it transparent, shadowing will not work properly no matter what technique you use.

Anyone know how to achieve this ?