Horde3D
http://horde3d.org/forums/

Question about the lights
http://horde3d.org/forums/viewtopic.php?f=1&t=44
Page 1 of 1

Author:  B_old [ 20.12.2006, 21:35 ]
Post subject:  Question about the lights

Hi,

I was wondering about the lights.
Am I right that the lights are spotlights by default?
How can I create a normal point or directional light?

Thanks.

Author:  marciano [ 21.12.2006, 17:58 ]
Post subject: 

Hi B_old,

you're right, in the Chicago sample spotlights are used. In Horde each light has a lighting shader which determines how the light source is interacting with the scene. You can modify this shader to get a point or directional light or whatever other type you want. The only restriction at the moment is that shadow maps are only calculated for spot lights. If you want a point light with shadows you can create 6 spots but of course that is pretty expensive performance-wise especially since the engine is not yet optimized.

Author:  B_old [ 21.12.2006, 18:29 ]
Post subject: 

OK, I know where to look then.
I am not used to the concept of having a seperate lighting shader. Is that something that comes with deferred lighting?

Author:  marciano [ 24.12.2006, 14:03 ]
Post subject: 

Yes exactly. With deferred shading in a first step all attributes of a fragment like color, normal and position are written to a buffer and after that lighting is done in a separate post-processing step. That's why you usually use two shaders, one for the attribute pass and one for the actual lighting.

Author:  B_old [ 24.12.2006, 15:13 ]
Post subject: 

Sounds kind of cool. I might try to implement this myself sometime. Thanks for the info.

Another thing.
Are you planning to let the user specify a FOV for the spotlight? I hardcoded a different FOV into the shader, but that is not very convenient. Does the engine expose shader-variables to the user?
Anyway, it would be nice to be able to change the FOV.

When I think about it, you HAVE to let the user specify a FOV directly, otherwise the engine will cull to few/many objects.

Author:  marciano [ 30.12.2006, 22:51 ]
Post subject: 

Thanks for the hint, that's something important that's still missing. There are some parameters like light position and color that are already exposed to the shader but the list is not yet complete.
I will include light FOV it in the next release. Implementing it should be pretty straightforward so if you really need it immediately or are a bit adventuresome ;) you can hack it into the engine within some minutes. Just look how the light color is integrated and do it in an analogical way.

Author:  swiftcoder [ 05.01.2008, 16:26 ]
Post subject: 

Since a lot of applications will be using forward shading for the foreseeable future, this may need to be rethought a little...

At the moment, if I want to add directional lights, I need to customise several of the shaders shipped with the samples - especially the skinning and standard shaders, and I am still not sure how I would determine a directional light - as I can't find an API to set the 4th component of the light position (the usual OpenGL method to specify directional lights).

Author:  marciano [ 06.01.2008, 15:47 ]
Post subject: 

The idea is to use different shader contexts for the different light types. If you want a directional light you add a shader context DIRLIGHT (or similar) to your materials and assign that name to the light source (the lighting context parameter). The light source is then using that shader context for calculating lighting.

I think this solution makes sense since a directional light is different from a spot light in several aspects, e.g. it usually doesn't have distance attenuation. So I think it is better than having a unified lighting shader that works for all light types. You also don't have to write the lighting code for each material again and again since you can just include a code resource in the shader contexts. So this not so much overhead.

Author:  swiftcoder [ 06.01.2008, 15:56 ]
Post subject: 

marciano wrote:
I think this solution makes sense since a directional light is different from a spot light in several aspects, e.g. it usually doesn't have distance attenuation. So I think it is better than having a unified lighting shader that works for all light types. You also don't have to write the lighting code for each material again and again since you can just include a code resource in the shader contexts. So this not so much overhead.


That makes sense. How difficult do you think it would be to get shadow-mapping working for a directional light (obviously point lights are a mess for shadow-mapping)?

Author:  marciano [ 07.01.2008, 00:42 ]
Post subject: 

Shadow maps for directional lights should be relatively easy to realize. Actually you just need to replace the perspective light frustum by an orthographic one.

Point lights are more challenging. I used to have shadow cube maps a long time ago but they are not generic enough for my taste and introduce too many special cases and shader combinations. I would rather suggest the same solution as described by Crytek (in Finding Next Gen - CryEngine 2) which involves unwrapping the cube map to six single shadow maps.

Author:  marciano [ 09.01.2008, 21:01 ]
Post subject: 

By the way, do you really need a special directional light or doesn't a spot light work as well if you place it far enough from the scene?

Author:  swiftcoder [ 11.01.2008, 14:01 ]
Post subject: 

marciano wrote:
By the way, do you really need a special directional light or doesn't a spot light work as well if you place it far enough from the scene?

I am paging in extremely big scenes, so it might not - there will probably be some paralax.

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