Marks on terrain

Started by
3 comments, last by Gavin Williams 11 years, 6 months ago
Hello,
I'm currently working on my terraineditor.
At the moment I try to mark the part I edit with a circle. I tried to project it onto the scene with usual projected texturing, but that gave me some pretty wierd results. Now I want to ask if there is a better and more performat version to do this, or if what I did was going into the right direction.

Thanks
Advertisement
I dont know how todo what you do , but i was wondering how do you control the vertex buffer with mouse , like increasing the y vertices etc with left mouse button , i know you lock the vertex and index buffers but i dont know how you increment those locked vertices etc..
:)
Keep your own copy of the heights array

float Heights[width*height]

When the user clicks the mouse, loop through the region that is affected and increment as desired.
Then re-copy the array to the vertex buffer.

Is how I did it in a terrain editor I once made. It was highly performant even with a 1024x1024 terrain - the bottleneck was the rendering not the updating once the terrain reached that size. If you want to go much larger than 1024x1024 you could make a paging system.
I'm assuming you're talking about drawing the pointer/editor itself rather than modifying the terrain underneath the mouse. If that's not the case, disregard.

I use picking to translate mouse screen-position to the world position on the terrain that the mouse is hovering over, then render the circle that represents the "brush" originating at that world-space point, just like any other 3d object in the scene. I do that as the final part of my draw call so that it's always visible over the terrain.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

I pick the terrain point and basically render a light onto the terrain at that point. In the past I have just put that code in inside the terrain shader, but now I have it as a post process utilizing the position map in my gBuffer. The pixel shader is as follows :


float4 PShader(PSIN input) : SV_Target
{
float2 terrainPosition = gGBufferPositionUn.Sample(PointSampler, input.texcoord).rg;
if (distance(terrainPosition,gBrushPosition.xy)<gBrushRadius && distance(terrainPosition,gBrushPosition.xy)>gBrushRadius-0.1)
return float4(0.8,0,0,1);
else
return float4(0,0,0,0);
}


I'd say that it's not very performant though, as it's fullscreen. For me right now, I'm still at 60fps so I haven't yet found the need to go over things for performance, but that is
certainly an easy way to do it if you are having problems.

This topic is closed to new replies.

Advertisement