This issue serves as a document/discussion regarding how colored light works.
Definitions:
With channel I mean one channel or RGB light - that is either R, G, or B.
Light values are always assumed to be a float value between 0 and 1. 0 would be lightlevel 0, and 1 would be lightlevel 15. Floating point because of smooth light interpolation for each pixel.
The lightmap is a vanilla feature that contains the current light value for each blocklight/skylight combination. Minecraft also handles nightvision, lightning strikes and daytime by changing the lightmap.
Basic overview:
The basic approach of the mod is to run light calculation 4 times, one for vanilla, and for each RGB channel. A bit compute itensive, but very vanilla friendly. I don't see a better approach for "real" colored lighting.
All color information is seperated form vanilla, so you can easily remove/add the mod without light glitches. Hurray for compatibility!
Additionally, there's a color list for light emitting blocks to set the color of the light they emit. For blocks not in the list, light is assumed to be white.
Colored light can also be filted though stained glass, Both sky and block light can be filtered like this.
Caveats:
Since each channel is between 0-15, there are a few unfixable issues:
"Decay of light color": Assume a block source with color RGB(15, 7, 0). After 7 blocks we have RGB(8, 0, 0). This means light turned from orange into red. Ooops.
Priority of white: Assume two light sources with color RGB(15, 15, 15) and RGB(15, 0, 0). Due to each channel being on its own, the mixed version is the combination of the maximums for each channel, that is RGB(15, 15, 15). The red is overridden by white.
Technical details:
We want to keep using the lightmap - since that is used for nightvison/lightning strike effects - and also handles sky light dependent on weather/day time. Not using the lightmap would be a huge PITA, so we need that. Plus, could help lamdbdynamiclight compat, but that's for the future.
The shaders get two light values for each channel, indicating strength of blocklight/skylight for that channel.
Additionally we get the two lightvalues for the vanilla minecraft light level, that is, vanilla blocklight / skylight.
The question, how do we want them mixed together...
I could have each channel go into the lightmap, basically ignoring the vanilla light level.
Drawback: No separation between block/skylight. SKY(15, 15, 15) and BLOCK(15, 0, 0) give white.
Use vanilla light values to get brightness for block like normally. Then multiply with the color, calculated with the following formula:
// In the night, sky light also needs less influence on color
sky_current_strength = value from lightmap with 0 blocklight, 15 skylight
sky_strength = sky_current_strength * sky_light_value_vanilla
block_strength = block_light_value_vanilla
// The lower the vanilla light strength, the less influence the color of the light has
sky_factor = sky_strength / (sky_strength + block_strength);
block_factor = sky_strength / (sky_strength + block_strength);
color = block_rgb * block_factor + sky_rgb * sky_factor
Drawback: Complicated, will yield absolute black when there is no light at all. Also makes blocks darker when placing an additional light source, e.g. glowstone.
Problem
I'd love to have both skycolor/block color mixing (solutions 2) and no absolute black at night. And blocks to not go dark when placing glowstone... Ideas on how to improve mixing?
If the document isn't easy enough to understand or unclear, please let me know!
This issue serves as a document/discussion regarding how colored light works.
Definitions:
Basic overview:
The basic approach of the mod is to run light calculation 4 times, one for vanilla, and for each RGB channel. A bit compute itensive, but very vanilla friendly. I don't see a better approach for "real" colored lighting. All color information is seperated form vanilla, so you can easily remove/add the mod without light glitches. Hurray for compatibility! Additionally, there's a color list for light emitting blocks to set the color of the light they emit. For blocks not in the list, light is assumed to be white. Colored light can also be filted though stained glass, Both sky and block light can be filtered like this.
Caveats:
Since each channel is between 0-15, there are a few unfixable issues:
Technical details:
We want to keep using the lightmap - since that is used for nightvison/lightning strike effects - and also handles sky light dependent on weather/day time. Not using the lightmap would be a huge PITA, so we need that. Plus, could help lamdbdynamiclight compat, but that's for the future.
The shaders get two light values for each channel, indicating strength of blocklight/skylight for that channel. Additionally we get the two lightvalues for the vanilla minecraft light level, that is, vanilla blocklight / skylight.
The question, how do we want them mixed together...
Use vanilla light values to get brightness for block like normally. Then multiply with the color, calculated with the following formula:
Drawback: Complicated, will yield absolute black when there is no light at all. Also makes blocks darker when placing an additional light source, e.g. glowstone.
Problem
I'd love to have both skycolor/block color mixing (solutions 2) and no absolute black at night. And blocks to not go dark when placing glowstone... Ideas on how to improve mixing? If the document isn't easy enough to understand or unclear, please let me know!