www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Wojtek on August 23, 2011, 08:57:29 pm

Title: Active lights in GLSLShader
Post by: Wojtek on August 23, 2011, 08:57:29 pm
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
Title: Re: Active lights in GLSLShader
Post by: EgonOlsen on August 23, 2011, 09:24:41 pm
There's a build-in uniform gl_MaxLights. I've never used it myself, but it's worth a try.
Title: Re: Active lights in GLSLShader
Post by: Wojtek on August 23, 2011, 10:16:16 pm
Well that uniform is more about the maximum number of lights supported by shader. I am more interested in actual number not maximum.
Title: Re: Active lights in GLSLShader
Post by: EgonOlsen on August 23, 2011, 10:23:00 pm
I see...would it help if you could query the Object3D for the number of active lights?
Title: Re: Active lights in GLSLShader
Post by: Wojtek on August 23, 2011, 11:03:54 pm
Yes it would be helpful, because I will pass that value to shader.
Title: Re: Active lights in GLSLShader
Post by: EgonOlsen on August 23, 2011, 11:10:58 pm
Give this updated jar a try: http://www.jpct.net/download/beta/jpct.jar (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.
Title: Re: Active lights in GLSLShader
Post by: Wojtek on August 24, 2011, 10:29:45 pm
Hello,

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

Thanks,
Wojtek