Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Marks on terrain

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 gnomgrol   Members   


Posted 21 October 2012 - 10:54 AM

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.


#2 Anddos   Members   


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 hupsilardee   Members   


Posted 23 October 2012 - 01:53 AM

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.

#4 BCullis   Members   


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.

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

#5 Gavin Williams   Members   


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 :

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);
  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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.