Rendering solid and semi-transparent objects

jbirac
Unregistered
 
Post: #1
Does anyone know how to render solid and semi-transparent objects in the same frame?

I need to render a large group of objects (gluSphere and gluCylinder) in any arbitrary order. Some of the objects are meant to be semi-transparent. I am using the depth test (i.e., the image is 3D) and am setting the each object's alpha color parameter to 0, 1 or something in between. The problem is a solid object (alpha = 1) rendered SUBSEQUENTLY "behind" a semi-transparent (alpha < 1) object will fail the depth test and go unrendered. This is not realistic!

Take this scenario:
The camera is looking through a (semi-transparent) window into a room of a house; a chair is visible in the room. If the objects are rendered in the sequence "chair-window-house" or "chair-house-window" – the chair is rendered FIRST – then the scene is realistic. But if the chair is rendered AFTER the window, the chair does not appear, regardless of the window's transparency; the window is "closer" so the depth test fails for the chair. How could the scene be rendered realisticly regardless of the order in which the objects are drawn?

I cannot be the first one to have this problem.

Does anyone know how to approach this?

Thanks in advance.

-- Jeff
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Render all your opaque objects first, in any order.

Then render all your transparent objects, sorted from furthest from the camera to nearest to the camera.

Depending on your situation, per-object sorting may not be fine-grained enough to generate a perfect image; you might have to sort per-polygon, or even worse, split polygons, but that's unlikely.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Transparent textures kordeul 2 2,697 Aug 27, 2007 01:38 AM
Last Post: kordeul
  Intersection with arbitrary solid hamishl 2 2,926 Sep 17, 2004 01:41 PM
Last Post: codemattic
  Transparent Color? Josh 6 5,969 Apr 22, 2002 05:27 AM
Last Post: Josh