-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add PI
, TAU
and E
constants to the shader language (3.x)
#52315
Conversation
3c7710c
to
1810df8
Compare
PI
, TAU
and E
constants to the shader languagePI
, TAU
and E
constants to the shader language (3.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.
Looks good! Just need to add it to GLES2 as well!
Is there any other standard name for the constant E? i.e. could we 'longify it' in some way? It just struck me that in some situations it could be a pain as this is global namespace, and if you were trying to convert a shader which used capitalized variable e.g. A, B, C, D, E etc, it could be an annoyance. Maybe I'm overthinking it though. 🤔 |
@lawnjelly Unfortunately it's hard to lengthen it without sounding awkward. Are |
While I think a global |
1810df8
to
d43e5c5
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.
Looks good!
I am a little worried about breaking user's shaders when they use the E
constant. I've seen a lot of users copy-paste the following code for the "Uncharted 2 Tonemapping function"
float A = 0.15;
float B = 0.50;
float C = 0.10;
float D = 0.20;
float E = 0.02;
float F = 0.30;
float W = 11.2;
vec3 Uncharted2Tonemap(vec3 x)
{
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
Given that shader programming often favours short variable names, I'd wager that more than a few users are already using E
in their code and adding the global define will break their code.
That being said, the error message is helpful (if they can just track down which shader is resulting in the error)
My gut is telling me to err on the side of caution and not risk breaking user code in the 3.x branch.
|
It's been awhile since I posted my comment, now I think |
71cb8d3
to
c58391c
Compare
At this stage, I'm not sure we should bother adding this kind of convenience features to the I'm not opposed to it either, but generally speaking we still have a lot of feature PRs targeting |
I tend to agree, this change will break at least a few users shaders and will provide only a slight QoL improvement. |
One option is to add |
Yeah, for Personally, I still don't think it is worth the annoyance. But if there is demand from users than we can definitely consider adding |
Just to give a concrete example, the In orbital mechanics, 'E' has a conventional meaning (different than 'e'). Although it violates variable capitalization convention, we prioritize orbital mechanics convention in specific math functions in our code (including in shaders):
I suppose this is a done deal for 4.0? I might open a proposal to change but I'm not sure if my edge case is worth anyone's time... |
Yes, this is a done deal for 4.0 unfortunately. Sorry to hear that this will break your team's shaders. Feel free to open a proposal, but know it would be targeting Godot 5.0 |
Closing per the above comments due to concerns with compatibility. |
3.x
version of #48837.Preview