Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Forward rendering light accumulation for 2D transparent sprites


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 pondwater   Members   -  Reputation: 191

Like
0Likes
Like

Posted 06 April 2013 - 11:31 PM

I'm writing a little rendering engine for 2D sprites incorporating dynamic lighting via normal maps. For opaque sprites I’m using deferred rendering. I'm attempting to include forward rendering for transparent sprites.

 

For the forward rendering, since I cannot take advantage of the depth buffer (since all sprites are on the same Z-plane), I’m not sure how to accumulate lights properly to prevent bright patches where sprites overlap.

 

What I’ve currently been doing is simply iterating over each transparent object for each light, accumulating the fragments using additive alpha. For this I either turn off depth testing, or set it to GL_LEQUAL. It doesn't really matter because all quads are drawn on the same Z plane so depth testing is irrelevant.

 

My problem comes into when two transparent objects intersect. Normally for opaque objects the sprite drawn last overwrites whatever is in the G-Buffer, which is what I want. However, for forward rendering, the additive blending of the lights causes bright patches where the sprites overlap.

 

So my problem boils down to: for individual transparent sprites the light must be accumulated with alpha blending, and between transparent sprites they should be combined using conventional alpha*S + (1- alpha)*D blending.

 

The only way I can think to accomplish this is to clear and fill an individual FBO for each transparent sprite. I clear the FBO, render an individual transparent object accumulating each light with additive blending, then alpha blend that with my final buffer from my deferred renderer. Clear the FBO, and begin rendering the next transparent object, and so forth.

 

This seems horrifically inefficient. What is the proper way to do this?



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS