terrain engine and procedural content

rated by 0 users
This post has 4 Replies | 3 Followers

Top 500 Contributor
Posts 6
SunBurn_Community_Licensee
jmkinzer Posted: 10-17-2011 1:53 AM

Hi,

I'm having what is probably a conceptual problem with the terrain engine.

If I wanted to generate terrain procedurally could I somehow create a  RenderableMesh, and (for deferred rendering) a DeferredTerrainEffect, and assign the latter to the former?

Moreover, since the geometry for terrains is generated on the GPU directly from the heightmap (unlike other cases for meshes + effects) what is the mesh really for? Does it contain any geometry? Could I, for example, somehow render the terrain "onto" the given mesh, e.g. a sphere, or with e.g. a plane but with an object space rotation? (Does the terrain engine make assumptions that it's on a plane with a fixed orientation?)

Thanks,

Jason

Top 500 Contributor
Posts 6
SunBurn_Community_Licensee

Correction: since XNA doesn't support SM 4.0 there won't be any possibility of generating geometry. Therefore I assume what's going on is the system is creating a set of (static?) vertex/index buffers in the mesh and using something like a VTF technique to modulate the 'Z' component on the GPU? And thus part of what's going on when using terrain data in the content pipeline is precisely that mesh creation.

Unfortunately since the terrain engine is a complete black box when using the content pipeline it's hard to get a feel for how it works or how to use it 'manually'. Any information on this topic would be great...

Thanks,

Jason

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Jason,

Most terrain systems have a heavy dependency between the terrain data provided on the cpu and the gpu shader.  SunBurn's system is similar, its mesh data requires the terrain effect to provide height and infinite tiling, and the effect requires a certain mesh format to correctly process the geometry.

While the rest of the engine is designed to be as modular as possible the terrain is one place where we had to be less flexible for optimal performance and ease of use on the content side.

That said there are still a lot of things you can do with the built-in implementation - for instance you can procedurally generate any or all of the height, alpha, diffuse, and normal maps, then assign them to the terrain effect to build the terrain at run time.

Or if you'd prefer to use your own terrain mesh you can use the Blend effect in the Custom Effects example - it performs alpha blending and is the basis we used in the terrain effect's material.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 500 Contributor
Posts 6
SunBurn_Community_Licensee

Yeah... my requirements are quite different than what your implementation appears to assume (to begin with, my surfaces are roughly spherical), so I'll be on my own for this bit. Thanks for the reply.

Top 150 Contributor
Posts 24
SunBurn_Pro_Licensee

If I am not mistaken, you want to create a sphere with a deformed surface using the terrain engine. I am not sure any terrain engine right out of the box would not require very extensive modification to make that happen, to the point that you would be effectively rewriting the program. You would probably be better off creating a sphere with a number of shared vertices equal to the number of points on your heightmap (or put another way, the number of triangles*3), and then displacing each by the respective height coordinate of a heightmap. To do this, you will most likely need to use spherical coordinates with the center of the sphere as your central point, and then increasing or decreasing the radius of each point by the amount fed in by the heightmap. For a very good terrain engine tutorial and codebase, I recommend Riemer's XNA tutorial. Of course, if you intend to market this game I would recommend creating your own from scratch after learning the ropes with Riemer's tutorial or getting his permission to use his work in your software. You could then apply any Sunburn effects to the resulting vertices. I hope I helped!

Page 1 of 1 (5 items) | RSS