- Home /
Alpha Textures
So I made a piece of Glass in Cinema 4D and applied in Alpha Texture on it, then imported it to Unity via .fbx The glass still has its texture to it, but instead of where it should be transparent it's black. (I didn't use an Alpha Texutre in C4D, I used the same texture but as an alpha)
I'm going to assume the default one as I never applied any, I'm not very experienced with Unity.
In that case, I know what your problem is. I'll write it up as an answer.
Answer by Hoeloe · Sep 06, 2013 at 11:20 AM
If you haven't set a shader for your glass material, then it will be using the Diffuse
shader. This is a simple shader for un-detailed, matte objects. The problem is that it uses a feature all modern graphics cards have called the "z-buffer". Basically, working out which objects are in front of other objects is actually quite difficult. The z-buffer solves this problem by having what is essentially a copy of what you are rendering, but instead of rendering colours, it writes in the depth of the current pixel. If it comes to a pixel, and finds there is a pixel already written there, then it will ignore it if the existing pixel is in front of the new one. This means that there is per-pixel sorting of objects, which is fast and looks correct. The issue comes when you introduce any object that is transparent. If you tried to use the z-buffer on a transparent object, chances are things would mess up. For example, if the renderer drew a plane of glass, then tried to draw whatever is behind it, it would find the glass already drawn into the z-buffer. However, it can't tell that the object drawn there is transparent, so it ignores the background. The result of this is that the objects behind the glass are never drawn, and you end up with a transparent object that acts to cut out all the objects behind it. Obviously, this is not what you want. Unity resolves this issue by not allowing standard, z-buffer shaders to be use transparency. You can write your own shaders to do this, but I doubt that's what you want.
So, what you need to do is use a different shader! There actually exist some transparent shaders built into Unity (if you open your material, there is a dropdown box that has "Diffuse" written in it, you can change the shader from there). For glass, you probably want Transparent/Specular. This will allow you to see through the object (and specular means it will also have a shine to it). There are downsides to this, though. These shaders are not written into the z-buffer. Instead, they are all sorted based on the centre point of the object. This is usually absolutely fine, as long as the objects aren't large. Large object can produce sorting errors, as the centre point becomes a less accurate approximation to the actual depth of the object. You only get per-object sorting with transparent objects, rather than per-pixel. There are ways around this, but ultimately no solution is perfect. Transparency is a difficult problem in rendering, and one you have to be very careful with.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to Make a Character Flicker? 1 Answer
Avatar T-Shirt Color With Print 3 Answers
Alpha Transparency Shader Issue 1 Answer
normal map, mask different areas? 0 Answers