|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Box Filtering Height Maps for Smooth Rolling Hills |
|
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| This is my first GDNet submission, and I hope that it is well received. Please let me know what you all think about it! I am contemplating the idea of a whole column on designing a powerful terrain engine, so we'll see how that goes. ~Graham ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
![]() netflow Member since: 6/27/2004 From: Canada |
||||
|
|
||||
| Great Article, definitely has a lot of stuff in there worth reading.. I wish we could have an article a day as useful as this! Keep it up |
||||
|
||||
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| Thank you very much for the support :) ~Graham ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
![]() ajoling Member since: 9/17/2000 From: The Hague, Netherlands |
||||
|
|
||||
| Looks interesting. I will give it a try tommorow, and see how it looks like :-). I'm still i nthe early stages of my terrain renderer, and always lookin for new things and ideas to try. :) |
||||
|
||||
![]() ajoling Member since: 9/17/2000 From: The Hague, Netherlands |
||||
|
|
||||
| Did it quickly before going away from home :) Here's my result: ![]() Without any smoothing ![]() This is using my own idea once: HeightMap[y][x] = (float)(HeightMap[y][x-1] * 0.11f) + (HeightMap[y][x+1] * 0.11f) + (HeightMap[y-1][x] * 0.11f) + (HeightMap[y+1][x] * 0.11f) + (HeightMap[y][x] * 0.11f) + (HeightMap[y-1][x-1] * 0.11f) + (HeightMap[y+1][x+1] * 0.11f) + (HeightMap[y+1][x-1] * 0.11f) + (HeightMap[y-1][x+1] * 0.11f); ![]() With box filtering. Between the last two there is not that much difference, but looking at the background, it looks your one is smoother :). Ofcourse, this was quick test, the terrain isn't very well visible at the moment :). btw, can I ask you how you get your detail? splatting? or something else :) |
||||
|
||||
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| I'm glad you got it working ;) Made quite a bit of difference! I did the detail in my terrain using detail texture splatting. Bit of optimization in there. Each polygon I check for splatting layers that hide layers underneath and remove occluded polygons. Then I regenerate the static vertex buffers. Works pretty well, and removes the polygons you can't see. ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
![]() Prozak GDNet+ Member since: 2/22/2000 From: Lisbon, Portugal |
||||
|
|
||||
Awsome tutorial, I have to use this on my terrain rendering code... will post some pics once i do ![]() Keep up the good work Graham ;D </ Positronic Dreams / Colibri 3D Engine / My Journal > * What the hell is an aluminum falcon? |
||||
|
||||
![]() d000hg Member since: 1/21/2002 From: Durham, United Kingdom |
||||
|
|
||||
| A useful article, though I'm a little suprised most people didn't already implement it. It's also a very useful technique in image manipulation, and is one example of using a matrix to manipulate an 'image'. By changing the weightings in the matrix you can sharpen/blur/detect edges, which makes a useful object-orientated approach most easy. I think the matrix is technically called a 'kernel' in image manipulation - Photoshop uses this technique for some of it's effects I believe. Good work. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| yup, matrix approarch is very flexible and does allow all kind of different effects, not only smooth & blur. (on both highmaps and textures, and also all sorts of different data) (... now a bit off topic, it's more about texture/picture filtering, than about heighmap ...) but the "box" method is somewhat special, because it can be optimized heavily. If you thing about it, you can calculate sum of first box in upperleft corner, and than to get sum of next box, you need only to subtract left column of box, and add right column of box. Column sums can be again cached and updated by simple -upper element +new lower element when you move to next row. This allows you to use this filter in realtime with different size of box with almost same computational complexity. I did this to blur (with variable "blur degree") whole software rendering result in our old PC demo called "WHY". (http://7gods.org/files/why_11.zip) The difference between no filter (1x1), 2x2, 3x3 and 4x4 is very visible, but with box size of 10x10 and more you get just blured vision, so this is definitely not very flexible filter in terms of finetuning the result. But it's fast and you can do it on the fly for almost constant CPU time. I think it can be even done at your GPU with some pixel shader maybe. With different matrix filters you will have to recalculate whole matrix everytime, which is making other filters to cost as much, as what size you choose for your matrix. Thus they are not as suitable for real-time, as this "box" blur. Ped/7Gods |
||||
|
||||
![]() ajoling Member since: 9/17/2000 From: The Hague, Netherlands |
||||
|
|
||||
| Yeah, I have quite some problems finding the logic behind Texture splatting. I'll probably leave it for a while now, and work on the water. Then it's time for some game logic. Anyway, this matrix type of filter is also great for pregenerated lightmaps/shadowmaps (for example using the fast lightmap calculation article here on GD). Blurring out the corners of the shadows make it look more real :) Just an idea for people who haven't tried this yet. :) |
||||
|
||||
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| Yes, the matrix described above is in fact technically referred to as the convolution kernel. By providing varying kernels, different effects can be achieved; including sharpen, blur, smart blur, etc.. Edge detection is a method to allow for finetuning your blur algorithms. Specifically speaking of heightmaps, it will allow your terrain to maintain its sharp cliffs while still applying smoothing and noise removal. ~Graham ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
![]() mikiex Member since: 7/13/2000 From: United Kingdom |
||||
|
|
||||
| Is it just me, but some hills and mountains require sharp edges, and if you want a mix, why not create your heighmaps correctly in the first place? Ok I skimmed the article, but i just don't see the point mikie |
||||
|
||||
![]() Kurioes Member since: 9/6/2002 From: Utrecht, Netherlands |
||||
|
|
||||
| I agree. Why don't you blur (blurring := box filtering) the terrain with the terrain editor (often you can edit the terrain files with a regular paint program such as the Gimp, and use its blur function). That would allow for really sharp edges when I need them. I can add teletubby style soft edges myself. If you need blurring go for a lower resolution terrain map. Having said that the article is okay and explains box filtering quite well (as stated before it's applicable to other areas too such as image manipulation). [Edited by - Kurioes on October 26, 2004 3:18:33 PM] Kurioes' Dump | KBL |
||||
|
||||
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| mikiex: In my article, I do state that in order to preserve sharp edges you would implement a different type of convolution filter know of as "smart blur". It uses a form of edge detection and a threshold factor to remove noise, yet preserve cliffs and edges. Kurioes: Blurring in Photoshop is box filtering. It's the same technique, except this method: a) Doesn't require photoshop b) Can be called at runtime c) Serve other dynamic purposes (soft shadows, etc..) Thank you for the comments, I do appreciate them. ~Graham ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
![]() MickePicke Member since: 10/9/2002 From: Sweden |
||||
|
|
||||
Quote: Programmers often want to do things themselves. You can blur the heightmap in another program, but how fun is that? You can always download the SDK to Doom 3 (or UT) and write your game from there, but that isn't any fun either. |
||||
|
||||
![]() Kurioes Member since: 9/6/2002 From: Utrecht, Netherlands |
||||
|
|
||||
| I still think photoshop (or any other decent painting program) is the way to go if all you care about is the final result; selectively blurring certain areas just gives you more flexibility and control over the final result. I do, however, understand why you'd want to do this yourself (I can't say I didn't). It would come in handy when generating random heightmaps. Suggestion for a follow-up: more kernels. For example: unfiltered: (lame kernel :P) 0 0 0 0 1 0 0 0 0 You should generally divide the result of the convolution by the sum of the elements of the matrix. You could experiment with other kernels; the results are quite interesting. Kurioes' Dump | KBL |
||||
|
||||
![]() clapton Member since: 3/10/2004 From: The Earth |
||||
|
|
||||
| A very nice article! :D It's very well written and everything seems obvious and simple. Good work. :) Is it your cat, Kurioes? ;) ___ Quote: |
||||
|
||||
![]() Kurioes Member since: 9/6/2002 From: Utrecht, Netherlands |
||||
|
|
||||
Quote: Nope :) Just the first adequate picture I could find on my computer. |
||||
|
||||
![]() Tybon Member since: 10/4/2004 From: Vancouver, Canada |
||||
|
|
||||
| I find a combination of median filtering using a photo editor and your box filtering routine achieved better overall results. Median filtering will smooth out the little bumps on the ground and your box filtering routine will smooth out the curvature of the hills in my terrain. Anyways good job on this excellent article! |
||||
|
||||
![]() gwihlidal GDNet+ Member since: 4/23/2003 From: Edmonton, Canada |
||||
|
|
||||
| Thank you for your feedback Tybon! ~Graham ---- Graham Wihlidal, MCSD.NET Senior Programmer Graphics & Art Tools BioWare ULC | EA -- Author of Game Engine Toolset Development THE VIEWS OF MYSELF DO NOT NECESSARILY REPRESENT THE VIEWS OF BIOWARE OR EA. KEEP THIS IN MIND. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|