Sign in to follow this  
hegel

texture disappear

Recommended Posts

I write a directx viewer of my own, it can load .x files but the objects shown in it don't have any texture. The .x files are exported from Maya. The confusing point is that my viewer can show .x files exported from 3dMax well. Anybody meet the same problem? BTW, I don't use sas in my application.

Share this post


Link to post
Share on other sites
hi,

you stated your problem, but didn't provide any detail / source code so that anybody could solve it. having this question I can just guess (are the textures loaded correctly? check HRESULTS, are the textures assigned to the appropriate sampler? does the textures have correct mip levels - if they are DDSs? are your UVs ok?)
first, you should check the X file (in text format) by hand, and have a look at the texture references.

kp

Share this post


Link to post
Share on other sites
the HRESULT is fail for loading texture, which means texture loading fails.
the teturefiles are .jpg.
The code doesn't work with .x files exported from Maya only. This is the confusing point.

Share this post


Link to post
Share on other sites
You are indeed providing way too little information for anyone to be able to assists you in this matter.

How are you retrieving texture filename information from the x file?
Are the filenames valid (correct path etc) ?
Are the textures being loaded correctly?
Are the textures being set correctly when rendering?

There are many different possibilites to what might be causing your problem.
So post some source code, show us your loading code so that we can examine if you are loading the textures correctly, and your rendering code so that we can examine whether or not you are setting the textures correctly when you are rendering the mesh.

Hope this helps

Regards,
/Omid

Share this post


Link to post
Share on other sites
Quote:
Original post by hegel
the HRESULT is fail for loading texture, which means texture loading fails.
the teturefiles are .jpg.
The code doesn't work with .x files exported from Maya only. This is the confusing point.


Debug and see what file it's trying to load. My guess is that you the paths are not entirely correct. That would also explain why maya wouldn't work but 3dsmax would, since 3dsmax is probably exporting the full path name to the file whilst maya is only exporting the filename, or some relative path.

Hope this helps

Regards,
/Omid

Share this post


Link to post
Share on other sites
Quote:
Original post by hegel
the HRESULT is fail for loading texture, which means texture loading fails.
the teturefiles are .jpg.
The code doesn't work with .x files exported from Maya only. This is the confusing point.
If texture loading fails, then chack the filename that you pass to the texture loading function (D3DXCreateTextureFromFile()?), and check is the texture file itself isn't corrupted. Then check any other parameters you possibly send to texture loading.

kp

Share this post


Link to post
Share on other sites
I ported Keith Ditchburn's x file loading program. You can download his source code in http://www.toymaker.info/Games/XFileLoadingCode.zip. His viewer got the same problem. Fro maya .x file, the display of textures and sometimes animations will get some problem.

Share this post


Link to post
Share on other sites
I've check the texture filename in .x files exported both from maya and 3dx. They are the same.
But the frame formats are a little bit different. Is that the problem?

Share this post


Link to post
Share on other sites
Have you tried using the debug runtimes? The D3DX functions are pretty good at outputting a better reason (e.g. that it can't find the file, or the dimensions are invalid).

Also, have you tried using dxviewer.exe? If that has the same problems then you might have found an issue with how Maya exports it's files - however, if that tool displays them fine then it's much more likely that your code is the problem [oh]

hth
Jack

Share this post


Link to post
Share on other sites
DxViewer is fine. But DxViewer using DXUT and SAS. It seems that the fixed-function pipeline of DirectX used in my program can't work with .x file format exported from Maya.

Share this post


Link to post
Share on other sites
I just found that the .x file exported by Maya sets all MeshVertexColor to black(r:0,g:0,b:0). I deleted all MeshVertexColor field in the .x file, then texture appeared.
I'm just wandering if there is any other programmable way to display textures than directly modifying .x file?

Share this post


Link to post
Share on other sites
Quote:
Original post by hegel
I'm just wandering if there is any other programmable way to display textures than directly modifying .x file?
You could, once loaded, modify the vertex buffer so that the diffuse component is not [0,0,0]...

Use ID3DXMesh::GetDeclaration() and scan the returned list for a usage of D3DDECLUSAGE_COLOR and index of 0. You can then extract the offset for the given field (the stride is D3DXGetDeclVertexSize()) and off you go [grin]

I'm pretty sure you could also use the fixed-function texture blending to skip the diffuse colour as well. I'm a little rusty on that part (Pixel Shaders for the win! [lol]) but a little reading around the SetTextureStageState() function should reveal all...

hth
Jack

Share this post


Link to post
Share on other sites
MeshVertexColor is not within vertex format definition. It's a standard template in .x files. Maya's exporter automatically set all MeshVertexColor to black. Directx will use this color information to render mesh if this information is present instead of texures. I think this maya's x file exporter is stupid at this point. Is there anyway to use fix functions of dx9 to overlook this MeshVertexColor information when rendering?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this