• Advertisement
Sign in to follow this  

Directx Texturing Problem.

This topic is 1653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently started exploring Directx 11. I'm almost done the introduction so I started making my own*.obj parser and it works beautifully. I accounted for the right-hand coordinate system of 3ds Max. The only problem is the texture.

Although the texture is layed out "almost properly", I can see that some mesh inherits texture colors that belong to the background part of uvw mapping. The model though seems to display the textures perfectly in 3ds Max as oppose to "almost properly" in my Directx program. 

I'd love to post codes but to be honest, I don't know where's the problem. Is it the *.obj parser? Initializer? Shader, or specifically Pixel Shader? I'm hoping the experience user would be able to "triangulate" the problem from the variables I've given (If that is a ridicoulous idea of mine, feel free to ask for the code or ask for a specific part of the code).

uvw mapping: 

[attachment=16768:uvw_01.png]

This is "wrong" output of my DirectX program: (The black part is likely from the black background of uvw map. I tried giving more "clearance" from the background without much hope.)

[attachment=16769:texture_problem_01.png]

While this is the "correct" output from 3ds Max:

[attachment=16770:texture_no_problem_01.png]

Share this post


Link to post
Share on other sites
Advertisement

I think the problem is with filtering, maybie MAX is doing point sampling with texture for its viewport display (check settings in options)? Try to render it and see if problem is present?

Try to scale down a bit each UV "island" or (it is hard for me to explain so i will point you to tutorial) go to cgtextures under "Tutorials" section find "Alpha mask background trick" and read it.

Edited by belfegor

Share this post


Link to post
Share on other sites

I don't really have to time to apply this right now since it's 3 in the morning. But base on your answer and the cg tutorial given, should I give my UV "island" space between each other? If so, what's the "rule of thumb" between separation of these islands via pixels? 

 

Thanks for the reply so far btw.

Share this post


Link to post
Share on other sites

I am not competent man to explain how exactly texture filtering works, but i will try.

When you put your uv seam exactly on "island edge" and set filtering other then "point" the pixel shader will sample adjacent pixels from texture thus grabbing "ocean" (the part that is not island biggrin.png  ) color, so you need scale down uv or paint (at least) 1 pixel out of "island" with color of adjacent pixel that is on "island".

I think you need at least 2 "free" pixels between uv "islands".

 

So you need to "expand" colors from edge at least a pixel. Here is rough painting of mine to visualise what i mean:

directx-texturing-proble.jpg

Share this post


Link to post
Share on other sites

the problem may be filtering. as stated above, non-point filtering will sample pixels beyond the edge of your desired UV area in the atlas, thereby blending the background color of the atlas into the edges. the fix is to extend the color of the desired texture as shown in the image in the previous post, or reduce the size of the UV area mapped to be safely inside the border of the texture in the atlas.

 

however, if you look at your output, the dark areas don't seem to correspond to where the edges of the textures in the atlas would be, so it may be a UV problem instead or as well. usually with filtering issues, everything looks correct, but you get dark edges where the background is too close to the sampled area. sort of like seams between the textures, but the textures all are in the correct position.

 

note also that mipmaps, alpha blending, and non-clamp addressing can also lead to this "dark areas" problem, its all the same sort of filtering issue.

Share this post


Link to post
Share on other sites

Hi,

 

I've done some work with texture atlas's and got similar problems. Check that your sampler is set to UV Clamp (I think this might only be an XNA restriction) and that your texture has deep enough borders to allow linear filtering to work OK at the margins. I can only guess that MAX using some kind of software renderer and does not internally use the texture atlas at all - perhaps it conditions the atlas into separate textures and renders the mesh in sections rather than all at once ?

 

Phillip

Share this post


Link to post
Share on other sites

Being my first post, I'm impress with response of this community. After hours of debugging, I've finally figured out how to texture my models perfectly. Your replies helped me a lot in solving the texturing problem. But after applying your recommendations, it turned out that there's more problem. Since I load the model via .obj parser I recently created, I knew right away that the problem is in there. After recognizing the problem, I fixed the problem and now the model renders nicely.

 

With all problems of the day being solved, a new problem arise concerning my .obj loader, since it whent from Big O(n) to Big O(n^2), making it very slow in loading. I will try to implement a hash table tommorow so it will hopefully be down to Big O(nlog(n)), but that's another discussion.

 

Again, I appreciate all your helped, and impressed by this community. 

 

Thank You.

Edited by JoeyAndres

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement