Extending the Lights

While implementing Light loading in the OGRESceneLoader, which I would like to contribute, too :D, I've found out that the Light classes are by far not ready.



There is no SpotLight, I can not find any settings for constant, linear or quadratic fallof… etc…



Well, I could implement them, just to need one thing:

The computeLastDistance method: Does it really should return the distance, or should it return, how strong the Light is affecting the Geometry?

If latter, I would implement things like linear, constant and quadratic fall-off of luminousity.



After digging into the shader codes, and Material code, etc…

I just can't figure out, how the Lighting really works, sorry have damn little GLSL experiences.

It would be really nice, if someone (e.g. MOMOKOOOOO XD) can explain me a bit, how the Lights are "rendered".

This would help me a lot implementing SpotLight, extending PointLight, etc.

Another question, how should a <node></node> statement with a light in it be handled?

Should the contained Light enlight the whole Scene(1), the node wich declares the light(2), or the parent Node of the node declaring the light(3)?



Personally, I think we shouldn't go for (1). I'm modeling in Blender, and (2) would mean, that I have to attach the models to be enlighten to the light. So, If I move the Light, the models move, too, which would be quite annoying.

(3) would mean, I have to attach the light to (or to a parent node of) the model to enlight it.



So I would vote for (3).

The falloff parameters that are commonly used in OpenGL, etc, are not used in jME3. Instead you have the "radius" parameter, it automatically handles the attenuation based on the light's radius. The way lights are rendered is a bit complex, it is done in multipass. The relevant code is in the Lighting.vert/frag shader.

I too think that lights in <node></node> should be applied to that node's parent.

So, that means you can't set the lightattunation manually?

Kind of sad, because, you won't be able to change it in blender for example.



Okay, it's kinda ready, will post it here as soon as I tested it better.



Oh, and btw… you can - at least in my working copy  :smiley: - use an userdefined .material file now :wink: