Author Topic: Active lights in GLSLShader  (Read 3831 times)

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Active lights in GLSLShader
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Active lights in GLSLShader
« Reply #1 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.

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: Active lights in GLSLShader
« Reply #2 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Active lights in GLSLShader
« Reply #3 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?

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: Active lights in GLSLShader
« Reply #4 on: August 23, 2011, 11:03:54 pm »
Yes it would be helpful, because I will pass that value to shader.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Active lights in GLSLShader
« Reply #5 on: August 23, 2011, 11:10:58 pm »
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.

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: Active lights in GLSLShader
« Reply #6 on: August 24, 2011, 10:29:45 pm »
Hello,

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

Thanks,
Wojtek