Jump to content

  • Log In with Google      Sign In   
  • Create Account


Brick Texture Artifacts When Camera is Moving


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
11 replies to this topic

#1 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 24 May 2012 - 05:35 PM

I think my issue is related to mipmaps and my understanding of texture loading and filtering in my pixel shader / DirectX.

The D3DXCreateTextureFromFile method automatically creates mipmaps (11 of them) and sets the filtering.

In my shader I’ve set the texture filtering to:

MinFilter = Anisotropic;
MagFilter = Linear;
MipFilter = Linear;


With these settings everything looks fine until the camera moves. I get artifacts where the grout is (around the bricks). At some distances it looks like a pattern of sorts. Kind of like horizontal lines in a recorded video of a TV screen.

With the filtering in the shader turned off I get the same artifacts but much more sever. Even if I use the D3DXCreateTextureFromFileEx function and manually set the filtering, the issue remains.

Does the filtering in the D3DXCreateTextureFromFile change the appearance of the mipmaped textures that are stored in memory or does it filter them in real-time through the hardware, ignoring my shader’s mipfilter setting?

How many mipmap levels should I have? (performance vs. quality)

Should I even use mipmaps?


To add insult to injury, last week I had an issue with ghosting due to poor refresh rates on my monitors. I’ve ordered new ones but they won’t be here for a couple of weeks. Could my issue be related to ghosting? I’m leaning towards it not being a ghosting issue because the patterns change depending on the distance from the object- Hence why I’m going down the mipmap path looking for the bug. But I could be wrong.

Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2157

Like
0Likes
Like

Posted 25 May 2012 - 07:01 AM

Hi,

can you post a screenshot?

In general mipmaps are beneficial for image quality (reduces aliasing) and performance (smaller textures are better for caches).

Anisotropic filtering should give less blurred results over bilinear/trilinear filtering.

Have you verified your MaxAnisotropy value? If it is set to 1, your texture filtering won't look better than tri/bilinear filtering.

http://msdn.microsof...4(v=vs.85).aspx check here how to set the maximum anisotropy value under d3d9.

Also, I suggest creating mipmaps offline. NVidia for example has a tools for creating dds files with mipmaps. It shortens the load times significantly.

Cheers!

Edited by kauna, 25 May 2012 - 07:02 AM.


#3 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 25 May 2012 - 10:23 AM

Thanks for the replies.

I’ve tried every available combination of min, mag and mip filtering and still have the issue.

The Max Anisotropy is 16, (the max available on this machine’s card). I’ve tried it set at 1 -16, with no difference in the results.


The D3D9 Texture interface shows the following properties:

Level Count: 10
Auto Gen Filter Type: Linear
LOD (level of detail): 0

In this particular application I cannot create the mipmaps myself due to its functionality.


I’ve attached a small video showing the issue.

Attached Files



#4 kauna   Crossbones+   -  Reputation: 2157

Like
0Likes
Like

Posted 25 May 2012 - 11:12 AM

As far as I know, anisotropic filtering doesn't change the quality of the image when the triangle is seen from perpendicular angles as we see in your filterissue video.

The D3DXCreateTextureFromFile creates mipmaps at the load time. If you don't create/load the mipmaps, the shader can't use any other mip level than the biggest, which means practically that no mip mapping will be applied. So, for mipmapping to work, the texture needs mipmaps and the sampler needs to be set to use them.

Otherwise it is a bit difficult to tell from the video what is going. Can you provide the texture itself?

Why can't you create the mipmaps yourself? If you are able to use D3DXCreateTextureFromFile function, you may load .dds files which can contain the mipmaps and you don't need to create them in the application.

Best regards!

#5 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 25 May 2012 - 12:10 PM

Thanks Kauna. This particular application allows the end user to load textures they’ve created. There are size restrictions and I could (in code) create images of different sizes in the background for the mipmaps but I’ve been avoiding that as the D3DXCreateTextureFromFile creates them automatically.

