-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
texture() ignoring uvs for .obj file #4866
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already. |
Hi! I know that the UVs are parsing correctly with some files but maybe there is a need to compare the UV parsing here to what is done in Processing to provide greater support. Anyone is welcome to take a look. |
So I figured out that the y values for the uvs are inverted. It's possible to reverse them like so: for(let i=0; i< mod.uvs.length; i++) {
mod.uvs[i][1] = 1.-mod.uvs[i][1];
} And this fixes the problem. See updated sketch: https://editor.p5js.org/kbrowne/sketches/o_PYbAgLl This leaves open the question of why uvs appear to be parsed correctly for the file @stalgiag mentioned. But the equivalent code in p5 looks like this: So it seems like p5 and processing are using the uv y values inversely. |
Thank you @kieranbrowne! I think we should follow Processing on this. It appears that the lower-left pixel is |
Hello, Line 226 in c1640a7
where the texVertex should theoretically be the same with 1 - V inversion for the second coordinate: Who is willing to patch and test this? I have never built p5js's main .js file yet |
Testing this as WebGL requires a flipped/inverted V texture coordinate
The added PR is ready for testing |
Here is a duplicated arm scene with a patched p5.js (uncompressed so 3.7MB) However, the capsule example with that patched p5.js file leads to a vertically flipped UV mapping visually: Maybe we should all take care of how we export our .OBJ files... Blender3d's OBJ exporter for example allows to flip the forward and upward axes:
Here is the related source in Processing (java), which states even in its preceding code commenting that the V values are inverted:
So unless OpenGL and WebGL differ in behaviour and V x Y axes directions, I think that p5.js should follow Processing's behaviour and invert the V values... |
#4866 V texture coordinate inversion on OBJ loadModel
closed with #5017 |
Hi there,
I'm trying to import a basic 3d .obj file and texture into p5js, but the texture appears to be ignoring the uv information in the obj file and misplacing the texture. I've written the equivalent program in processing 3 and it display correctly, so I can be pretty sure it's not an issue with the obj and texture files.
Am I doing something silly, or is this a genuine bug?
Most appropriate sub-area of p5.js?
Details about the bug:
The p5 code with all the necessary assets can be found here: https://editor.p5js.org/kbrowne/sketches/o_PYbAgLl
And here is the equivalent processing 3 code which textures correctly:
The text was updated successfully, but these errors were encountered: