varying ambient light Topic is solved
-
- Goblin
- Posts: 247
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 18
varying ambient light
I'm aware that regular lights can be restricted to certain renderables using light masks, but is there any way to have different amounts of ambient light for different renderables?
-
- Bronze Sponsor
- Posts: 479
- Joined: Sun Jan 18, 2015 4:20 pm
- Location: Buenos Aires, Argentina
- x 167
Re: varying ambient light
As far as I know, you would probably have to solve it by using your own shaders.
-
- OGRE Team Member
- Posts: 5433
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1341
Re: varying ambient light
No, there is not out of the box.
You could workaround the issue by using Render Queues (or scene visibility flags, but this is less efficient) and multiple pass scene passes.
And in between the passes, you change the ambient light.
Or else, customize the shaders.
You could workaround the issue by using Render Queues (or scene visibility flags, but this is less efficient) and multiple pass scene passes.
And in between the passes, you change the ambient light.
Or else, customize the shaders.
-
- Goblin
- Posts: 247
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 18
Re: varying ambient light
Can you give me any hints on how to set up multiple scene passes, or where to find sample code illustrating that?
-
- OGRE Team Member
- Posts: 5433
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1341
Re: varying ambient light
It's just two "pass render_scene" passes:
skip_load_store_semantics optimizes performance (Ogre 2.3+) by telling Ogre to keep rendering without flushing anything. The identifier is an arbitrary number you use to identify this pass in CompositorWorkspaceListener (so you know what to turn on and off)
rq_first and rq_last is how you tell Ogre what RQs to render
shadows "reuse" forces Ogre to reuse an already populated shadow node (Ogre should notice this automatically, but using reuse makes it explicit)
Code: Select all
pass render_scene
{
load
{
all clear
colour dont_care
}
store
{
all dont_care
colour store_or_resolve
}
// kArbitraryId0
identifier 101
rq_first 0
rq_last 5
shadows MyShadowNode
}
pass render_scene
{
skip_load_store_semantics true
// kArbitraryId1
identifier 102
rq_first 5
rq_last 199
shadows MyShadowNode reuse
}
rq_first and rq_last is how you tell Ogre what RQs to render
shadows "reuse" forces Ogre to reuse an already populated shadow node (Ogre should notice this automatically, but using reuse makes it explicit)
-
- Goblin
- Posts: 247
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 18
Re: varying ambient light
OK, so that quoted code is not C++, it's... what? What do I do with it? Sorry about my cluelessness. Normally when I'm trying to figure out how to do something, I look through the API docs, but this is going in a very different direction.
-
- OGRE Team Member
- Posts: 5433
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1341
Re: varying ambient light
It's script code to setup in ".compositor".
You'll find lots of them in "Samples/Media/2.0/scripts/Compositors" and a few of them in "Samples/Media/2.0/scripts/materials".
Compositors tell Ogre how you want to render code. You create a compositor definition, and then instantiate it via CompositorManager::addWorkspace()
You can do it via C++ but it can be hard to setup (it's easier to set them up in script, then modify them in C++; rather than constructing them from scratch). If you truly want to construct them from scratch we have a few examples in Samples/2.0/Showcase/Postprocessing/Postprocessing.cpp (see PostprocessingGameState::createExtraEffectsFromCode)
Ignition is also constructing them in pure C++ in Ogre2RenderTarget::BuildCompositor
You'll find lots of them in "Samples/Media/2.0/scripts/Compositors" and a few of them in "Samples/Media/2.0/scripts/materials".
Compositors tell Ogre how you want to render code. You create a compositor definition, and then instantiate it via CompositorManager::addWorkspace()
You can do it via C++ but it can be hard to setup (it's easier to set them up in script, then modify them in C++; rather than constructing them from scratch). If you truly want to construct them from scratch we have a few examples in Samples/2.0/Showcase/Postprocessing/Postprocessing.cpp (see PostprocessingGameState::createExtraEffectsFromCode)
Ignition is also constructing them in pure C++ in Ogre2RenderTarget::BuildCompositor
-
- Goblin
- Posts: 247
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 18
Re: varying ambient light
I decided to do it by shader customization. At the end of the DoAmbientLighting piece in AmbientLighting_piece_ps.any, I added a line:
So I can modify an HlmsPbsDatablock to add "extra ambient light" for that material.
Code: Select all
finalColour += material.userValue[2].xyz * pixelData.diffuse.xyz;