Any tips for 3D lighting?
What I was able to do so far:
- On Start: Function "CallLights"
- Function "CallLights": for each Light object - Function "UpdateLight"
Param (0) = light level
Param (1) = redcolor
Param (2) = greencolor
Param (3) = bluecolor
Param (4) = alphacolor (I did nothing with this until now...)
Param (5) = light.posX
Param (6) = light.posY
Param (7) = light.poxZ
- Function "UpdateLight"
-- For each object that isn't a ligth object (this condition is only for my project, as I said, Meshloader load/placehold everything that is 3D)
-- (param(0)*10)/Distance3D(obj.x, obj.y, obj.z, param(5), param(6), param(7))
-- obj red color = Function.Param(1)*Self.LightLevel
-- obj green color = Function.Param(2)*Self.LightLevel
-- obj blue color = Function.Param(3)*Self.LightLevel
Image :D
Problem? Here: I need to make this to verify if ther is a block blocking light, since a light on the ground cannot reach a cave level.
I saw that it could load light block per block... How am I supposed to that mid-air? I have to place every non-block with 'air placeholder'?
You need to pathtrace or raytrace from ach object within the range of the light to the light source and if there is a collision with block on the path ( assuming each of your blocks has it's own sprite object ), you test weather the path is between min and max z of the object, and if it isn't, it continues the path till it eventually reaches the source. You already did raytracing I think.