-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for light intensity and color at night and day #14091
base: master
Are you sure you want to change the base?
Conversation
a0a30f4
to
cbcfa1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only went through the DOCS. It'd be also nice having some pictures or a small video
78d8b63
to
ecd7eb7
Compare
@appgurueu @Zughy Fixes, feedback applied, rebased, and a small video added (to PR itself). |
423525e
to
1de2312
Compare
1de2312
to
5a9c097
Compare
Rebased, merged to one commit, and cleaned Lua code |
40144a3
to
4b3ed11
Compare
4b3ed11
to
60d1927
Compare
I've made some testing of this feature. I assume it actually should depend now on #14789 as it repairs generally applying any colorful light values to the common vertex light color and this PR is not an exception also. At the set single-channel color offsets the devtest player model gets fully dark. It happens on adjusting the red and blue channels: The particles are not affected by the sunlight color at all with any combinations of the offsets and coefficients: The color of the nodes going with such paramtype2 as |
src/lighting.h
Outdated
* sunlight->b = colorOffset_rgb.Z+colorRatioCoef_rgb.Z*daynight_ratio; | ||
* | ||
*/ | ||
struct LightIntensity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be renamed to SkyLight
for the same reason mentioned above.
src/script/lua_api/l_object.cpp
Outdated
if (lua_istable(L, -1)) { | ||
lua_getfield(L, 3, "color_offset"); | ||
if (lua_istable(L, -1)) { | ||
lighting.lightIntensity.colorOffset_rgb.X = getfloatfield_default(L, -1, "r", lighting.lightIntensity.colorOffset_rgb.X); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a some reference to the structure like LightIntensity &sky_light = lighting.lightIntensity
to avoid writing overly long lines. Also, I think it is worth to remove _rgb
suffix since it is pretty clear this is RGB format by judging the storing only 3 float values (v3f).
@@ -1815,4 +1815,12 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt) | |||
} | |||
if (pkt->getRemainingBytes() >= 4) | |||
*pkt >> lighting.volumetric_light_strength; | |||
if (pkt->getRemainingBytes() >= 24) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth to change the check for the bytes availability in the packet doing it similar with https://github.com/minetest/minetest/pull/14343/files#diff-592338f1bfb0275512da218625ce67e993b91984c175f70fe376825ab4e0aad2R1804
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the normally used style.
I will change it in the rebase after PR #14343 is merged.
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., | |||
#include "util/directiontables.h" | |||
#include "client/meshgen/collector.h" | |||
#include "client/renderingengine.h" | |||
#include "client/localplayer.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why localplayer is included here ? we should not have player inclusion on mapblock_mesh, which is close to render and has nothing to do with player session/object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the light setting is stored in the local player.
No affected particles are a bug. I will check it. When texture without red color is shown as black in the light which does not include the red part, it is not a bug. This PR should affect only the color of sunlight, not the color of light from artificial light sources. |
60d1927
to
e4c4c8a
Compare
e4c4c8a
to
b03c4b0
Compare
09a54f8
to
a4bb71d
Compare
Rebased, sky color is applied also to particles. |
Add compact, short information about your PR for easier understanding:
get_sunlight_color
function, so no constants are used for sun color calculation, but configurable parameters.To do
This PR is Ready for Review.
How to test
Run game devtest and run command
set_light_intensity
from lighting mod.Screen.Recording.2024-01-02.at.17.47.51_480.mov