Re: [Algorithms] Tangential Curvature of terrain
Brought to you by:
vexxed72
From: Klaus H. <k_h...@os...> - 2000-08-22 04:37:25
|
Thanks, Joe :) At some point I'll try everything I can get my hands on. I'll collect all those mails, and will try other algorithms as soon as this terrain sample is finished (do some improvements afterwards). At the moment I have a solution that looks pretty cool. And guess what... it's the solution that I thought would never work. I was wrong and the results can look just beautiful, and it nicely breaks up the transition between two ecosystem. What I did is this: For each data point Pm,n in the height field compute the elevation-difference between Pm,n and its eight direct neighbors. Sum these differences up and average them, by dividing the sum by 8. The result is a single value R (for each data point). I then modify the elevation line as follows: elevLine' = elevLine + R * ecosystem.relEffect; where elevLine' is the new elevation line, elevLine is the elevation line of the ecosystem after elevation skewing (or before - shouldn't matter), and relEffect is a scale factor which you can use to increase/decrease the effect. You would honestly be surprised by the results of this simple solution. There are places in my terrain that look almost real, and I could further enhance this by casting shadows. ...And I thought it wouldn't work. Niki ----- Original Message ----- From: Joe Ante <jo...@ti...> To: <gda...@li...> Sent: Monday, August 21, 2000 3:19 PM Subject: Re: [Algorithms] Tangential Curvature of terrain > > Basically, the curvature of a function is its second derivative. > I think geometrically viewn this is not the correct answer. Take as an > simplyfied > example: f(x) = x^2 f''(x) = 2 > > Which meant that for every point the concavity/convexity is the same over > the entire graph. > > What this concavity/convexity value actually specifies is how high a heixel > is in respect to the heixels in some distance around it. Maybe even in > respect to all heightsamples in the heightmap. > > Consider for example an huge crater landscape and in the middle of this > crater there is a small hill. > > The question now is, is the heixel on top of this small hill inside the huge > crater, more convex or concave? > > > So what you want is that heixels that are near have more influence than > heixels that are far away from the heixel, whose concavity/convexity you > want to find out. > > > So what you need to define is a function with a maximum distance, which > gives you out a value between 0...1 when you give it a value from > 0...maximumdistance. > y = f (x) > x e [0...maximumDistance] > y e [0...1] > > A gauss-like curve is propably best suited: > y = 360^-((x/maximumDistance)^5) > (This function has worked out for me just fine.) > > > Pseudocode: > > float ConcaveConvex (long inX, long inZ, float inMaxDistance) > { > float itsHeight = GetHeight (inX, inZ); > float c = 0; > > for (z=0;z<HowmanyHeixels;z++) > { > for (z=0;z<HowmanyHeixels;z++) > { > float difference = itsHeight - GetHeight (x, z); > float d = sqrt ((x-inX)*(x-inX) + (z-inZ)*(z-inZ)); > c += difference * GaussFunction (d, inMaxDistance); > } > } > > c /= HowmanyHeixels* HowmanyHeixels; > return c; > } > > float GaussFunction (float inX, float inMax) > { > return powf (360.0F, -powf (inX / (inMax), 5.0F) > } > > float GetHeight () should give back a height scaled to [0...1] in this > context. > > > > There is plenty room for optimization here (tables, tables, tables) > But even then it will be very slow. But it doesnt matter that much because > you dont want to calculate the ecomap in realtime or as a preprocessing > phase step anyways. > > > Note that I havent integrated this into my terrain engine yet, I have only > spent some thought on it, so I cant really guarentee that it works. > > bye joe > > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > |