Horde3D

Next-Generation Graphics Engine
It is currently 06.06.2024, 14:03

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: 20.12.2006, 21:35 
Offline

Joined: 20.12.2006, 21:26
Posts: 5
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 21.12.2006, 17:58 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 21.12.2006, 18:29 
Offline

Joined: 20.12.2006, 21:26
Posts: 5
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 24.12.2006, 14:03 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 24.12.2006, 15:13 
Offline

Joined: 20.12.2006, 21:26
Posts: 5
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 30.12.2006, 22:51 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 05.01.2008, 16:26 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 06.01.2008, 15:47 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 06.01.2008, 15:56 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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)?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 07.01.2008, 00:42 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 09.01.2008, 21:01 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 11.01.2008, 14:01 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 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:  
cron
Powered by phpBB® Forum Software © phpBB Group