XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Transparent textures on meshes

Last post 4/28/2008 6:32 PM by jwatte. 3 replies.
  • 4/28/2008 11:57 AM
    • (484)
    • premium membership
    • Posts 145

    Transparent textures on meshes

    I've been reading through the forums regarding alphablending and transparent textures on meshes, and what I've found is basically this:  You've got to draw all opaque objects first, and then sort the transparent ones based on depth from the camera, in order for everything to draw correctly.  Am I understanding this correctly?




  • 4/28/2008 12:01 PM In reply to

    Re: Transparent textures on meshes

    If you want the effect to be right all the time, then yes. This can be very expensive if you don't have a nice way of sorting the meshes during runtime.

    I think it can get worse too. What happens if you have five translucent objects spread out, each in a straight line directly in front of the camera. Now you want alpha blended particles in between each of those as well. I haven't tried that situation myself, but I can bet it gets pretty hairy.

    XNA QuickStart Engine (3D Game Engine for XNA) | My site
    "I'll be whatever I want to do!", Philip J. Fry
  • 4/28/2008 1:57 PM In reply to

    Re: Transparent textures on meshes

    I would definitely make your system only sort if absolutely necessary. Take an example from Grand Theft Auto 3 (and I believe all the ones since even). The windows on the restaurants you were able to go into were alpha blended. From the outside you could see everything inside without a problem. However if you went inside you would be unable to see any cars through the windows because they didn't bother doing sorting. It makes sense, too. You are probably outside the restaurant far more than inside, so the minor visual error was worth the saved CPU time.

    So you could even make your system able to sort some transparent objects if need be and ignore other ones where it isn't as important. Then you can pick and choose to get the best performance/visual quality.
  • 4/28/2008 6:32 PM In reply to

    Re: Transparent textures on meshes

    Are you sure the cars weren't just LOD management with the indoors scenes?

    Sorting might have been expensive back in the days of BASIC interpreters on 1 MHz Z80 chips, but depth sorting a number of meshes is not going to show up on the profile of a modern game, unless you have 1,000s of meshes and use a bad sort function. In fact, I sort individual particles in a particle system without too much impact (it's measurable, but not noticeable).

    Sorting each individual polygon across the entire scene starts becoming expensive, though. But you don't need that unless you have objects that interpenetrate, such as a really large particle system within which a number of transparent objects are located.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
Page 1 of 1 (4 items) Previous Next