bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add support for KHR_texture_transform

Open yrns opened this issue 2 years ago • 6 comments

Objective

Support the KHR_texture_transform extension for the glTF loader.

  • Fixes #6335

Solution

As is, this only supports a single transform. Looking at Godot's source, they support one transform with an optional second one for detail, AO, and emission. glTF specifies one per texture. The public domain materials I looked at seem to share the same transform. So maybe having just one is acceptable for now. I tried to include a warning if multiple different transforms exist for the same material.

Note the gltf crate doesn't expose the texture transform for the normal and occlusion textures, which it should, so I just ignored those for now.

Via cargo run --release --example scene_viewer ~/src/clone/glTF-Sample-Models/2.0/TextureTransformTest/glTF/TextureTransformTest.gltf:

texture_transform

Changelog

Support for the KHR_texture_transform extension added.

yrns avatar Mar 30 '23 19:03 yrns

Your PR increases Bevy Minimum Supported Rust Version. Please update the rust-version field in the root Cargo.toml file.

github-actions[bot] avatar Mar 30 '23 19:03 github-actions[bot]

message above is due to a network error on crates.io

mockersf avatar Mar 30 '23 22:03 mockersf

Your screenshot doesn't look exactly like the expected (https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureTransformTest), it seems the background for out of texture quads are not the same. Do you know why?

How would it work with https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureTransformMultiTest?

mockersf avatar Mar 30 '23 22:03 mockersf

Your screenshot doesn't look exactly like the expected (https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureTransformTest), it seems the background for out of texture quads are not the same. Do you know why?

The default camera and lighting in the scene viewer make it hard to see. The background in the arrow texture is there, just very faint, if that's what you mean.

How would it work with https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureTransformMultiTest?

multi_transform

This looks far from complete because the loader doesn't support texture coord sets. I see there's some TODOs in the source code. The renderer doesn't do clearcoat, and the gltf crate doesn't expose a texture transform for occlusion.

yrns avatar Mar 31 '23 01:03 yrns

A Affine2 seems better (smaller and faster) for the transform than a Mat3?

mockersf avatar Aug 20 '23 13:08 mockersf

Hi… Any update on this??

hchockarprasad avatar Feb 11 '24 12:02 hchockarprasad

Closes #11869

janhohenheim avatar Feb 15 '24 06:02 janhohenheim

Adopted; I'm currently updating this PR to main and addressing the comments on my fork :)

janhohenheim avatar Feb 16 '24 16:02 janhohenheim

Done, just got some questions on the new PR

janhohenheim avatar Feb 16 '24 18:02 janhohenheim

Closing as adopted :)

alice-i-cecile avatar Feb 16 '24 22:02 alice-i-cecile