Hello I was just wondering if anybody had already gotten interested in the following:
the bump mapping glsl shader I have only takes in account 1 light (the famous gl_LightSource[0]), so clearly except when you run a simple demo, you don't want your shader to interact only with 1 light. So I was wondering between the following solutions, which one you'd advise me:
_ Incorporate in my shader, additional lights like gl_LightSource[1, 2, …] (probably ok if you just want to add 1 or 2 lights)
_ Incorporate a test in my shader to select only the closest light source with a distance test (but I believe it would be a total waste of gpu to have the test done in the shader)
_ Have jme test this condition and tell the shader which light source it should deal with (seems more reasonable, but I have no idea how, since the light is not provided in the shader arguments, or maybe can you give the light source as a uniform … ?)
Any opinion, comment, appreciated,
Adrien
Very common problem, was especially prominent 2-3 years ago in the commercial engine field… Some solutions:
- Summing of light components for all lights (e.g your first preposed solution)
- Multi-passing, rendering the model once for each light
- Deferred rendering, same as #2 but rendering the model data to a framebuffer (normal, depth, diffuse) and operating on that.
_ Have jme test this condition and tell the shader which light source it should deal with (seems more reasonable, but I have no idea how, since the light is not provided in the shader arguments, or maybe can you give the light source as a uniform ... ?)
This is done automatically in jME2 which has light sorting. Essentially gl_LightSource[0] will always be the closest light.
I guess the optimal solution will be to migrate all my stuff to jme 2.0, and probably also having the shader handle 3-4 lights at the same time, but thanks now I don't have to worry about that anymore,
Adrien
In jme2 you have to enable light sorting manually.
See jmetest.util.TestManyLights.
rootNode.sortLights()
In jme1 you had to use the now Deprecated LightManagement class