🔒 Locked
Multisample questions
Advertisement
Original Post
I am struggling with some image resampling problems that I hope the community can help me shed some light on! I have a basic grayscale image, lets say the size is 2048x2048. This is mapped/displayed on a region that, in screen space, is 1050x1050 pixels. The mapping is straightforward and planar, ie no tilting planes or complex polygons or anything. Due to high-frequency components in the image I am now suffering from *severe* artefacts. The interpolation that performs the mapping between 2048x2048 and 1050x1050 simply does not cope. When "zooming" a bit I soon reach a point where a downsampled version, 1024x1024, fits perfectly and now the texture mapping does not introduce additional artefacts. My question at this point is what options I have for handling the first scenario (maximum difference in size between source and destination size)? a) I tried swapping the Linear min/mag filter for other options, but without visible results. b) I have also explored using multisampling (NonMaskable, TwoSample, FourSample) but without success. Should either or both of thesehave solved my problem? Ie, could there be errors in my testing or is my problem not of the nature that those tools would help me?
You may have to write your own filter in a pixel shader. For a difficult image, I'd try a 5 to 7 sample (per dimension) Lanczos (cosine-windowed sinc). I'm pretty sure this kernel is separable so do it in horizontal and then vertical pass for efficiency. If you're resizing by a factor larger than 2x, use appropriately more samples. One idea would be to use this filter to precompute the various MIP levels and then use the built-in bilinear filtering to blend between them. If your image is static, just use IrfanView set to Lanczos resampling to resize it to all the MIP levels and load them from file, then use mipmap linear texture filtering.
If the high frequency content of the image is the problem when you downsample, then I would try to reduce the high frequency content with a Gaussian filter or something similar. Of course, if you can keep the down sampling to an integer number then it will help hide the flickering.
Actually, the downsampling is only the first half of my problem... But I wanted to keep things as clear as possible for the initial discussion.
When doing the downsampling (and unfortunately I can neither use integer ratios nor use upsampling when slightly "over" the limit), the quality is only rarely problematic.
The bigger problem is that in some scenarios I must also apply an edge enhancement shader. As you can imagine that does not exactly lessen the HF content. The result is some serious artefacts, and it is mainly due to this scenario that I was exploring my options.
I had a hunch that multisampling was more relevant when texturing polygons more complex than my simple static square. I might still look more deeply into mipmapping, but it a first glance it did not seem to offer any help. When the ratio between texture and destination size is an integer factor the results are nice. It is the points just before this that are the problem.
I think my best bet at this point is to probably opt for a more sophisticated edge enhancement filter, that perhaps contains an adjustable smoothing component that would allow be to more gracefully handle the different scenarios.
Thanks for the input so far, and please do not hesitate to suggest any ideas whatsoever. I am still at an experimental phase, so most options are still open!
When doing the downsampling (and unfortunately I can neither use integer ratios nor use upsampling when slightly "over" the limit), the quality is only rarely problematic.
The bigger problem is that in some scenarios I must also apply an edge enhancement shader. As you can imagine that does not exactly lessen the HF content. The result is some serious artefacts, and it is mainly due to this scenario that I was exploring my options.
I had a hunch that multisampling was more relevant when texturing polygons more complex than my simple static square. I might still look more deeply into mipmapping, but it a first glance it did not seem to offer any help. When the ratio between texture and destination size is an integer factor the results are nice. It is the points just before this that are the problem.
I think my best bet at this point is to probably opt for a more sophisticated edge enhancement filter, that perhaps contains an adjustable smoothing component that would allow be to more gracefully handle the different scenarios.
Thanks for the input so far, and please do not hesitate to suggest any ideas whatsoever. I am still at an experimental phase, so most options are still open!
Come to think of it, precomputing "mipmaps" on my own with tighter increments than full factors of 2 might actually be possible. The actual frequency problem would still be the same, but I might cut out the very worst cases by introducing more intermediate reconstructions.
I'll probably look into this options as well!
I'll probably look into this options as well!
An image would seriously help.
All I can say is that you can try your own filters: Gaussian, Lanczos, BiCubic, Mean filter. Everything applied offline.
Try also colour-dithering the image in software.
Then you use Lod to switch from one texture to another.
It has already been suggested to try this Lod thing into mipmapping to get the smoothest transition between the different filtered images.
An alternative is to slightly darken the image according to the ratio. The human eye detects dark spots with less accuracy.
When the ratio is 1:1 display 100% bright.
When ratio is 1.2:1.2 display 95% bright
When ratio is 1.5:1.5 display 85% bright
When ratio is 1.8:1.8 display 95% bright
When ratio is 2:2 display 100% bright.
This is all I can help without screenshots.
Cheers
Dark Sylinc
PS: Long shot, but might be worth trying: You didn't mention you tried anisotropic filtering. Have you?
All I can say is that you can try your own filters: Gaussian, Lanczos, BiCubic, Mean filter. Everything applied offline.
Try also colour-dithering the image in software.
Then you use Lod to switch from one texture to another.
It has already been suggested to try this Lod thing into mipmapping to get the smoothest transition between the different filtered images.
An alternative is to slightly darken the image according to the ratio. The human eye detects dark spots with less accuracy.
When the ratio is 1:1 display 100% bright.
When ratio is 1.2:1.2 display 95% bright
When ratio is 1.5:1.5 display 85% bright
When ratio is 1.8:1.8 display 95% bright
When ratio is 2:2 display 100% bright.
This is all I can help without screenshots.
Cheers
Dark Sylinc
PS: Long shot, but might be worth trying: You didn't mention you tried anisotropic filtering. Have you?
Here's an example of a sort of worst case scenario. Different types of images show different artefacts, I guess depending on the frequency content of the source image. Here we get folding distorsion/aliasing in the form of vertical lines. For some images there are square patterns of varying scales.

Please click "twice" to look at the image in full resolution, as downsampled representations would add problems of their own. The image shows, from left to right:
a) Large scale differens (sourceWidth/destinationWidth close to 2, but slightly larger). No edge enhancement
b) Exactly the same as [a] but with strong edge enhancement filter shader used.
c) The same as but zoom changed a small bit, such that a mipmap of half the size matches perfectly.
As for anistropic settings, I tinkered with them a bit, but without luck. My knowledge in that area is slim, but I thought this would only help when the polygon edge suffers from "perspective" problems. Ie not being aligned with the view?

Please click "twice" to look at the image in full resolution, as downsampled representations would add problems of their own. The image shows, from left to right:
a) Large scale differens (sourceWidth/destinationWidth close to 2, but slightly larger). No edge enhancement
b) Exactly the same as [a] but with strong edge enhancement filter shader used.
c) The same as but zoom changed a small bit, such that a mipmap of half the size matches perfectly.
As for anistropic settings, I tinkered with them a bit, but without luck. My knowledge in that area is slim, but I thought this would only help when the polygon edge suffers from "perspective" problems. Ie not being aligned with the view?
Something else is going on I think - if you were using a second mip level it shouldn't be so grainy as compared to the original image. Are you sure that you have mip levels filled up? Can you verify this with PIX (I'm assuming you are using D3D - are you?) if the mip level is actually being used?
I would expect the high frequency blips when you are using the full resolution image on a smaller resolution image. The mip maps will almost certainly help you if they are not currently being used!
I would expect the high frequency blips when you are using the full resolution image on a smaller resolution image. The mip maps will almost certainly help you if they are not currently being used!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement