[D3D9 C++] - Transparent meshes hiding parts of themselves!

Started by
5 comments, last by stakon 13 years, 8 months ago
Good day,

I am using transparent objects for some good time now and i am aware of the practices needed (solids firs, transparents last, front2back rendering, no culling...)

What i didn't realize all this time is that when i create say a cube mesh and set its verts/material to transparent the self transparency of the cube isn't correct!

What i mean is if i rotate my cube some of its inner "back" faces are displayed nicely through the transparent "front" face while others are not!

Why is this happening? Do you have any suggestions to overcome this?

Thanx in advance,

stakon.
Advertisement
In your transparency pass, render the back faces first (cull front faces) and render the front faces after that (cull back faces). If you just disable culling the render order depends on the order of the faces in the mesh (so sometimes it looks correct and sometimes it doesn't).

Also you mention front2back, I assume you meant back-to-front for the transparency pass?
Thanx marco for the reply.

I thought that i cannot render separately the faces within my mesh.
Do you imply sub-setting my mesh and calling the pmesh->DrawSubset(X) in the correct order?
Or are you talking about something else?

btw you are right, i meant back2front.
My solution was as follows:

-> Turn on front face culling
-> Draw cube (this will always draw the inside of the cube)
-> Turn on back face culling
-> Draw cube (this will draw outside of the cube)

However this solution is only suitable for relatively simple shapes such as cubes. If your meshes are more complex you need more advanced solutions to achieve correct transparent rendering. Using simple submeshes and sort them is possible, you can also look into more advanced techniques such as depth peeling.
For more information: NVIDIA website
I just add two thoughts as addition to Marco's second post (not correcting him, just specifying):

- Those two draw commands will be axactly the same, you don't need to sub-set your mesh any special way.

- This simple solution will work also for "complex" meshes as long as they are convex. It won't work properly for concave meshes.
Now the question is how "complex" a convex mesh can be :D
Quote:Original post by Tom KQT
I just add two thoughts as addition to Marco's second post (not correcting him, just specifying):

- Those two draw commands will be axactly the same, you don't need to sub-set your mesh any special way.

- This simple solution will work also for "complex" meshes as long as they are convex. It won't work properly for concave meshes.
Now the question is how "complex" a convex mesh can be :D


Thanks that's exactly what I meant, but clearer ;-)
Thanks to both of you guys!
Your help is much appreciated.

It works very nice as most of my shapes are convex!

Too bad i couldn't think it by myself as now i think it was rather simple. Oh well.

This topic is closed to new replies.

Advertisement