Terrain Questions

150 views
Skip to first unread message

Raster Ron

unread,
Apr 9, 2013, 9:30:11 AM4/9/13
to urh...@googlegroups.com
Hi,

I'm checking out the terrain features of the engine and I was wondering if it supports 8 textures through alpha/auto splatting.

Another thing is, can I use 3rd party tools to export the model and apply the terrain textures, like Artifex Terra (Ogre), L3DT or Earth Sculptor?

Lasse Öörni

unread,
Apr 9, 2013, 9:57:16 AM4/9/13
to urh...@googlegroups.com

Hi,
the terrain shader supports 3 texture blending via a simple weight map, so the answer is no. Of course nothing prevents you from writing your own terrain shader. While doing that, you may need to reorganize the material texture units, currently they're max 5 so that the total texture count doesn't go over the limit 8 units on GLES2 devices. The remaining 3 texture units are for lights.

If the terrain editor exports a grayscale heightmap and a weight texture for the blending (and limits itself to 3 textures, ie. R, G and B channels in the weight map), then it will be compatible.
 

Raster Ron

unread,
Apr 9, 2013, 10:39:08 AM4/9/13
to urh...@googlegroups.com

Thanks Lasse, I'll keep that in mind. So, one way I can achieve detailed textures is just use a standard model (mdl) file split it in chunks, apply collision shape and rigid body and "stitch" them together.

BTW, how do I apply collision shape on a Terrain, will this be done automatically? What is Terrain Patch that I see on the editor?

Sorry for asking a lot of questions all at once, I still need to get some grasp on what can be done with the Editor and assets creation.. :-)

Lasse Öörni

unread,
Apr 9, 2013, 10:54:06 AM4/9/13
to urh...@googlegroups.com
On Tuesday, April 9, 2013 5:39:08 PM UTC+3, Raster Ron wrote:

Thanks Lasse, I'll keep that in mind. So, one way I can achieve detailed textures is just use a standard model (mdl) file split it in chunks, apply collision shape and rigid body and "stitch" them together.

BTW, how do I apply collision shape on a Terrain, will this be done automatically? What is Terrain Patch that I see on the editor?

Yes, you absolutely can build the ground from pieces like that, and in fact you have to if you want to have caves or overlapping areas, as the terrain is just a simple heightmap.

To create a terrain heightmap collision, create a RigidBody + CollisionShape into the same node as the terrain, and select the "Terrain" type for the CollisionShape. It will then pick up the heightmap from the terrain automatically. Note that because terrains are potentially huge, the heightmap collision doesn't debug draw itself to avoid slowdown or even crashes.

Terrain is the "master" component, which isn't a drawable component by itself, instead it creates child nodes with TerrainPatch components which actually are drawable, and which can change LOD individually (but while still obeying certain stitching rules to avoid holes). TerrainPatches contain no editable attributes and should be generally be left alone, as the Terrain component manages them.

Raster Ron

unread,
Apr 9, 2013, 11:11:11 AM4/9/13
to urh...@googlegroups.com

Ok got it, thanks. As for creating rigid body and collision shapes for a model (.mdl) file. I'm just going to load the same .mdl file under collision shape and choose Triangle Mesh?

Lasse Öörni

unread,
Apr 9, 2013, 11:19:40 AM4/9/13
to urh...@googlegroups.com
On Tuesday, April 9, 2013 6:11:11 PM UTC+3, Raster Ron wrote:

Ok got it, thanks. As for creating rigid body and collision shapes for a model (.mdl) file. I'm just going to load the same .mdl file under collision shape and choose Triangle Mesh

Yes. Also, if it's suitable for the object in question (for a ground mesh it probably isn't), you can try choosing Convex Hull type instead, this will wrap the model's triangles with planes and be less computation-intensive. 

Alex Fuller

unread,
Apr 9, 2013, 11:14:55 PM4/9/13
to urh...@googlegroups.com
Hi,

