partial transparency

Can someone refresh my memory as to why, when you import a maya object into Unity, parts of it are transparent when they shouldn’t be? I’m using the Alpha/Diffuse shader. The texture has an alpha channel where it should, but parts of the rest of the model are appearing transparent.

I’m pretty sure I don’t have overlapping UV’s and my object is all quads… am I missing something?

Cheers,
Paul

Maybe the alpha of the color of the material is not set to 100%?

Yeah, I thought of that Joachim… but it’s set to 100%…

Cheers,
Paul

Ok, here is something fairly quick that I tried that fails… maybe it is supposed to?

  1. create a white sphere in maya
  2. create a red cube in maya and place inside sphere
  3. texture cube red
  4. texture sphere white by using a tga texture which has a black circle in alpha (i.e the circle will put a hole in it)
  5. export to Unity using fbx (I’m on windows going to mac)
  6. import sphere/cube object
  7. import texture for sphere
  8. assign texture to sphere using Alpha/Diffuse shader

View from all angles and all is well. You can see the red cube inside the sphere when the transparent hole comes into view.

  1. Assign same white texture to cube, and use an Alpha/Diffuse shader as well.

View from all angles and the cube will become entirely visible now and then (even past the hole).

Is this normal behavior?

Cheers,
Paul

Ok, I found a solution to my problem. Originally my model was a number of polygon meshes ‘combined’ in Maya. I then applied a texture (which contains the alpha map for the transparent part) to that new mesh. That’s when I get the funky xray transparency (in both Maya using ‘High Quality Rendering’ in the opengl view and in Unity).

The solution was to separate out the transparent mesh part (windscreen) and apply the texture with the alpha for transparency to that piece alone. Then combine all the other mesh parts into a new mesh and apply the same color texture but this time with no alpha.

This viewed fine in Maya and loads and works as expected in Unity.

It is the same as the problem I mention above with the cube and sphere… use the same texture which contains alpha for both objects and you get weirdness.

Cheers,
Paul

This is a usual issue with partly transparent objects - you don’t get 100% correct depth sorting. The usual trick is to either separate them into fully opaque and transparent parts; or use a shader that does two passes - one for fully opaque parts (100% correct) and then partly transparent parts (not always correct, but at least opaque parts are correct) on top. Similar to VegetationTwoPass shader on the wiki.

Hey Aras, thanks very much for the explanation and for the pointer.

Cheers,
Paul