sjcomp
27-06-2006 01:22:55
I suppose it is a very basic question... How do I draw a grid on top of the terrain? If I want to create what would be long and lat lines on the map, though I want them follow the profile of the terrain.
Thanks.
zeroskill
27-06-2006 07:05:46
This isn't PLSM2 specific, it works for generally all terrain renderers that support tile based texturing.
Absolutely easiest way to do this is to make a splatting texture that contains the lines you're after in whatever color you desire (or use white and let the material diffuse color do all the coloring), and anywhere that the line isn't visible, use 0% alpha so that it allows the existing pixel colors to show through. Then apply it as a texture that covers the whole terrain. (If you aren't using splatting, then this is just one of the blend textures.) Make sure you use 'nearest' texture filtering unless you want blurry lines.
Since the lines are drawn as a texture pass, they will be drawn directly onto the terrain polygons, which gives you the contour you are looking for.
sjcomp
27-06-2006 13:37:21
(If you aren't using splatting, then this is just one of the blend textures.)
Thanks, zeroskill! I am not using splatting at the moment, could you explain a little more about how I do it with blend textures?
I was thinking more a long the lines of being able to set the distance between the lines within the program, but if I am using textures grid size is not easily controllable.
syedhs
27-06-2006 14:18:34
sjcomp
27-06-2006 14:37:27
Thank, syedhs. It was an answer to another question that I had
Though I do not see how I can have a decal projected on the whole terrain with the lines still being thin. I am thinking along the lines of making an effect if there is a second path of rendering the terrain with mCamera->setPolygonMode(PM_WIREFRAME). So there is a solid mesh with a wireframe on top of it. I can not use wireframe because it is too dense and it has triangles as opposed to quads.
Falagard
27-06-2006 18:15:49
You could use Line3D which draws a line from one point to another and manually build your grid out of many Line3Ds. Line3D is actually pretty intensive though because I think each line is formed from 2 triangles.
Anyhow, if you were going to do it using Line3D you'd decide how far apart you'd want your grid cells to be and get height using a SceneQuery with the get height flag (forget what it is exactly). And to ensure that your lines appear over the terrain at all times, even if it is slightly below in some areas, you could assign a material to the line3d that has depth_check off, which means it'll ignore the z buffer for depth testing.
Clay
sjcomp
27-06-2006 19:28:11
depth_check off would allow me to see the lines, but they would not follow the terrain profile in between the crossing points.
How intensive would it be to access vertex buffer of the terrain and make a second render path to draw the terrain wireframe on top of the terrain? I would like not to draw every vertex, meaning that I want to skip a few vertecies to have a less denser mesh. Because of the LOD I would not be able to create one mesh and use it all the time, I have to update it every frame. Another quesiton is how I can do this second path and apply it to the already rendered image...
Well it looks a little more complicated, once I started to think about it. I would have to render the terrain, then render the grid, and after that render objects that are on top of terrain if I want them to occlude the grid as well as the terrain... This sounds too complicated.
Falagard
27-06-2006 23:20:01
depth_check off would allow me to see the lines, but they would not follow the terrain profile in between the crossing points.
Depends on how far apart your grid points are spaced. Lets say terrain has a vertex every 2 meters when at highest LOD, and you also have your grid at 2 meters, the problem is when the terrain starts using lower lods, there are fewer vertices, which is why you want to turn depth testing off.
Yes, with Line2D based grid you'd probably need to recalculate the grid as you move around every certain number of units the camera moves you'd recalculate the grid.