Horde3D
http://horde3d.org/forums/

Why render things twice?
http://horde3d.org/forums/viewtopic.php?f=1&t=1666
Page 1 of 1

Author:  zoombapup [ 05.05.2012, 13:26 ]
Post subject:  Why render things twice?

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?

Author:  worstplayer [ 05.05.2012, 13:32 ]
Post subject:  Re: Why render things twice?

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).

Author:  MistaED [ 06.05.2012, 04:49 ]
Post subject:  Re: Why render things twice?

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... :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/