Comments (12)
#43 is merged now, with a bunch of things on top like trivial import of multi-primitive meshes and mesh name import. I'm now in the middle of implementing real support for multi-primitive meshes, current status is this:
After that I'll focus on additional mesh and material properties.
from magnum-plugins.
I think I've read that on KhronosGroup/glTF#674
Try the TextureCoordinates
glTF sample to make sure.
from magnum-plugins.
my bad i didn't see the PR ! that's great !
from magnum-plugins.
@steeve I did some investigation regarding texture coordinate Y flipping today in order to deconfuse myself.
The theory:
-
OpenGL conventions are that the first data row is at Y coordinate 0, which is at the bottom.
-
WebGL spec says the following for
texImage2D()
andtexSubImage2D()
that takesTexImageSource
as parameter:The first pixel transferred from the source to the WebGL implementation corresponds to the upper left corner of the source. This behavior is modified by the the UNPACK_FLIP_Y_WEBGL pixel storage parameter.
This seeming difference (which is apparently only in case of TexImageSource
, to my understanding) leads to extremely long threads full of extremely confused comments on many Khronos glTF repos.
The practice:
- Both OpenGL and WebGL behave exactly the same in my testing (and it also always behaved like that). If I enable
UNPACK_FLIP_Y_WEBGL
, then I get flipped images on web compared to desktop. Apparently the spec above is just forTexImageSource
and since Emscripten is passing a rawArrayBuffer
there, the convention is upper left as in OpenGL and so I didn't ever experience any differences. - In order to accomodate for OpenGL (and WebGL) conventions, I'm flipping all images on load.
- glTF, for some unknown reason, chose to go against the common OpenGL conventions and specifies the origin as upper left. All tools now accomodate for that and flip Y texture coordinate. As far as I understood from the extremely long threads, this changed in summer 2017 (glTF 2.0 was meant to follow GL specs, but then they reverted back to what 1.0 had to avoid breaking existing implementations and models and ... or some such thing?)
- Just to verify everything again for the 100th time, I tried to export a simple textured model from Blender as both OBJ and glTF. OBJ matches the expectations and origin is bottom left. glTF has the coordinates flipped.
So the glTF importer will be flipping Y (the same as you do) in order to have the same behavior as everything else in the engine. And that'll be part of #43 as well.
from magnum-plugins.
We did a very dirty workaround because apparently webgl textures have top-left origins, while opengl has bottom-left, so, to fix the texture coordinates:
for (auto &tc : textureCoordinates) {
tc = Vector2(tc.x(), -tc.y());
}
from magnum-plugins.
@mosra Outch, sorry about that! The code in question was my fault, it came in with the recent fixes. I remember we originally had the mesh loading right (as in using the accessors correctly), so I broke that with those changes. I should not have relied on the test cases alone (did admittedly not actually try loading a mesh and looking at that with the viewer).
I have time over the weekend and will fix this (There is a WebXR jam kinda thing coming up anyway for which I'll need it, so I need this fixed myself, too). You have better things to do 😉
from magnum-plugins.
@Squareys thanks!
Not sure about the texture coordinates, though: in my experience there was no difference in WebGL compared to desktop GL (that would cause all text-related webgl examples to look flipped, I think, but they aren't). We're doing some image flipping on import to match GL, so maybe there's some issue with it (being flipped twice or not at all).
from magnum-plugins.
While you're at it @Squareys, can you check for this?
Trade::TinyGltfImporter::mesh3D(): unsupported mesh vertex attribute TANGENT
A lot of meshes found on the web use that, for the record.
from magnum-plugins.
@steeve Sure, I put that there, what about it? Magnum does not support tangents, so it ignores them and produces this warning. That should not be an issue, I hope... although it would be nice to be able to import those, of course.
(@mosra Should I add support for tangents in MeshData3D
while I'm at it? Skin weights also?)
from magnum-plugins.
For the record: I'm now working on redesigning MeshData to support tangents, vertex weights, custom attributes and other things. It will materialize as part of mosra/magnum#240.
from magnum-plugins.
hey guys, where are we with this ?
cheers !
from magnum-plugins.
For the record, two years and one apocalypse later, with mosra/magnum#371 and 1cc6b4e TinyGltfImporter
supports tangent attributes as well as a ton of other stuff.
from magnum-plugins.
Related Issues (20)
- AssimpImporter: Should normalize filepaths for external image paths HOT 1
- Static analyzer warning about variable used before initialization in TinyGltfImporter HOT 2
- Unable to install magnum-plugins.deb on Linux Mint 20.2 HOT 3
- KTX2 + Basis Universal HOT 4
- Attentuation for Directional/Sun Lights when importing Blender files HOT 3
- Wrong line ending normalization under Windows due to typo in .gitattributes HOT 1
- AssimpImporter: Embedded textures fail to load with FBX HOT 2
- meshoptimizersceneconverter build failed because meshoptimizer has updated HOT 1
- GltfImporter: spot light with outer angle of 90° produces error HOT 4
- Build Server Configuration Issue. HOT 10
- DrWavAudioImporterTest: cmake error when CORRADE_BUILD_STATIC=ON and BUILD_PLUGINS_STATIC=OFF HOT 2
- vcpkg does not work properly due to lib files not copied to the installed folder HOT 2
- CMake error (missing: AnyImageImporter) HOT 6
- Update Basis Universal plugin for UASTC HOT 4
- FindMagnumPlugins.cmake interaction with Assimp HOT 4
- AssimpImporter crashes on gltf/glb in wasm builds HOT 9
- Updating the basis plugin importer HOT 1
- Compile issues on osx HOT 4
- Expose Configuration Value implementation for Trade::BasisImporter::TargetFormat HOT 4
- Find modules have issues with paths containing spaces HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnum-plugins.