Deferred Lighting

View previous topic View next topic Go down

Deferred Lighting

Post by S33m3 on Sat Aug 13, 2011 3:58 pm

Hello !

I see that you have implemented deferred lighting.
Wich kind of problem have you resolved with this technique ?

First pass : I see that you are rendering your landscape first without light data.
Second pass : Then you seems to render only the light data on the landscape (Without texture colors)
Third pass : Then you have the one red picture with what seems to be the effect of the second pass to the first one.

The result is the First image blending with the second by the Red image value.

Do you generate your "red" map from pixel distance from camera ?
It makes you render your landscape to 3 differentes texture, and then use them in a 4 step to generate to final image. It this metods not killing performance ?

S33m3

Posts : 54
Join date : 2011-03-23

View user profile

Back to top Go down

Re: Deferred Lighting

Post by Slaihne on Sun Aug 14, 2011 2:27 am

Hehe,

To take your last point first; I thought exactly the same as you, that it would kill performance. But, i continue to be amazed at what modern graphics hardware can do. On my rig it currently runs at around 250fps with everything at max. Also, there is a lot of of stuff still in the shaders that needs tidied up or removed.

The passes i carry out are actually....

Draw all blocks, including transparent (not liquid).
Draw all models

These render into 3 buffers, a plain texture colour, a lighting buffer, and the first channel of a 2 channel linear depth buffer.

I plan to put dynamic lights after doing this rendering.

Then the tex and light are combined to produce a render to screen.

Then i draw the liquid front faces, but only to the 2nd channel of the linear depth buffer. I use an alpha blended add here.

Then i draw the liquid back faces, again, to the 2nd channel of the linear depth buffer. I use an alpha blended subtract here.

The linear depth buffer now allows me to calculate the water fog as well as the non-water fog per pixel.

If the player's head is in the water then i draw a sky sphere, blending in each pixel according to the linear depth buffer, followed by the stars, planets and clouds. The latter 3 don't use the linear depth buffer for blending.

I then do a full screen pass for water fog, blending in a fixed colour and using the linear depth buffer.

I then draw the liquid faces with transparency.

Then, if the players head is NOT in the water i draw the skysphere etc as detailed above.

Whew, that's a lot Smile But it runs fast. I think the thing that took me the longest time was coming to terms with what seemed like a huge number of steps to generate the scene.

Oh, and the problem i wanted to solve is still only partially solved. This was to get proper dynamic lighting. I feel that without moving or changing lights the underground areas may feel a bit 'flat'.

I say partially, because the main issue i was experimenting with is that of lights shining through walls. Currently i think that the only way this can work is if the lights cast shadows, but to cast shadows they need to be aware of the nearby geometry, i think that this may be slow.

Oh, the whole fog thing was a chance to leverage the Multi Render Target thing to solve another little bug bear, that of underwater fog not quite working properly.
avatar
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 49

View user profile

Back to top Go down

Re: Deferred Lighting

Post by Slaihne on Sun Aug 14, 2011 9:37 am

Just ran a few tests using GPU PerfStudio (a freebie from ATI)...

My full screen fog passes each take around 0.2 ms and my combining of the light and colour buffers also takes around 0.2 ms. To clear the buffers at the start of the frame takes around 0.02 ms each.

I'm gobsmacked affraid
avatar
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 49

View user profile

Back to top Go down

Re: Deferred Lighting

Post by Slaihne on Sun Aug 21, 2011 2:59 am

With the performance i'm seeing, i've decided to make the change to a proper deferred renderer. I'm probably going to keep a forward renderer also for the slower machines out there.
avatar
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 49

View user profile

Back to top Go down

Re: Deferred Lighting

Post by S33m3 on Sun Aug 21, 2011 8:37 am

If I resume well the "weakness" of the deferred rendering is that you need to render your scene multiple times.
So it means that you Draw multiplying your draw call by a X factors isn't it ?

How many draw call do you send per frame with your deferred rendering turned on ?

S33m3

Posts : 54
Join date : 2011-03-23

View user profile

Back to top Go down

Re: Deferred Lighting

Post by Slaihne on Sun Aug 21, 2011 9:20 am

I don't do any more draw calls than before. I'm using multiple render targets, so a single draw call draws to many targets simultaneously.
avatar
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 49

View user profile

Back to top Go down

Re: Deferred Lighting

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum