-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
In lighting, always normalize zero to (0, 0, 1) #14231
Conversation
I wonder if that SSE4 path is really worth it. But probably doesn't matter much. |
Well, it was already there from #11425, I just figured might as well use it more places since it's there anyway. -[Unknown] |
Yeah, I know, just wondering out loud. |
@@ -1056,7 +1062,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag | |||
break; | |||
case GE_PROJMAP_NORMALIZED_NORMAL: // Use normalized transformed normal as source | |||
if (hasNormal) | |||
temp_tc = flipNormal ? "vec4(normalize(-normal), 1.0)" : "vec4(normalize(normal), 1.0)"; | |||
temp_tc = StringFromFormat("length(%snormal) == 0.0 ? vec4(0.0, 0.0, 1.0, 1.0) : vec4(normalize(%snormal), 1.0)", flipNormal ? "-" : ""); |
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.
@unknownbrackets I think the bug is here. Two %s but one parameter.
You don't really need the sign in the length check anyway...
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.
Oops, I don't think I intended to have it twice. Bah.
-[Unknown]
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.
It's kinda ridiculous that this compiles. (I mean, I know why, but ... )
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.
Makes me miss D where this wouldn't. I'm sure rust has something similar.
-[Unknown]
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.
Indeed, this would break with Rust formatting macros.
Fixes #14167. We've seen several cases of this now, so I think it's better to just assume it's the case for all normalize usage.
-[Unknown]