-
Notifications
You must be signed in to change notification settings - Fork 28
IR-10191 mt stg studio flips green channel on normal maps #2007
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
IR-10191 mt stg studio flips green channel on normal maps #2007
Conversation
…s to avoid override
@HexaField We need to switch from using computeTangents() to MikkTSpace because computeTangents() breaks how our normal maps are imported—especially with GLTF files that use OpenGL-style tangent space. When we delete tangents for merging and use computeTangents(), the resulting tangents don't include the correct handedness (w component), which leads to flipped or incorrect lighting when using a normalScale of (1, 1) (which we choose for included tangents). ThreeJS even states that if we are going to calculate the Tangents we must flip the green channel. Currently with or without tangents we are computing the tangents. This mismatch causes normal maps that should work out of the box to render incorrectly appearing inverted. MikkTSpace solves this by generating tangents that match the standard expected by GLTF exporters and is recommended by Threejs to use. The current quick bandaid fix would be to always have the normal scale flipped for all gltfs. Another way to get around this is to not delete tangents and comment out this code: https://github.com/ir-engine/ir-engine/blob/dev/packages/spatial/src/common/classes/BufferGeometryUtils.ts#L104 I tested that on many scenes and didnt find a problem but may be a super niche edge case where it would fail. Currently this problem is only with gltfs that have tangents |
…t them. adds check for primitives for normalScale assignment.
…10191-MT-STG-Studio-flips-green-channel-on-normal-maps
…10191-MT-STG-Studio-flips-green-channel-on-normal-maps
…10191-MT-STG-Studio-flips-green-channel-on-normal-maps
…ps' of https://github.com/ir-engine/ir-engine into IR-10191-MT-STG-Studio-flips-green-channel-on-normal-maps
Summary
Subtasks Checklist
Breaking Changes
References
https://tsu.atlassian.net/browse/IR-10191
QA Steps
Add normal mapped gltf attached in ticket to a new scene.
Observe that the normal maps on the small quad display correctly