You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
Some effects can benefit from being done in either linear or srgb space. In addition, not all cases of needing a linear or srgb color result/input are handled by the source_color. Mainly color constants or literal color vectors.
The srgb <-> linear conversion functions used by godot's shaders could easily be copied and/or imported into shaders, but it's very hard for a user to find this code or formula.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Provide the existing srgb_to_linear and linear_to_srgb functions as built-in functions to godot shaders.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
vec3 linear_to_srgb(vec3 color) {
// If going to srgb, clamp from 0 to 1.
color =clamp(color, vec3(0.0), vec3(1.0));
constvec3 a =vec3(0.055f);
returnmix(
(vec3(1.0f) + a) *pow(color.rgb, vec3(1.0f /2.4f)) - a,
12.92f * color.rgb,
lessThan(color.rgb, vec3(0.0031308f))
);
}
vec3 srgb_to_linear(vec3 color) {
returnmix(
pow((color.rgb +vec3(0.055)) * (1.0/ (1.0+0.055)), vec3(2.4)),
color.rgb * (1.0/12.92),
lessThan(color.rgb, vec3(0.04045))
);
}
If this enhancement will not be used often, can it be worked around with a few lines of script?
If you know where to look you can find these, but it's a pretty basic feature that shouldn't be this hard to find.
Is there a reason why this should be core and not an add-on in the asset library?
It's already in the core shaders, just needs to be provided to user shaders.
The text was updated successfully, but these errors were encountered:
Adding built-in functions to the shader language that have no GLSL counterpart is a difficult proposition. See godotengine/godot#77239 (comment) which was rejected in the past.
Adding built-in functions to the shader language that have no GLSL counterpart is a difficult proposition. See godotengine/godot#77239 (comment) which was rejected in the past.
I don't disagree with the points made in 77239 but I'm not sure if there's an easy alternative solution like there was for that. Perhaps adding the code as an example into the documentation could help? Doesn't sound like a good approach going forward either, and I'm not sure how someone is supposed to be able to find out how to do this otherwise. (Speaking from experience it's very hard to figure out exactly what the math is for the conversion, even after looking through search results)
The fact that godot will automatically do this for your color uniforms but doesn't let you do it for consts (no hints) makes this feel like a missing feature.
Oh, looks like this also isn't the first time adding extra functions anyway godotengine/godot#43886
documented here
Describe the project you are working on
Shaders, especially particle and other effects
Describe the problem or limitation you are having in your project
Some effects can benefit from being done in either linear or srgb space. In addition, not all cases of needing a linear or srgb color result/input are handled by the
source_color
. Mainly color constants or literal color vectors.The srgb <-> linear conversion functions used by godot's shaders could easily be copied and/or imported into shaders, but it's very hard for a user to find this code or formula.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Provide the existing
srgb_to_linear
andlinear_to_srgb
functions as built-in functions to godot shaders.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
If you know where to look you can find these, but it's a pretty basic feature that shouldn't be this hard to find.
Is there a reason why this should be core and not an add-on in the asset library?
It's already in the core shaders, just needs to be provided to user shaders.
The text was updated successfully, but these errors were encountered: