Closed joseph-kaile closed 9 months ago
@joseph-kaile can you please open a PR for the cesium-native changes as well? It looks like there will be two, one into main and one into v0.27.x.
Joseph's code in this PR is solid, but it only applies the texture transform to the "baseColorTexture". I extended it to work with all the other textures, too. And added support for texture rotation, so that I could use @emackey's awesome TextureTransformMultiTest glTF to validate it. It seems to be working well:
The occlusion test passes, too, it's just a bit hard to see:
(Note that I had to turn off "Static Lighting" in the Project Settings in order to make Unreal render the occlusion texture at all.)
Now that I've worked on this, someone else should review and merge it. It depends on CesiumGS/cesium-native#799 so merge that first.
This looks great to me @kring. I'm pushing a few commits to fix an unrelated test failure, and also some cleanup in the material graph. (No nodes added or removed, just reorganized for visual clarity).
I have one concern about the image you posted: I'm seeing a discrepancy between the "Sample" normal textures and the transformed ones.
It almost looks like the normals are completely reversed from the sample ones, even though they're supposed to be the same. But I wasn't able to verify it myself because I didn't know how to get the glTF into the scene. In the end it does seem like the texture coordinate transformations were correct, and maybe the output is somehow being interpreted wrong, but I'm not 100% sure.
Sharp eyes @j9liu. I'm seeing some similar results in Blender, but not in BabylonJS and others. My initial hunch is that there's disagreement as to whether rotating a normal map also rotates the TBN matrix, or if rotating it just influences the UV coordinates only. This probably needs a bit more investigation and possibly a new sample model to test it. But it seems likely unrelated to this PR.
Yeah I think that's even visible in the glTF Sample Viewer @emackey:
FWIW, the way I've implemented it in Unreal, KHR_texture_transform
affects the texture coordinates only.
Same as https://github.com/CesiumGS/cesium-unity/pull/385 but in Unreal.