Sign in to follow this  

How would I blur a texture in the distance?

This topic is 4282 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 need somehow to blur the texture for my terrain in the distance. The reason I need to, is because as the distance increases from the camera, the texture tiling becomes visible and looks horrible at great distances. It would need to keep the texture close to the camera untouched and progressivly blur as distance increases. I am assuming that the answer will be in the vertex and pixel shaders. I don’t want a super blur, just enough to mask the tiling a bit. Here is what the tiling nightmare looks like now: (yes, it is multitextured with a blend map and the texture sucks) Image hosting by Photobucket [Edited by - Valor Knight on March 29, 2006 9:39:44 PM]

Share this post


Link to post
Share on other sites
I think where you sample your textures with tex2D, you could use tex2DLODbias (that may not be the totally correct name) to force pixels further away to use a lower mipmap level and therefore be more blurred.

Hope that helps
Andrew

Share this post


Link to post
Share on other sites
An easy and cheap way of doing this would to create your mipmaps so that the smaller versions are also blured slightly rather than just downsampled. You can also adjust the mipmap bias to make the lower mip levels fade in earlier than they would normally.

However I'm going to suggest that you don't do either of these and find better ways of removing the obvious tiling. Some suggestions:

- Get a better texture. Good textures shouldn't have obvious features like that one does as it makes the repatition even more obvious.

- Reduce the frequency of the repeating texture. If this makes the near landscape suffer too much in detail then consider adding an additional detail texture (which may fade out using mipmaps as above).

- Add a greater variation in lighting. Nice high contrast shadows should break up the monotony.

- Consider adding more variation in surface detail. Different surface textures, surface decals and vegetation would all help a lot.

- At the opposite end of details textures, try a single large texture layer streched over the whole landscape. You can use this to give more subtle colour shifts and discolourations.

Share this post


Link to post
Share on other sites
My terrain makes use of both a large detail texture and a small one to good effect. If you take one really large texture and stretch it out across the whole map, and then blend it with a small, high frequency texture, the tiling issue will be significantly reduced. Also, it does look like your texture has a very obvious border, so you may want to do something about that. Finally, you can use a texture matrix to rotate your texture coords, so the repeats don't run parallel with the terrain. All of this is cheaper then running a pixel shader to blur the texture, so you may want to try this before going down that road.

Share this post


Link to post
Share on other sites
I am using a blend map, however it does not look like it. I agree the texture totally sucks, I will look for better textures. And, currently I have no lighting/shading in this (as the image shows). I need to find new textures, doe anyone know of a good site w/ free textures?

Personally, I know a little about vertex shaders, and even less about pixel shaders, so how could I mipmap it? is it tex2Dlod? how do you use it?

[Edited by - Valor Knight on March 26, 2006 4:31:54 PM]

Share this post


Link to post
Share on other sites
check out this tutorial at gamasutra:
http://www.gamasutra.com/features/20010523/hajba_01.htm

it's about using photoshops high pass filter to removed obvious tiling artifacts.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The problem is that your MIP map chain is showing obvious texturing repeats, this is not a shader problem. The basic way to avoid this is to properly make your base textures (that all your lower mip map chain will be created from). I will give you the steps to alleviate this problem with photoshop editing.

1) open your texture up in photoshop

2) make sure your texture properly repeats already (another tutorial). This can be done by using the offset effect to scroll your texture vertically and horizontally. If there is a really obviouse seems fix it, perferablly with the clone stamp tool and NOT smudging the texture to blend edges. (again another tutorial)


NOW THE PROBLEM: When your texture looks fine tiled close up, but bad far away, this is due to the low frequency color changes in your texture. High frequency changes get cancelled out in the mip mapping creation process. So for example, a very noisy/pixelated texture will lose it's "noisyness" in the lower level deatails and become quite blurry due to the nearest neighbor sampling. This is fine, but the proces also starts to reveal the low frequency changes in your textures. What you want to do, is minimize the low frequency changes in your textures, here is how:

3) select your texture, and make a copy of it for later use.
4) select FILTER->OTHER->HIGHPASS, this will turn your image gray
5) adjust the radius of the highpass, larger values will make your image more solid gray, and a lower value will create an image that retains more low frequency detail.

NOTE: this is the filter that will remove your lower unwanted frequencies from your image. As you adjust the radius you can see how your image start removing low frequency ranges for the higher radius values. Now artistically remove some of the lower ranges by increasing the radius. Your image should appear fairly smooth and solid, but not completely gray. Again this takes some practice to see how much low frequency range you actually need to remove.

6) now apply the highpass filter, your image should be grayscale
7) make a new layer and paste your original copied image into the layer
8) adjust the layer blending to apply color only, this will recolor your greyscal image.
9) save your new texture and run it in your engine.

NOTE: You will notice that your texture has lost the low frequency changes, so the obvious low level tiling has been lost. This however makes a very nice and smooth transition into the smaller mipmap chains, which now will not show the low frequency changes. Instead they will blend into a mroe solid and consistent color in the distance. You should experiement with radius values of the highpass filter to see how this actually effects your distance texture LOD. After your are comfortable with this you can easily adjust all your problem textures to produce the same results.

FOR YOU: It looks like you blended and made your texture edges repeat. However when doing this you lost your high frequecy detail (at the texture edges). This is why the clone stamp tool is nice, you can sample a part of your image and artistically blend the edges of your texture while retaining a degree of the texture noise/high-frequency/detail. Rememeber smudging of texture edges will produce low-frequency data, because it is.. well-smoothed and has no high frequency noise in it. Also increase the contrast of your texture a little bit, this will produce a crisper closer image for you and then by following the above steps will produce the blend to a solid color in farther distances.

Good luck, hope this helps. Rememeber to practice this a couple of times, it is a very useful technique.

Share this post


Link to post
Share on other sites
ok, so this isnt a problem with my terrain engine, it is my texture's mip levels are showing the low frequency changes. good to know, unfortunatly, I am not an artist, nor have photoshop so I have to just find better textures then. Currently they are jpg's so the mip are created on the fly (right?). If I used .dds mips are pre-made and can change, correct?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:

I am not an artist, nor have photoshop so I have to just find better textures then


There are free/cheap solutions to photoshop that should support the same highpass effect. Short answer for you, yes.. find a better texture. However If you do not want to expand your artistic abilities then you shouldnt be worrying about the quality of your textures right now. Develop the engine and then put in better art later or find someone to do it for you that is artistically capable.


Quote:

Currently they are jpg's so the mip are created on the fly (right?). If I used .dds mips are pre-made and can change, correct?


You program produces a full mip map chain if in your LoadTexture call your provide DX_DEFAULT or NULL or 0 for the mip map creation parameter. You can store custom mip map chains in the dds format if you want, However generating them on the fly is all that is really needed, unless your doing something funky like a specialized texture for an advanced pixel shader.

Good luck

Share this post


Link to post
Share on other sites

This topic is 4282 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.

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