Skip to content
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

BasisTextureLoader example: the texture is rendered upside down #19797

Closed
WestLangley opened this issue Jul 5, 2020 · 4 comments · Fixed by #21094
Closed

BasisTextureLoader example: the texture is rendered upside down #19797

WestLangley opened this issue Jul 5, 2020 · 4 comments · Fixed by #21094
Labels

Comments

@WestLangley
Copy link
Collaborator

... So the issue is: how to apply a .basis texture to a three.js built-in geometry.

/ping @zeux
/ping @takahirox
/ping @donmccurdy

  • [ x ] r118
@donmccurdy
Copy link
Collaborator

donmccurdy commented Jul 5, 2020

All three.js built-in geometries have UVs matching our default of texture.flipY = true. That default doesn't apply to compressed textures, so using the built-in geometries with compressed textures will require one of:

a. changes to the texture before compression
b. changes to the UVs
c. changes to the UV transform

In one case I've used a function like this:

    /** Invert UVs to be compatible with `flipY=false` textures. */
    function flipY ( geometry ) {

      var uv = geometry.attributes.uv;

      for ( var i = 0; i < uv.count; i ++ ) {

        uv.setY( i, 1 - uv.getY( i ) );

      }

      return geometry;

    }

This would apply to .basis, .ktx,, and any other compressed texture format, if the texture author has not already flipped the texture. The same issue also comes up when using ImageBitmapLoader on Firefox, which doesn't support the flipY ImageBitmap option, I think.

@mrdoob mrdoob added this to the rXXX milestone Jul 27, 2020
@WestLangley
Copy link
Collaborator Author

https://threejs.org/examples/webgl_loader_texture_basis.html

Maybe this example should have a block of code that implements "fixing" the UVs, and use a texture that has an obvious right-side-up.

@WestLangley
Copy link
Collaborator Author

@donmccurdy Thanks!

@forcepusher
Copy link

In case anyone bumps into this in the future:
You could specify the -y_flip argument when building a basis texture and use everything as is.
See more info on basisu CLI arguments here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants