Im working on a full lighting system for Defold game engine it uses puer opengl to draw stuff. So the actuall thing is this: The way the implementation goes is much like an observer pattern. Theres an array/vector with all the lightsources currently loaded into memory. A certain object can listen to certains light sources, by that i mean they will get their memory location and know which value is the light source(s) position, color and alike. Thing is, every object that can recieve light has its own array/vector of lights. Im implementing a way of adding/removing light sources from this array. In the way things are, when i run the game, i have one object that will listen to 4 light sources, that being a sun (directional light) and three other point light sources. When the scenes initialized the array is kinda of like this:
[0] = sun
[1] = lamp
[2] = lamp2
[3] = lamp3
This is how information is sent to the gpu, but note that directional light and point lights are separated. For point lights they all go into an array, so this is how they look in the gpu (renderdoc used):
then i remove lamp
from the list
[0] = sun
[1] = lamp2
[2] = lamp3
but instead of the position [2]
of the gpu being erased and all be 0, instead they still have the value of lamp3
:
i have tested the lua code the engine runs on, and it only sends data to the gpu 2 times after i removed the lamp
object, in short, theres no information about lamp
being passed to the gpu after it is removed from the list
after removing lamp
on more time, i add it again this time it is on top of everything on the light sources array (its the last position):