Lights affecting only specific renderqueues
-
kracejic
- Kobold
- Posts: 25
- Joined: Wed Sep 10, 2014 5:18 pm
- x 1
Lights affecting only specific renderqueues
Hi,
Can lights in Forward3D be configured to affect only some specific objects? One solution could be to use light only for specific renderqueues IDs range.
Use case:
Top down shooter with indoor and outdoor lights.
Or is there another way to get similar outcome?
Thanks for ideas
Can lights in Forward3D be configured to affect only some specific objects? One solution could be to use light only for specific renderqueues IDs range.
Use case:
Top down shooter with indoor and outdoor lights.
Or is there another way to get similar outcome?
Thanks for ideas
- dark_sylinc
- OGRE Team Member

- Posts: 5588
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1413
- Contact:
Re: Lights affecting only specific renderqueues
Not by default.
You can use the range setting to suddenly cut the light.
For your particular case, the best I can suggest is to slightly modify OgreForward3D.cpp and the shader templates so that a rectangle is sent instead of the range and hence suddenly cut the light. Would be like the range setting, but with more freedom.
Light masks are supposed to solve this problem, but it wasn't integrated into Forward3D due to some performance concerns (which may be unfounded though?), as we would have to send the light mask per object (not just the light's) and evaluate the bitmask per pixel.
You can use the range setting to suddenly cut the light.
For your particular case, the best I can suggest is to slightly modify OgreForward3D.cpp and the shader templates so that a rectangle is sent instead of the range and hence suddenly cut the light. Would be like the range setting, but with more freedom.
Light masks are supposed to solve this problem, but it wasn't integrated into Forward3D due to some performance concerns (which may be unfounded though?), as we would have to send the light mask per object (not just the light's) and evaluate the bitmask per pixel.
- dark_sylinc
- OGRE Team Member

- Posts: 5588
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1413
- Contact:
Re: Lights affecting only specific renderqueues
I've been thinking about it, and there is one way:
Forward3D lights do obey the visibility mask. We can exploit this.
Let's say you've got interior and exterior objects and interior and exterior lights.
Set visibilityMasks of both the interior objects and lights to 1.
Set visibilityMasks of both the exterior objects and lights to 2.
Lights that affect both interior and exterior objects can be set to 3 (3 = 1 | 2)
For efficiency reasons, place the interior objects in one RenderQueue and exterior objects in another RenderQueue ID. However this isn't strictly necessary.
Lets say interior objects are in RQ 4; and exterior objects are in RQ 5.
This should work because the lights are processed by the same frustum culling system that affects objects before they're sent as a list to the GPU.
Forward3D lights do obey the visibility mask. We can exploit this.
Let's say you've got interior and exterior objects and interior and exterior lights.
Set visibilityMasks of both the interior objects and lights to 1.
Set visibilityMasks of both the exterior objects and lights to 2.
Lights that affect both interior and exterior objects can be set to 3 (3 = 1 | 2)
For efficiency reasons, place the interior objects in one RenderQueue and exterior objects in another RenderQueue ID. However this isn't strictly necessary.
Lets say interior objects are in RQ 4; and exterior objects are in RQ 5.
Code: Select all
//First render the interior objects:
pass render_scene
{
//Filter out exterior objects and lights
visibility_mask 0x00000001
rq_first 4
rq_last 5
}
//Then render the exterior objects:
pass render_scene
{
//Filter out interior objects and lights
visibility_mask 0x00000002
rq_first 5
rq_last 6
}-
kracejic
- Kobold
- Posts: 25
- Joined: Wed Sep 10, 2014 5:18 pm
- x 1
Re: Lights affecting only specific renderqueues
I will try this, it should provide everything I need.
Thank you!
Thank you!