Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 22:12

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Why render things twice?
PostPosted: 05.05.2012, 13:26 
Offline

Joined: 16.05.2009, 12:43
Posts: 207
I noticed that in model.shader the FS_AMBIENT and FS_LIGHTING passes. This is a bit confusing, as ambient light is part of the lighting calculation. I'm wondering if anyone has any ideas why there would be two passes for this?


Top
 Profile  
Reply with quote  
PostPosted: 05.05.2012, 13:32 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
If ambient was part of lighting context, it would be applied multiple times depending on how many lights are on the scene (FS_LIGHTING is computed for each light source and add blended).


Top
 Profile  
Reply with quote  
PostPosted: 06.05.2012, 04:49 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
zoombapup wrote:
I noticed that in model.shader the FS_AMBIENT and FS_LIGHTING passes. This is a bit confusing, as ambient light is part of the lighting calculation. I'm wondering if anyone has any ideas why there would be two passes for this?

Hi Zoombapup,

This is the general technique for forward rendering and afaik this is exactly how Doom 3 does it except that a shared shadow map is used vs the stencil shadow technique (each light renders the geometry again) so technically the geometry is rendered 3 times if the light has a shadowmap context attached (1 ambient, 1 shadowmap & 1 light additively blended like Worstplayer explained and should give an accurate light calculation from the ambient pass) although the shadowmap pass will have different geometry rendered due to the light's position culling based on its view frustum and not the camera's. Also notable is that the ambient pass also did a z pre-pass so these additive lights on top will be cheaper due to the z-testing and only render to the fragments which pass the z-test.

It's done this way so that each light is its own pass and can have its own shadowmap context and keeps the system general-purpose (and is relatively memory-efficient due to the same shadowmap context getting re-used). It's not very scalable performance-wise with more lights but hey, that's what deferred shading is set out to fix, or light pre-pass... :)

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group