Skip to main content
gamedev.net
🔒 Locked

Transparent Objects Rendering

Started by Simplicity 1 reply 700+ views
Original Post
Simplicity
Simplicity
As in many texts, transparent objects should always be rendered back to front relative to the camera. Consider the following case, however. Let's say we have a large sphere s1 with radius 10 and position (0,0, -10) and a smaller sphere with radius 4 and position (0, 0, -8). Thus, the smaller sphere is inside the larger one. These two spheres have a certain level of transparency in that they are not fully opaque or transparent. Let's mount the camera at (0, 0, 5) looking toward (0, 0, -1). To the camera, the larger sphere's center is further away, so based on back to front method the larger sphere would be rendered first and then the smaller one. Would this create artifacts because the face of the larger sphere closest to the camera is actually closer to the camera than the face of the smaller sphere closest to the camera while the furthest face is further than? Thanks.
Dark_Nebula
Dark_Nebula
Yes, this might cause artifacts. If it's visible or not depends on the scene. To avoid all artifacts you have to sort and render each face back-to-front.
In many situations just sorting objects is good enough.
blaze02
blaze02
If your 3D object (sphere) is transparent, you need to also render each "object" back to front. Assuming clockwise vertices is the standard for front-facing polys, you will want to:
1) Turn on clockwise culling and render your object.
2) Turn on counter-clockwise culling and render your object again.

I don't see any way to render your objects perfectly in all cases, but you could determine that the smaller sphere is between the back and front of your larger sphere. Thus it should be rendered between steps (1) and (2) above, obviously with the same render technique (back-facing polys, then front-facing polys). To render everything perfectly in all cases, I think you will either have to render on a per-poly basis or adhere to real-life physics: i.e. solid objects cannot pass through each other.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.