PDA

View Full Version : Heightmap Terrain flicker



Colin
31-03-2012, 01:10 PM
Hello there, I've been having a few problems with directx9 lately, i've implemented a simple brute-force (for now) terrain system into my engine, everything is working good apart from the terrain flickering, it seems it has something todo with the depth, i've tried disable culling and still no luck. I have uploaded a sample of what is happening. (Please ignore the progress bar, it is just from while i develop new interface controls)

w,a,s,d to move, spacebar to speed up movement, as you fly over above the terrain you will see the terrain in the distance flickers alot. Any ideas are welcome :)

DOWNLOAD LINK (http://www.overhertz.com/uploads/SURGEAPP.rar)

screenshot:
http://www.overhertz.com/uploads/surge1.PNG

note it is not using any textures

Regards,
Colin,

Dan
31-03-2012, 02:17 PM
my guess is you should try reducing the distance between the far and the near clipping plane which will increase the depth accuracy. you may also scale the whole landscape down to around 100x100 to improve the floating point accuracy. and finally you may want to change the depth format to D3DFMT_D24S8 instead of D3DFMT_D16 (assuming that you don't use that format already). btw what's the size of the landscape?

the landscape looks kind of upside-down here.

Colin
31-03-2012, 02:28 PM
i use depth format D3DFMT_D24X8, as for the size, it is 32x32 vertices scaled by 1500, i tried having the scaling very small and it was exactly the same problem, however i tried changing the near/far clipping plane and this seems to do the trick so thanks, what do you think would be a good value for these both?

Dan
31-03-2012, 02:32 PM
the difference between the near and far plane should be as small as possible. I normally try not to go over 1000

Colin
31-03-2012, 02:35 PM
excellent thanks, i will keep that in mind

about the landscape upside down, that is because i temporarily disabled culling, and the camera is starting below the surface, you can just fly up above the geometry - it is intended just for testing with for now :)

Dan
01-04-2012, 04:24 AM
dont mind if I show off my landscape here?

Colin
01-04-2012, 11:06 AM
that looks pretty good - i have moved onto texture splatting now, once i finish with multi-texturing my terrain, i will re-post also :)

Colin
01-04-2012, 12:57 PM
seems i have broken something, i can't understand why this is happening, my code for loading raw heightmaps is as follows:



SetLength(vertices, F_Vertices);
iVertices := 0;
AssignFile(f, filename);
Reset(f, 1);

// Loop across and up
for iy := 0 to F_VertsY-1 do begin
for ix := 0 to F_VertsX-1 do begin
BlockRead(f, height, 1);

// Create the verts
vertices[iVertices].x := (ix*tScale);
vertices[iVertices].y := height*tHeight;
vertices[iVertices].z := (iy*tScale);

vertices[iVertices].u := ix;
vertices[iVertices].v := iy;

Inc(iVertices);
end;
end;

CloseFile(f);


I have not changed anything since last night regarding heightmaps, but today it is doing some weird sheeat :D

screenshot >

http://www.overhertz.com/uploads/surge2.PNG

any ideas? :)


Never mind, seems my heightmap was corrupt :)

new screenshot >

http://www.overhertz.com/uploads/surge3.PNG

Dan
01-04-2012, 02:01 PM
looks much better than the first version ;)
how are you doing the texture blending? (vertex mask? texture mask? do you use layers or blend the textures in a single pass?)

Colin
01-04-2012, 02:23 PM
I am using 1 alphamap + 3 textures in a single pass via hlsl, i plan to add a 2 pass version to support more textures.... however i was also considering fitting more than 1 texture into a loaded texture file and messing around with u,v coords to have many textures in a single pass.

Dan
01-04-2012, 02:36 PM
do you have any plans for adding the bump mapping? that will double the number of texture slots you will need which makes a single pass blending a bit less attractive.

Colin
02-04-2012, 06:35 PM
after some planning i have decided i will most likely add a render stage system, allowing for multiple effect files for each stage, so i can have texture/diffuse, bump, lighting per stage.

Dan
02-04-2012, 06:50 PM
are you going to implement some sort of level of detail algorithm? I assume you do not use any yet, but when you increase the size of the landscape if you do not manage the number of vertices you use the performance will drop straight down to crawling. if you are planning to use some kind of LOD, it is, in my experience, much easier to start with that instead of lightning, texturing and blending implementation, because these stages depend a lot on how you implement your level of detail.

Colin
02-04-2012, 08:03 PM
i will most likely just implement a quad based render queue

EDIT

maybe you can help me out with something? :)

i'm fairly new to HLSL and i've ran into a difficulty... rather than hardcoding my alphamap scaler value i want to automatically stretch the alphamap across the whole terrain automatically.... any ideas how i can accomplish this? I was thinking of 2 options....

1: divide 1 by vertices of the terrain, so 64 vertices terrain = 1 / 64.
2: add an internal semantic into my effect loader to grab the dimensions of the model.

what do you think?