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
4 replies to this topic
Sponsor:
#2 Members - Reputation: 271
Posted 22 October 2012 - 08:24 AM
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..
:)
#3 Members - Reputation: 442
Posted 23 October 2012 - 01:53 AM
Keep your own copy of the heights array
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.
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.
#4 Members - Reputation: 1673
Posted 23 October 2012 - 10:57 AM
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.
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.
#5 GDNet+ - Reputation: 472
Posted 24 October 2012 - 04:34 AM
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 :
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.
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.






