Rendering solid and semi-transparent objects

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
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 4,091 Aug 27, 2007 01:38 AM
Last Post: kordeul
  OpenGL, SDL, and Transparent Bitmaps RyanA 4 6,148 Jun 26, 2006 04:26 PM
Last Post: RyanA
  About transparent colors un textures valle 2 3,820 Oct 26, 2004 09:52 AM
Last Post: valle
  Intersection with arbitrary solid hamishl 2 3,781 Sep 17, 2004 01:41 PM
Last Post: codemattic
  "boingX" (transparent ogl) under carbon GioFX 2 4,386 Jun 29, 2004 09:08 AM
Last Post: GioFX