Discussion:
[Opensg-users] OpenSG2: LightEngine and light information in shader
Johannes Brunen
2016-10-21 07:40:55 UTC
Permalink
Hello,

currently I'm working on a shader shadow engine example and have realized that the light information is not available in the shader as I expected. I did expected that the OSGLightNActive variables are defined and that the OpenGL light structure gl_LightSource is valid. The reason is, imho, that the Light::renderEnter method does not perform any action, but delegates all the work to the engine's runOnEnter method. Obviously the ShaderShadowMapEngine:: runOnEnter does not care about that.

I have a couple of Questions for that:

1. Is my analysis correct?
2. Is it a bug or is it intentional?

I'm planning to use more lights than the 8 OpenGL standard lights. Additionally these lights may carry some extra information compared to the standard ones. In the end, I would like to have an uniform buffer object that does contain all the light information in an array of light structures.

3. How would you design such a scenario?

I have not yet understand what would be the correct place to setup the UBO of the lights. I would like to use light cores/chunks as usual in my scene graph, i.e. not bypassing the system by directly defining the UBO myself. I could imagine that a core at the top the scene graph could be responsible for accumulation of the light information and setting up the UBO for shader based rendering.

Finally, I'm heading to use a shadow map engine that I'm planning to write that performs shadowing on these lights.

I would really appreciate some help on these two related topics.

To be clear, the problem with the OSGLightNActive and the gl_LightSource structure relates to the simple first example with the ShaderShadowMapEngine that I'm writing. I did have tried to use an off- the-shelf light shader and it did not work, because of the missing information. But what I really would like to solve is the scenario with many shadowing lights in a forward rendering approach.

Best,
Johannes
Carsten Neumann
2016-10-21 17:08:28 UTC
Permalink
Hello Johannes,
Post by Johannes Brunen
currently I'm working on a shader shadow engine example and have
realized that the light information is not available in the shader as I
expected. I did expected that the OSGLightNActive variables are defined
and that the OpenGL light structure gl_LightSource is valid. The reason
is, imho, that the Light::renderEnter method does not perform any
action, but delegates all the work to the engine's runOnEnter method.
Obviously the ShaderShadowMapEngine:: runOnEnter does not care about that.
1. Is my analysis correct?
I think so and you have probably looked much closer at this than I have
in a while ;)
Post by Johannes Brunen
2. Is it a bug or is it intentional?
I think that was the intention, basically having a LightEngine takes
over how to render that light - including which state needs to be set.
Basically it swaps out the lights implementation (in terms of how it
affects rendering) while keeping the interface (the standard light cores).
Post by Johannes Brunen
I'm planning to use more lights than the 8 OpenGL standard lights.
Additionally these lights may carry some extra information compared to
the standard ones. In the end, I would like to have an uniform buffer
object that does contain all the light information in an array of light
structures.
3. How would you design such a scenario?
I have not yet understand what would be the correct place to setup the
UBO of the lights. I would like to use light cores/chunks as usual in my
scene graph, i.e. not bypassing the system by directly defining the UBO
myself. I could imagine that a core at the top the scene graph could be
responsible for accumulation of the light information and setting up the
UBO for shader based rendering.
But if your lights have additional information you will have to extend
the standard light cores anyway, so you might as well drop them entirely
and build ones that construct the necessary state for your shaders?
I think either writing a LightEngine that populates the UBO or a
completely different set of lights is what I'd look at for this.

Cheers,
Carsten

Loading...