[DirectX11] [Assimp Textures] Have you ever seen anything similar?

Started by
4 comments, last by __Dominik 8 years, 6 months ago

Hi everyone!
I've got a problem when loading objects using assimp. I did succesfully load vertex data and I am able to draw static mesh (without bones and animations, I've got few bugs there but I'll go back to solving that problem after I solve this one). Back to the problem. I have loaded texture coords using this code


tmp.Tex.x = modelScene->mMeshes[i]->mTextureCoords[0][j].x;
tmp.Tex.y = modelScene->mMeshes[i]->mTextureCoords[0][j].y;

of course it is in cycle for all meshes and all vertices (i, j respectively).

Then I draw it using DirectX 11 and I get this result:
WbPx5.png

I tried almost all permutations of post loading flags that had something to do with UV coordinates and nothing helped (only the yellow spots changed it's color to green in some cases).

I tried drawing the loaded texture on a quad to see if it is loaded successfully and it is.

The code for drawing is basically the same as in the book from Frank Luna, with minor changes (because I redesigned the whole framework to my needs). Shader is whole from the book.

I am hopeless already. I am looking for working way to load my models (fbx, dae) to my demo for almost 2 months now and nothing worked (this is the closest I've got), so if anyone have seen anything similar I would be really grateful for any pointers on where to look for problem.

Advertisement

Try something like this:


uv.x = pMesh->mTextureCoords[ UVIndex ][ vertIndex ].x;
uv.y = pMesh->mTextureCoords[ UVIndex ][ vertIndex ].y;

HTH

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

How is that different from the code I have provided? ... in my code "i" is meshID and "j" is vertindex (it is in cycle but that's written above)... UVIndex is always 0 because I have only 1 texture layer in my model that's for sure ... I could try to change the 0 to some other number just to see if assimp didn't put it in some other layer but I don't think that's going to work because then this call would crash because 0th layer would be nullptr (I think ... according to documentation) but thanks for trying

Sorry, missed that.

Have you used the AssimpView to verify that the texture coordinates are correct?

HTH

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

Going back to the first assumption, how do you know it's an issue with the UV's? What's your input layout look like - does it exactly match the memory layout of your vertex buffer(s) and your vertex shader? What's the vertex and pixel shader do? Is the actual texture resource valid?

Have you captured the frame with a graphics debugger (e.g. visual studio graphics debugger or Renderdoc) and inspected the vertex attributes that you're actually delivering to the vertex shader?

Sorry, missed that.

Have you used the AssimpView to verify that the texture coordinates are correct?

HTH

Yeah, I've done that before I started to even implement assimp libs to my code as long as any 3rd party library adds mess to any project so I wanted to make sure it would work.

Going back to the first assumption, how do you know it's an issue with the UV's? What's your input layout look like - does it exactly match the memory layout of your vertex buffer(s) and your vertex shader? What's the vertex and pixel shader do? Is the actual texture resource valid?

Have you captured the frame with a graphics debugger (e.g. visual studio graphics debugger or Renderdoc) and inspected the vertex attributes that you're actually delivering to the vertex shader?

Well, the shader worked for the demo model that was included with the Frank Luna's book and I used the same input layouts, therefore I automatically assumed that it should be fine for any model provided that I load it correctly into the same vertex layout, correct me if I am wrong.
I may try to look into some graphics debugger (but I'll need to find out how they work first).
Texture is loaded correctly I tried to draw it on quad and it displayed correctly .... however I used different (more basic) shader so I may try to display it using the same shader I use for model but as I stated above I don't think that's going to be a problem.

EDIT:
I tried to draw it on a quad with the shader I use and it is drawn correctly, however on first try I've put wrong tangentU and Normal vectors and it was all black with occasional white lines (with shades of correct texture) as I moved the camera, so I am adding a possibility of the problem to be wrong Normals or Tangents, I am adding my code of how I load those:


tmp.Normal.x = modelScene->mMeshes[i]->mNormals[j].x;
tmp.Normal.y = modelScene->mMeshes[i]->mNormals[j].y;
tmp.Normal.z = modelScene->mMeshes[i]->mNormals[j].z;


tmp.TangentU.x = modelScene->mMeshes[i]->mTangents[j].x;
tmp.TangentU.y = modelScene->mMeshes[i]->mTangents[j].y;
tmp.TangentU.z = modelScene->mMeshes[i]->mTangents[j].z;

BTW. whlie I am at it ... what's the difference between tangent and tangentU? Could that be the problem somehow? I can provide shader code if you want.

This topic is closed to new replies.

Advertisement