Active lights in GLSLShader

Started by Wojtek, August 23, 2011, 08:57:29 PM

Previous topic - Next topic

Wojtek

Hello,

Is it possible to determine how many lights are assigned to particular Object3D?

What I want is to determine active lights count in my Fragment shader to not iterate through 8 lights.
There is an additional reason why I want to do that.
If I had previously specified 5 lights and disabled 3 of them, my shader is still getting values of old 3 lights.

Is there any specific method in JPCT to determine actual number of active lights associated to world, or is GLSLShader passing any uniform value which I would be able to use in my shader?

Thanks,
Wojtek

EgonOlsen

There's a build-in uniform gl_MaxLights. I've never used it myself, but it's worth a try.

Wojtek

Well that uniform is more about the maximum number of lights supported by shader. I am more interested in actual number not maximum.

EgonOlsen

I see...would it help if you could query the Object3D for the number of active lights?

Wojtek

Yes it would be helpful, because I will pass that value to shader.

EgonOlsen

Give this updated jar a try: http://www.jpct.net/download/beta/jpct.jar

It adds a getLightCount()-method to Object3D (untested and only valid in the context of an IRenderHook) as well an an additional setCurrentObject3D()-method to IRenderHook, which will be called right before the beforeRendering()-method with the current Object3D.

Wojtek

Hello,

I have checked it today and it is good very well.

Thanks,
Wojtek