How write the properties of light in irrlicht?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Noiecity
Posts: 319
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

How write the properties of light in irrlicht?

Post by Noiecity »

I am confused as to how the radius and attenuation of irrlicht work, I see that both affect irrEdit, and not separately, but rather they both complement each other, however when asking chatgpt or any other AI they insist that the documentation suggests that when assigning attenuation values ​​it will ignore the radius, so how do you actually assign the radius and attenuation in irrlicht? I don't understand it, I remember that a few years ago the AI ​​told me that I had to assign them in an order, but the AI ​​usually only speculates about a possible meaning of certain words, it won't necessarily be that in practice.

I have also seen that it is good to activate ambientlight if you want a pointlight, it practically has the same lighting effect as diffuse(the attenuation and radius have the same effect), only that it respects better when the light is close to the object, with fair attenuation values, you get correct lighting without having so many triangles

Attenuation: 1.000000, 0.000001, 0.100000
Image
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, for free. CC0 man.

Image
**
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How write the properties of light in irrlicht?

Post by CuteAlien »

Phew... bit tricky. AI is partly right. First - make sure you go over the lightscenenode and not the SLight structure when setting those (as mentioned there those are not meant to be written to directly).

And then yes - ILightSceneNode::setRadius indeed sets the attenuation (and also the radius).
If the radius has any effect depends on the driver. In theory light is infinite. But Direct3D has a hard cutoff - so the radius is used there.
And in Irrlicht it is also used as hard cutoff when shadows are calculated - I think it was when nodes are further away than 4*radius from the light they stop throwing shadows.

If you want to set attenuation to other values, but do need Irrlicht shadows: Set the radius first (to any value where shadows should be regarded). And then set the attenuation later to any values you want.

If you don't have shadows - then really only attenuation matters (except in D3D which does hard cutoff which doesn't exist in other drivers).
Basically the 3 different attenuation values control the curve how light gets reduced by distance (so harder/softer cutoff) and when going over setRadius it only set the middle one to 1/radius and the other two to 0.

And yes - ambient and diffuse behave the same, except one is global and the other is per light.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Noiecity
Posts: 319
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: How write the properties of light in irrlicht?

Post by Noiecity »

Thank you, I understand better now because of your explanation
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, for free. CC0 man.

Image
**
Post Reply