Minimum Viable Monochromatic Lights#24428
Open
coreh wants to merge 5 commits into
Open
Conversation
MyCodingSpace5
pushed a commit
to MyCodingSpace5/bevy
that referenced
this pull request
Jun 2, 2026
# Objective While testing bevyengine#24428, I realized the `rgb_to_hsv` function can return negative hues, eg `rgb_to_hsv(vec3(1.0, 0.0, 1.0))` returns `(-1.0472, 1.0, 1.0)`. ## Solution For colors where `(swizzle.x - swizzle.y) / c + swizzle.z` is negative, `negative % 6.0` stays negative. I replaced `x % 6.0` with `fract(x / 6.0) * 6.0`, which is always positive. ## Testing - Ran the shader from a test script for a couple colors. The function is pretty much unused, it currently only gets called when `ColorGradingGlobal.hue` is set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: This PR has been extracted from #14822, with the goal of making it easier to review and hopefully merge by splitting off some potentially contentious parts (e.g.
SpectralColor) and also since some areas will require more work (e.g. ambient light support: we'll need to add ambient light bitflags and to figure out how to properly interact with with irradiance volumes, etc.)Related PRs: #24447
Objective
Solution
SpectralModelenum tobevy_camera, to allow selecting between the “traditional” Tristimulus rendering or Tristimulus + Monochromatic LightsmonochromaticflagtoSpotLight,PointLightandDirectionalLightcomponentsMeshPipelineKey::MONOCHROMATIC_LIGHTSflag andMONOCHROMATIC_LIGHTSshader defPOINT_LIGHT_FLAGS_MONOCHROMATIC_BITandDIRECTIONAL_LIGHT_FLAGS_MONOCHROMATIC_BITWGSL constantsmonochromatic_response()WGSL function, that approximates response of the base color to monochromatic light via a simple HSV + triangle function gaussian approximationNotes
SpectralColortype from Spectral Color Lighting #14822, which I will also extract in a separate PR and link from hereTesting
Showcase