void CTerrain::ErodeBand(float* pBand, int Stride, int Length, float Filter)
{
float Previous = pBand[0];
int Current = Stride;
int i;
for(i = 0; i < Length-1; i++)
{
pBand[Current] = Filter*Previous+(1-Filter)*pBand[Current];
Previous = pBand[Current];
Current+=Stride;
}
}
And here's the code that loops through all lines-
void CTerrain::ErodeImage(float* pImage, float Filter)
{
int i;
for(i=0; i, Size, Size, Filter);
}
for(i=0; i<Size;i++)
{
ErodeBand(&pImage[Size*(Size-1)+i], -Size, Size, Filter);
}
}
I've been working on this for days and I know it has to be something simple I just can't see. Can anyone help me?
—————————–
Weeks of programming can save you hours of planning.
There are 10 kinds of people in this world– those who understand binary and those who don't.
<SPAN CLASS=editedby>[edited by - sofsenint on October 4, 2003 11:20:57 PM]</SPAN>
<SPAN CLASS=editedby>[edited by - sofsenint on October 4, 2003 11:21:27 PM]</SPAN> </pre>
<SPAN CLASS=editedby>[edited by - sofsenint on October 4, 2003 11:22:09 PM]</SPAN>
<SPAN CLASS=editedby>[edited by - sofsenint on October 4, 2003 11:23:26 PM]</SPAN>
erosion-blur
I've been working on a terrain generator using Trent's book Focus on 3D Terrain Programming. Right now, I'm using the fault formation technique. After I create each fault, I blur the image using the erosion blur presented in the book. However, the heightmaps end up with huge drop offs, and don't look at all blurred. Here is a sample heightmap- http://www.angelfire.com/ia3/sofsenint/Image1.gif
My code seems to be almost exactly like what I see in Trent's code.
Here's the function that blurs an individual line-
I found my problem- I wasn't "normalizing" the terrain like Trent does in his code. But now I've discovered a new one. When I generate terrain, it renders just fine. However, if I save it, there is a chunk of the image that is misplaced. Example-
www.angelfire.com/ia3/sofsenint/image2.gif
If you look closely, you can see that those misplaced pixels on the left would match up if you dragged it to the other side of the pic. This error is not there when I first generate the heightmap and render it, but it is in the heightmap when saved and loaded. This is strange, because my saving routine just writes the whole thing as a chunk. Another strange thing about it is that this error only occurs in generated terrain- if I load a pre-made heightmap and then save it, the patch of misplaced pixels does not show up in the saved file. What in the world could be wrong?
-----------------------------
Weeks of programming can save you hours of planning.
There are 10 kinds of people in this world-- those who understand binary and those who don't.
[edited by - sofsenint on October 5, 2003 5:59:54 PM]
www.angelfire.com/ia3/sofsenint/image2.gif
If you look closely, you can see that those misplaced pixels on the left would match up if you dragged it to the other side of the pic. This error is not there when I first generate the heightmap and render it, but it is in the heightmap when saved and loaded. This is strange, because my saving routine just writes the whole thing as a chunk. Another strange thing about it is that this error only occurs in generated terrain- if I load a pre-made heightmap and then save it, the patch of misplaced pixels does not show up in the saved file. What in the world could be wrong?
-----------------------------
Weeks of programming can save you hours of planning.
There are 10 kinds of people in this world-- those who understand binary and those who don't.
[edited by - sofsenint on October 5, 2003 5:59:54 PM]
Looks like you''re on win32 platform and have you write files in text mode, windows writes 0x0D 0x0A instead of 0x0A. It seems valid, because the shifting only occurs on the dark patch
Open your file in binary mode when saving you bitmaps.
Open your file in binary mode when saving you bitmaps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement