minetest / minetest

Luanti (formerly Minetest) is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.86k stars 2.04k forks source link

Lighting API features #13905

Open Athozus opened 1 year ago

Athozus commented 1 year ago

Problem

Recently, we got many visuals improvements, such as dynamic shadows, and more are upcoming, according to the milestone. However, creating light sources itself is still weird, on many points, notably for entities.

Solutions

Here are my proposal features/changes. A day or not, I'll work on it. But, if someone else does it, that's 100% okay.

Alternatives

Additional context

Thanks for reading all the message =) Note that I'm most an ingame coder than a mod developer, however I already made some edits on mods.

hecktest commented 1 year ago

Shadows should overlap themselves. When two shadows are overlapped, it creates a darker shadow (irl)

This isn't what happens in real life, what happens in real life is that light is combined additively rather than shadows being combined subtractively.

Athozus commented 1 year ago

This isn't what happens in real life, what happens in real life is that light is combined additively rather than shadows being combined subtractively.

Yes, thanks for the precision. That should be taken in account for the coding of it.

Athozus commented 5 months ago

@y5nw suggested me in a Matrix discussion to add the following parameter : lighting_direction, which is a good call I think.

I don't really know how this would be defined, I'm not a physicist (only 1st year of studies), but I would in the first place propose a lighting_vector then a lighting_angle which would be the range around the vector, which would be the « middle ». But I'm waiting for better physicists than me.

Athozus commented 5 months ago

And a small patch to apply to @APercy's PA28 if you'd like to test the light_source for entities (I've tried small things but didn't spend much that time) :

The patch ```lua diff --git a/entities.lua b/entities.lua index 7ecfc28..beb5f91 100644 --- a/entities.lua +++ b/entities.lua @@ -39,6 +39,7 @@ minetest.register_entity('pa28:p_lights',{ collide_with_objects=false, pointable=false, glow = 0, + light_source = 0, visual = "mesh", mesh = "pa28_lights.b3d", textures = { @@ -66,6 +67,7 @@ minetest.register_entity('pa28:light',{ collide_with_objects=false, pointable=false, glow = 0, + light_source = 0, visual = "mesh", mesh = "pa28_light.b3d", textures = { diff --git a/init.lua b/init.lua index 7cda764..6da0a63 100755 --- a/init.lua +++ b/init.lua @@ -55,15 +55,15 @@ end function pa28.step_additional_function(self) --position lights if self._engine_running == true then - self.lights:set_properties({textures={"pa28_l_light.png^pa28_l_light.png","pa28_l_light.png","pa28_r_light.png"},glow=15}) + self.lights:set_properties({textures={"pa28_l_light.png^pa28_l_light.png","pa28_l_light.png","pa28_r_light.png"},glow=15,light_source=8}) else - self.lights:set_properties({textures={"pa28_l_light.png","pa28_l_light.png","pa28_r_light.png"},glow=0}) + self.lights:set_properties({textures={"pa28_l_light.png","pa28_l_light.png","pa28_r_light.png"},glow=0,light_source=0}) end if self._land_light == true then - self.light:set_properties({textures={"pa28_landing_light.png"},glow=15}) + self.light:set_properties({textures={"pa28_landing_light.png"},glow=15,light_source=8}) else - self.light:set_properties({textures={"pa28_metal.png"},glow=0}) + self.light:set_properties({textures={"pa28_metal.png"},glow=0,light_source=0}) end if (self.driver_name==nil) and (self.co_pilot==nil) then --pilot or copilot ```