I've been on a project where the world was in grid sections which fit well into an octree. So you'd make your art in logical asset bits and then at build-time you would 'polygon-soup' the geometry and split it up into renderer states eg. all the polygons in this grid with the same material/shader will be merged into the one mesh, and then do a boolean slice at the grid borders (which did add a small amount of verts to the final meshes). This would probably be a good way to make terrain also if you wanted overhangs and things, and the frustum cull and software occlusion query can cull the parts not visible from the octree. For distant grids you could create a LOD scheme that merges the geo and do a decimate on the geo and bake all the materials/shaders into one texture to reduce state changes.

Probably you'd whip up some kind of python pipeline in blender or a DCC package to do booleans, mesh merges, decimates, bakes, etc. before sending the model to AssetImporter, but to preserve collision shapes you'd need to work out a solution for that as all the meshes are polygon soup at the DCC->AssetImport stage (perhaps getting the root transforms of the static assets and making then non-renderable nodes with filled out components, not too hard to do it's xml). Also this approach is more for static things, not deformable terrain.

-Alex

Raster Ron

unread,
Apr 10, 2013, 3:49:50 AM4/10/13
to urh...@googlegroups.com
Wow Alex, that is a lot to think about :-) I will probably start with a smaller terrain to get a handle on things but I'll take note on your solution here. Anyway, I have managed to simply load and overlay the sample terrain to the NinjaSnowWar game. The editor ask for a .mdl model file to activate the collision shape and there's no example included, so is there an easier process or tool to add collision to a terrain?

Also, I'm getting a cut off on the camera and cannot see a farther distance. It looks like there's a problem with the near clip setting, but I can adjust this on the editor. I'm sure this is not a fog issue, so how do I correct this?

Here's a screenshot


Thanks.
Message has been deleted

Raster Ron

unread,
Apr 10, 2013, 3:54:37 AM4/10/13
to urh...@googlegroups.com

Ok got it. BTW, how do I add collision shapes on a terrain where the height map is only provided. Can you suggest a tool where I can generate the corresponding model and fit it to work with the terrain for collision?

Alex Fuller

unread,
Apr 10, 2013, 4:07:39 AM4/10/13
to urh...@googlegroups.com
Hi Raster Ron,

The clipping issue is due to the default ninja snow war ground mesh overlapping the terrain. To add collision you get the node that has the terrain component attached and add a collision shape component with terrain as the type, as well as attaching a rigid body component using the editor eg. ./Urho3D -w -s Scripts/Editor.as. The scene should already have a PhysicsWorld component if you're editing the ninja snow war scene file, if it doesn't make sure to add it to the Scene root node. You might want to disable gravity and leave mass at 0 and 'Is Kinematic' at 0 I think, to keep it static.

Raster Ron

unread,
Apr 10, 2013, 4:53:30 AM4/10/13
to urh...@googlegroups.com
Ok, but I'm not sure the ninja ground mesh is doing that or maybe I am missing some settings. As you can see, the original mesh (level.mdl) is showing completely and the rest of the terrain is shaded with the zone ambient light (I think) that I have set. It looks like a clipping issue.

Here it is again in editor view, at the same spot and same scene file. As you can see, at least the higher part of the terrain is being shown (with the fog) because I have adjusted the camera clipping to a higher value in the editor. In the game it's not doing that.

http://i.imgur.com/IxVkNd8.jpg

In the editor, I can set the clipping where or how I want it, but in-game it's stuck with a close camera clipping.

I'm attaching the scene file, maybe you can help me correct this small issue? :-)
Scene3.xml

Raster Ron

unread,
Apr 10, 2013, 5:34:12 AM4/10/13
to urh...@googlegroups.com
Ok I solved it. It turns out that I forgot to set the game script far clip..

gameCamera.farClip = 70000.0;

silly me :-p
Reply all
Reply to author
Forward
0 new messages