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

Alpha Blending

Last post 21/10/2009 3:45 by legalize. 5 replies.
  • 14/09/2009 4:59

    Alpha Blending



      I have a D3D10 Framework, and am attempting to create multiple levels of blending. 

     The problem is that I have to (of course) render in order, and the user can move anywhere in the scene.

      This means that rendering order must either be adjusted to where the user is (to allow for proper blending) or ... ?

     Is there a way to have objects that should have major alpha components get a second pass to deal with it properly rather than modify the rendering order??

    (the above should look more like a 3-set venn diagram.. not the 2-set it resembles now)
  • 14/09/2009 16:33 In reply to

    Re: Alpha Blending

    Answer
    Reply Quote
    Unfortunately this kind of transparency requires pre sorting. There were some attempts to work round this. A search for “order independent transparency”   should give you some samples for this.
  • 14/09/2009 17:02 In reply to

    Re: Alpha Blending

    Ralf, Thanks for the suggestion - I did the search as you suggested, sadly found two posts - one was this one.

    The other post suggests using one vertex per billboard and finding depth that way, he seemed to be doing something with billboards...
    I however am using 3D objects, not billboards - but at least I have the bounding boxes - so, I guess I only really have to check two verticies instead of one...

    So, If I have this straight.... The rendering order should be.. 

      Solid Objects from Near to Far ( opposite of painters algorithm .. )
      -- Skybox somewhere in here --
      Transparent objects from Far to Near (Should this be reversed? Logically, You render far transparents first so they show up thru the closer transparent objects - painters algorithm.)


    Thanks so much.


  • 14/09/2009 17:32 In reply to

    Re: Alpha Blending

    I don’t mean searching the forum. I was talking about the web. Sorry for being not more clear.
  • 15/09/2009 20:49 In reply to

    Re: Alpha Blending


     I have fixed my issue by using a bounding box algorithm, a distance to camera algorithm, some std::sort and a bit of luck.

     Now, I only draw whats in the frustum, from FAR to NEAR (always, so my transparency works) ...

      Is it advisable to go the other way with solids and opposite with transparencies? or does sorting everything out tax more than drawing backwards?
  • 21/10/2009 3:45 In reply to

    Re: Alpha Blending

    Answer
    Reply Quote

    indes:
    Is it advisable to go the other way with solids and opposite with transparencies? or does sorting everything out tax more than drawing backwards?

    For opaque surfaces, its better to draw them front to back if you're using the depth buffer for hidden surface elimination. Drawing the closer objects first fills the Z buffer so that hidden objects are rejected faster than they would be if you spent the time to calculate all their shading for the color buffer only to cover it over by a closer object later. Since these are opaque objects, any partially transparent objects that are behind them will be completely occluded even though they are partially transparent.

    So generally, you draw opaque objects front-to-back first, then transparent objects back-to-front. For objects that have portions that are completely opaque and portions that are completely transparent (think of a transparency map that has fully opaque, fully transparent and inbetween portions), it can sometimes be faster to draw them in both of these passes, but use alpha test to segment the objects into two chunks of pixels: those that are completely opaque and those that have some partial transparency.

Page 1 of 1 (6 items) Previous Next