-
Notifications
You must be signed in to change notification settings - Fork 38
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
my Model stands head #3
Comments
Did you confirm that the model is displayed properly in other viewers (for example: Blender or MeshLab)? Or can you upload/provide the model, so that others could check it? Regarding the second question: I'm not sure whether I understood this right, but you usually pass in 2 as the (In OBJ, texture coordinates could have 1 or 3 dimensions as well, and although I never encountered this, I wanted to have it covered, just in case). |
Thanks for the fast answer. |
So in this case, it is almost certainly not the model that is flipped, but only the texture. Unfortunately, flipped textures are distressingly common - Google "texture flipped vertically bug" brings maaany results, and things like
show that this always causes trouble in the Blender/OBJ/OpenGL chain. I think the main reason is in the way how OpenGL handles textures and texture coordinates, but more about this can be read in a recent issue from glTF: KhronosGroup/glTF#1021 However, there are several options for solving this:
In fact, this issue is so common and so annoying that I'd rather consider adding special versions of the |
Here are some pictures. Maybe you see the issue. Thank you for your support :) |
It's hard to be sure about this just from the images. But again, I guess it's just the usual y-flip. In this case, you could try to apply this function
(Updated based on the fixes discussed below) to your texture coordinates, like this:
(if you're obtaining them as an array, you can just pass a If this fixes the issue, I'll consider adding methods that do this transparently, as in
for the next release. |
I will try and give info :) do not wonder the chalice is pretty ugly, it was just for testing. |
your method does not work for me - "IndexOutOfBoundException". My model is textured correct in my game now. I just added a minus in front of the y coordinate ("vt") manually and now it looks like textured correct, but i do not know why .. is it interpretated as 1.0f-y because negative UV-coords? |
Sorry, the
(Updated based on the fixes discussed below) The fix that you described most likely works "accidentally", because of a certain texture wrapping mode: https://webglfundamentals.org/webgl/webgl-3d-textures-repeat-clamp.html This will not work in all cases. |
one last thing: thank you very much :) |
Yes, I should have tested this properly locally, instead of just sketching the code here. Sorry about that. So eventually, this should work:
I'll leave this issue open until I decided whether or how to integrate the optional flipping in the |
I've been hesitating a bit here. This "texture coordinate flipping" is actually only a workaround: Most image loaders provide the image data with the first pixel being at the upper left. OpenGL assumes that the first pixel is at the lower left. (For whatever reason. I mean, they really screwed this one up, didn't they?). So the "cleanest" solution would usually be to flip the image data, so that it matches the expectation of OpenGL. However, even if the texture coordinates are supposed to be flipped, I wasn't sure whether it would be more appropriate to do this via an optional/additional parameter, like this:
or whether to offer a However, the next release will have the |
The new method for obtaining the texture coordinates with flipped y-coordinates is part of version 0.3.0:
|
Hi,
thank you for your Loader. Works fine,
but:
maybe you have an idea why my model stands head.
I am using the plain arrays from the ObjFile.
Another question would be: the parameter dimensions in the ObjData.getTexCoordArrays(obj, dimension) is for the format of my Texture Coordinates (in my case 2).
Thank you very much!
The text was updated successfully, but these errors were encountered: