Jump to content
  • Advertisement
Sign in to follow this  
Tasaq

DX11 XNA terrain painting

This topic is 1957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Edited by Tasaq

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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 :-)

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!