XNA terrain painting

Started by
3 comments, last by Tasaq 10 years, 11 months ago

Hi,

I have terrain code with fancy stuff done but everything is read from files (heightmaps, blendmaps etc.). I would like to make editing possible on runtime, like pushing the heightmap or painting with textures. My problem is I don't know how to get texture coordinates of place on map I picked with cursor. For example to paint a road on terrain with sand texture.

Also I am using tessellation + displacement mapping, so my vertex buffer cotains simple quad, which makes host side closest ray-triangle itersection test rather useless. Another thing is that I can use compute shader (I got access to dx11 features in my XNA project), so I have possibility to speed things up smile.png I am also using deffered shading so I got depth buffer stored in render target texture (maybe I can use that somehow?).

Any ideas how I can achieve what I want to do?

Advertisement

You could do the Picking on the quads and just adjust the vertices of the quads.

Have a preview window/RT with the tesselated output on left side and the rough mesh with the quads on right side.

Other option would be to just pre-tesselate the mesh and use that for picking and rendering.

In the end, it's up to you, how much control you want to have over the physical mesh vs the post-tesselated look.

You have to decide, where on the sliding scale, you want to be.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

Other option would be to just pre-tesselate the mesh and use that for picking and rendering.

That's good idea, thanks:) I also have been thinking about editing textures directly with model preview. I will try both options and see which is more convenient :)

If someone got other ideas and tips for terrain editors I will be thankful for sharing :)

That's good idea, thanks:) I also have been thinking about editing textures directly with model preview.

That is certainly an alternative, although probably the most time-consuming to implement you must implement a system of brushes that will seamlessly blend, undo/redo and the UI part of it to seamlessly handle painting between 2D and 3D elements.

That's quite an undertaking, if you ask me :-)

Pretesselating and picking is pretty easy compared to that - so if you don't have the time to burn, I'd go with that first :-)

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

I did with very simple method. I sent to shader my cursor position in screen space. I read depth in that position from my depth buffer, then I did depth to world position transformation, that way I get the point my cursor is picking. Since I know my terrain position and dimmensions, I simply do (pickedPoint.xz-TerrainMinValue)/TerrainMaxValue - this way I get picked texture coordinate on my terrain displacement map. It works fine :)

This topic is closed to new replies.

Advertisement