Jump to content

  • Log In with Google      Sign In   
  • Create Account


Directx Texturing Problem.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 JoeyAndres   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 July 2013 - 01:42 AM

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: 

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.)

texture_problem_01.png

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

texture_no_problem_01.png



Sponsor:

#2 belfegor   Crossbones+   -  Reputation: 2323

Like
1Likes
Like

Posted 14 July 2013 - 01:55 AM

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, 14 July 2013 - 01:57 AM.


#3 JoeyAndres   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 July 2013 - 03:00 AM

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.



#4 belfegor   Crossbones+   -  Reputation: 2323

Like
2Likes
Like

Posted 14 July 2013 - 03:50 AM

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



#5 Norman Barrows   Crossbones+   -  Reputation: 1835

Like
1Likes
Like

Posted 14 July 2013 - 10:10 AM

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.


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 


#6 PhillipHamlyn   Members   -  Reputation: 454

Like
0Likes
Like

Posted 14 July 2013 - 11:00 AM

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



#7 belfegor   Crossbones+   -  Reputation: 2323

Like
0Likes
Like

Posted 14 July 2013 - 11:09 AM

I think that clamp doesn't matter here as all islands are inside 0-1 uv range.



#8 JoeyAndres   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 July 2013 - 01:07 PM

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, 14 July 2013 - 11:58 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS