L3DT users' community
Large 3D terrain generator

Heightfield smoothing

Any and all chit-chat regarding L3DT.

Heightfield smoothing

Postby Aaron » Fri Jan 05, 2007 3:03 am

Hi Everyone,

The latest dev build (v2.5 beta 2, Pro only) now has an option to apply smoothing to a heightfield. The option is at currently at 'Operations->Heightfield->Filter (diffusion)' in the menu. The inputs are a number of iterations, gradient threshold, and a threshold mode. There's no documentation yet, but this will come in time.

For users that import heightfields from images, this option may be particularly interesting, as it will allow you to selectively filter those quantisation steps that occur when you use those nasty 8-bits/layer formats. If you want to do this, set the number of iterations to ~3, set the threshold mode to "gradient" and set the threshold to:

Threshold = 0.5 * (MaxAlt - MinAlt) / (256.0 * HorizScale) <-- you need to calculate this

This will apply smoothing to any slope that is as steep as or steeper than one quantisation step.

If there's interest, I can bash-together a plugin to do all this in one click. Let me know.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby mauronen » Fri Jan 05, 2007 1:57 pm

Great work Aaron (as usual :wink: )
I tried to apply filter on GeoControl heightfield that previuosly has been rendered with a bunch of pyramids (it was like an hedgehog :lol: ), and it works very well.
Developing a plugin (with documentation) could be another great idea and could open the way that i previously suggested to you about heightfield filter plugins.
User avatar
mauronen
Doyen
 
Posts: 107
Joined: Sun Jan 22, 2006 11:06 am
Location: Rome

Postby Shealladh » Mon Jan 08, 2007 10:06 am

Cool, look forward to it. Btw, I'm with another bigger project now ;)
I take solice from the fact that I know nothing...compared to the rest of the world.
Shealladh
Contributing member
 
Posts: 49
Joined: Fri Sep 29, 2006 1:52 pm
Location: Melbourne, Australia

Postby monks » Mon Jan 08, 2007 8:16 pm

Nice, L3DT keeps rolling forward. Is this a step towards contours and interpolation...?

monks
monks
Oracle
 
Posts: 292
Joined: Tue Nov 22, 2005 10:38 pm
Location: Middle Earth

Postby Aaron » Mon Jan 08, 2007 11:34 pm

Hello,

Mauro wrote:Developing a plugin (with documentation) could be another great idea and could open the way that i previously suggested to you about heightfield filter plugins.


Ah, documentation is the problem here. There are plenty of example plugins (with source code), but none of them are well-documented. I should have some time in April to address this.

Regarding heightfield filters, users of the plugin API may like to note that I've added some zeofunc extension functions (available by zeofunc_GetFunc and callable by zeofunc_Execute and zeofunc_ExecuteThreaded) that include many of L3DT's heightfield effect filters. They're nested in the namespace 'calc.HF', and for instance this filter is called 'calc.HF.GradFilter'. You can view the available zeofuncs and thier argument lists using the new atFuncBrowser plugin (included with v2.5.0.2). Yet more functions are coming in the 3rd beta of v2.5, due next week. I'll write some documentation on this at some point also.

Monkschain wrote:Is this a step towards contours and interpolation...?


Not as such. This particular filter function was one of the first to be implemented in L3DT back in 2002 (-ish), but for reasons unknown I've only now made an interface for it. I think I just answered the contour and interpolation bit in the ME-DEM thread.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby mauronen » Tue Feb 20, 2007 7:32 am

Hi Aaron.
What do you think about:
    a) Modifiy Filter settings as follows:
      1) introduce input fields necessary to calculate threshold (MinAlt, MaxAlt,HorizScale) so that they can be tuned?
      2) automatically calculate threshold based on actual heightfield MinAlt, MaxAlt and HorizScale (or based on input fields set above) ?
      3) add a button (like "Recalculate") when settings changes?
    b) Alternatively (but more complex, i suppose)
      1) Merge, into Filter settings, same panels recalled through Heightfield > Change Horiz.scale... and Heightfield > Change Vert.scale... with actual parameters provided into panel (Threshold units,Max iterations,Slope threshold)
      2) Dynamically change Slope threshold parameter when each of other settings changes


And, what other types of values (other than Gradient) accept Threshold units?

Thanks in advance and cheers.

Mauro.
User avatar
mauronen
Doyen
 
Posts: 107
Joined: Sun Jan 22, 2006 11:06 am
Location: Rome

Postby Aaron » Thu Feb 22, 2007 1:47 am

Hi Mauro,

Yep, these are all good ideas. They're now on the to-do list.

mauronen wrote:And, what other types of values (other than Gradient) accept Threshold units?


Er...do you mean the 'degrees' and 'radians' options? These are just a different way to measure the gradient, as angles rather than rise/run ratios. For instance, I tend to think in degrees, and I do things like filter any pixels that have a change in gradient of more than ten degrees from their neighbours. To convert from degrees to gradient (the actual algo uses gradient, not angles), I use the formula:

grad = sin(angle) / HorizScale;

Radians are of course just another way to measure angle (1Rad = Pi/180 degrees, where Pi~3.14159).

Was this what you were asking, or am I off the mark?

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby mauronen » Fri Feb 23, 2007 12:12 pm

Hi Aaron.
Er...do you mean the 'degrees' and 'radians' options?

Er...i'm sorry Aaron. I haven't previoulsy saw that Threshold units field has pre-defined values (Degrees, Radians, Gradient). I thought that this field could be only editable.

I'm sorry.

Cheers.

Mauro
User avatar
mauronen
Doyen
 
Posts: 107
Joined: Sun Jan 22, 2006 11:06 am
Location: Rome

Postby dennis » Wed Apr 04, 2007 1:21 am

If you select an area of the heightfield does the filter only act on the selected part or does it always act on the entire heightmap?
dennis
Luminary
 
Posts: 65
Joined: Fri Aug 04, 2006 9:54 pm

Postby Aaron » Wed Apr 04, 2007 3:17 am

Hi Dennis,

At the moment it does the whole map. I'll put it on the to-do list to do area filtering.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to General discussion

Who is online

Users browsing this forum: No registered users and 38 guests