Advertisement

Textures in Directx 11

Started by August 13, 2017 03:02 PM
5 comments, last by terrysworkstations 7 years, 3 months ago

Im in DirectX 11 using the D3DX11CreateShaderResourceViewFromFile for textures. I have to rotate texture file 180 and flip horizontal in Mspaint for the texture to fit on the object.  SO when I have a .obj object with text, it will be backwards like in the image. I have to rotate and flip with all objects that have textures.Does anyone know how to fix the issue?

Untitled.png

Your UV coordinates in your mesh are flipped ( U coordinate ).

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Advertisement

I use the regular image now(not rotated or flipped), and negated the x. Did not work though. I negated the y uv and almost works accept as seen, the text is backwards.

 

Untitled.png

from, http://www.rastertek.com/dx11tut08.html,

Quote

Right hand to Left hand conversion

By default Maya 2011 is a right handed coordinate system and exports the .obj file data in right hand coordinates. To convert that data into a left handed system which DirectX 11 is by default you have to do the following:

1. Invert the Z coordinate vertices. In the code you will see it do this: vertices[vertexIndex].z = vertices[vertexIndex].z * -1.0f;

2. Invert the TV texture coordinate. In the code you will see it do this: texcoords[texcoordIndex].y = 1.0f - texcoords[texcoordIndex].y;

3. Invert the NZ normal vertex. In the code you will see it do this: normals[normalIndex].z = normals[normalIndex].z * -1.0f;

4. Convert the drawing order from counter clockwise to clockwise. In the code I simply read in the indexes in reverse order instead of re-organizing it after the fact:

fin >> faces[faceIndex].vIndex3 >> input2 >> faces[faceIndex].tIndex3 >> input2 >> faces[faceIndex].nIndex3; fin >> faces[faceIndex].vIndex2 >> input2 >> faces[faceIndex].tIndex2 >> input2 >> faces[faceIndex].nIndex2; fin >> faces[faceIndex].vIndex1 >> input2 >> faces[faceIndex].tIndex1 >> input2 >> faces[faceIndex].nIndex1;

With those four steps complete the model data will be ready for DirectX 11 to render correctly.

 

I still cannot get it to work even after the steps above. BTW, im using blender.

Alright h8cplusplusGuru, got it. thx

Advertisement

This topic is closed to new replies.

Advertisement