The Texture in the video is a simple 512 X 512 brick texture applied to a cube mesh, nothing special. The createtexturefromfile was used so the mipmaps were created automatically.

So, for mipmapping to work, the texture needs mipmaps and the sampler needs to be set to use them.


Other than setting the min, mag and mip filter, what else is needed to setup a shader for mipmaps?

Also, in the D3DXCreateTextureFromFileEx function you can set 2 filters, one for the texture and one for the mipmaps. I’m not clear on how these work. Do they override the shader’s sampler filters? I noticed you can have multiple filters applied, is there a standard that works well in most situations?

As far as I know, anisotropic filtering doesn't change the quality of the image when the triangle is seen from perpendicular angles as we see in your filterissue video.


Does this mean I have to change the filters depending on the camera angle? It seems as though this could become a huge performance issue with the multiple state changes.

I noticed better results when I set the texture filter to BOX and the mipmap filter to DITHER in the D3DXCreateTextureFromFileEx function. Maybe I need to apply more than one filter. If I set these to none I can see the mipmaps being appled as the camera moves closer but no filtering is being applied, even thoguh I have the mipmap filter in the shader’s sampler set to Linear. I also noticed the scaling being off but this could be a side-effect of the omission of filters.


Thanks again for your help Kauna…

Edited by DJTN, 25 May 2012 - 12:14 PM.


#6 kauna   Crossbones+   -  Reputation: 2157

Like
0Likes
Like

Posted 25 May 2012 - 12:40 PM

Other than setting the min, mag and mip filter, what else is needed to setup a shader for mipmaps?

Also, in the D3DXCreateTextureFromFileEx function you can set 2 filters, one for the texture and one for the mipmaps. I’m not clear on how these work. Do they override the shader’s sampler filters? I noticed you can have multiple filters applied, is there a standard that works well in most situations?


Setting min, mag and mip filter is what you need to make shader / sampler to use mipmaps. Of course the texture needs to have mipmaps too.

Filtering options in D3DXCreateTextureFromFile(Ex) affects the image in the load time. These filtering options don't have much to do with the shader/sampler filtering options. Ie. if the function creates mipmaps, different kind of filtering can be applied to this mipmap generation. Also, if the image is rescaled when loading, a filter can be applied. For example if the image size on disk isn't power of 2, the image could be scaled to the nearest power of 2 size.

Does this mean I have to change the filters depending on the camera angle? It seems as though this could become a huge performance issue with the multiple state changes.


Definetely no, my point is that anisotropic filtering doesn't affect the particular case you present. Otherwise it has better image quality than other filtering methods.

Cheers!

#7 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 25 May 2012 - 01:00 PM

I've attached another video displaying my issue. I've scaled the texture by 5 (wrapped) so you can see it better. It's a rather large file so I'll need to delete it later.

#8 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 25 May 2012 - 01:55 PM

I've noticed when the mesh is rotated clockwise the artifacts disappear. It’s only when the grout of the brick texture is lined vertical and horizontal that the artifacts appear. Maybe this IS a ghosting issue.


Can anyone else see the artifacts in the video?

#9 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 25 May 2012 - 08:53 PM

Anyone?

#10 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 26 May 2012 - 10:38 AM

It definitely looks like a mip mapping error. I would try mip maps generated offline. If you disable mip mapping does it still look that way? I wouldn't suggest disabling it and being done, but as a test you should see what it does.



I disabled mipmapping and the artifacts are more sever.

I've tried creating my own, changing the level of detail, and changing the filter combinations to every conceivable sequence in the texture creation as well as the shaders sampler.

I'm at a loss here...

Edited by DJTN, 26 May 2012 - 10:39 AM.


#11 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 27 May 2012 - 10:09 AM

Could this issue be due to the DX9 half pixel offset issue?

#12 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 27 May 2012 - 12:17 PM

When I change the color of the mortar of the brick texture to a color other than white (grey for example), the issue disappears. I'm now starting to think this is a limitation of DX and something I cannot fix. This would explain why so many games using muted colors or colors close in range.




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