Jump to content

  • Log In with Google      Sign In   
  • Create Account

XNA terrain painting


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 Tasaq   Members   -  Reputation: 1253

Like
0Likes
Like

Posted 09 May 2013 - 08:10 AM

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, 09 May 2013 - 08:12 AM.


Sponsor:

#2 VladR   Members   -  Reputation: 722

Like
1Likes
Like

Posted 09 May 2013 - 08:46 AM

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

 


#3 Tasaq   Members   -  Reputation: 1253

Like
0Likes
Like

Posted 10 May 2013 - 04:18 AM

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



#4 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 10 May 2013 - 08:07 AM

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

 


#5 Tasaq   Members   -  Reputation: 1253

Like
0Likes
Like

Posted 13 May 2013 - 09:50 AM

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






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.



PARTNERS