0
\$\begingroup\$

I'm loading a simple model, which is composed of vertices that have position, normal and UV texture coordinates.

The thing is, displaying that model using DirectX 9 or 10 shows that the UV coordinates are wrong. In fact, if I manually edit the texture using Paint and flip it vertically, the result is ok.

Is something wrong with my loading routines? Using Visual Studio Graphics Debuggers shows that both the model and the texture are correctly loaded.

Do I have to flip the texture vertically when I load it, or just transform the UV coords with:

u = u;
v = 1 - v;

Also, as far as I know, OpenGL differs from Direct3D for the UV coordinates system. Would those coordinates be ok with OpenGL without any transformation?

\$\endgroup\$
  • \$\begingroup\$ By default images are stored from top to down in memory. Yes, you have to flip every image (at least for openGL). \$\endgroup\$ – wondra Jul 27 '14 at 17:56
  • \$\begingroup\$ This is an issue of face winding order. The UVS on the model are using one (Counter-clockwise or Clockwise) and the renderer is set up to use the opposite one. \$\endgroup\$ – Chuck Walbourn Jul 30 '14 at 2:47
  • \$\begingroup\$ Sorry, winding would show up as a flip in U rather than a flip in V... I ran into this issue with CMOs (Right-handed models) vs. SDKMESH (Left-handed models). \$\endgroup\$ – Chuck Walbourn Jul 30 '14 at 3:48
1
\$\begingroup\$

Transforming uv coordinates should be good enough. You could do it while loading your model, or even in a shader.
Whether the texture is upside-down in memory is irrelevant for performance when sampling the texture.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.