I am looking for a two sided transparent cutout shader compatible with Unity 3. The samples from the Comunity I have found are not for U3 or they don’t work with shadows.
Any idea where can I get it? I don´t mind to pay (reasonably) for it.
Thanks but it is not a good solution for my case.
add cull off to the shader you’re using
e.g.
// Unlit alpha-cutout shader.
// - no lighting
// - no lightmap support
// - no per-material color
Shader "Unlit/Transparent Cutout" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 100
Pass {
[B]__Cull Off__[/B]
Lighting Off
Alphatest Greater [_Cutoff]
SetTexture [_MainTex] { combine texture }
}
}
}
Can you explain your case in more detail? I know of very few situations where doubling geometry is not the best solution.
Daniel is right,
the only time you would want to render backfaces via the shader, rather than modeling them in, is when you would have to render the backfaces in a seperate pass anyway. (to work around sorting issues or concave geometry). Even if your object is transparent you can often force the order of the draw within a mesh by how you construct it in your modeling program.
If you’re working with cloth, for instance, doubling the geometry is not a very good idea. Download the standard shader sources from Unity’s site, locate the one you need, open it in an editor and add “Cull Off” where appropriate (search the forums for the details, as this has been answered many times before). Also rename the shader in the source file. Then import it into your project, select it for use in your material, and you’re ready to go.
You’re forgetting skinned meshes. Thats double the verts to push to the gpu if you double up.
Thanks to everybody.
My case is a single complex model with different materials (one of them the transparent cutout) and doubling the whole geometry is not very convenient.
Hi Angel,
When you say Transparent Cut out did you want it to work like any of surfaces in this screenshot ?
The gold surface is opaque and clips to fully transparent, The Clear surface has varying levels of transparency on only clips at a certain threshold.
PeterB and Hippocoder have some good points
It is possible to just turn of culling, as long as you don’t mind the lighting on the backfaces being the same as the front faces and some shadow receiving issues . Often you don’t notice the lighting artifact If its on cloth. because the back faces lighting as if they were flipped has the same effect as light transfer. ( light passing through thin materials)
I keep forgetting that unity does its skinning on the cpu in which case doubling the verts on skinned mesh like cloth would be a less efficient way of doing things compared to a multipass shader. just depends on whether you want to spend time on skinning or a second draw call.
If you are happy with your surfaces other than the back face issue, let me know which shader you are using and i’ll set up a multi pass version for you.
Kind regards,
Brn
I think my case is very simple. I am using the standard “Transparent/Cutout/Diffuse” shader. I want to be able to “see” the textured back faces of the model but it would be sufficient to cast shadows only from one of them ( front or back faces).
Thanks.
Cloth and large skinned models are good examples of situations where doubling geometry is either not possible or detrimental. I don’t do a whole lot of 3D modelling, but all the programs I have used make it incredibly simple to duplicate and flip the normals of all or a subset of a model’s polygons.
When you say “different materials”, are you referring to multiple submeshes, or is there one mesh whose materials you are switching at runtime? Either way, how does this reduce the viability of duplicating geometry? If I’m sounding doggedly curious, it’s because I don’t understand the rationale behind doing a lot of work in one place in order to avoid the tiniest bit of work in another. If there’s a good reason for doing this, I’d really like to know it. I’ve seen a lot of people take your stance, but–with the exception of skinning and cloth–I haven’t seen any indication that they aren’t just being obstinate.
Maybe you are right, Daniel but I prefer to try the shader mod,the model needs too much tweaks to achieve the desired result because it is a single mesh with several materials applied in different polygons, and I am not a 3D expert preciselly, thanks for your advice anyway.
Another question: I have downloaded the standard shaders sources but in the pack is not included any Transparent shader. The Transparent cutout shader in the Inspector doesn’t allow to be edited, so I don´t know how can I try it…
I have Unity Pro 3.3.
Unfortunately, most of Unity’s shaders have different file names from their shader names. All of the transparent shader files start with “Alpha”.
Hi Angel_m
based on your spec’s above here is a package that will do what you are after. No normal maps spec or anything fancy.
Use the Transparent/Cutout/Diffuse Double sided shader on your material, the other is there just to generate a pass. Make sure both are added to your project. Best of luck.
Kind regards,
brn
Thank you very much.
No problem
Thanks a lot brn—
Hi, thanks again for your shader it seems really really awesome !
I don’t already test it but I want to know just one thing. It can be possible to bake lightmap with it or not ?
The double sided cutout texture works fantastically for this flag I’ve done, thankyou so much! I was wondering if it would be ok to include the shader in a store asset upload? (I’ve got this diner which has a flag on it that uses it)