Advertisement Jump to content
Sign in to follow this  
martyj2009

OpenGL OpenGL terrain

This topic is 1831 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

I was wondering if I could get some input on managing terrains with OpenGL.

 

For terrains I'm using a heightmap. I also have a corresponding texture map which designates the textures to use for each vertex.

 

The texutres are loaded with a GL_TEXTURE_ARRAY_2D accessed by a textureIndex.

 

This allows me to change the texture at a given point to a path based texture, grass, ect.

 

I know other people out there use height of a verticie to indicate the texture to use. My problem with this is, how would I ever designate paths in my terrain?

 

How does everyone else manage terrains?

Share this post


Link to post
Share on other sites
Advertisement

Are you asking how to store pathing data in a texture? If so, think of the terrain as a grid and each cell of the grid is a pixel of the image. You can then store bools for whether you can go each direction from a given cell (pixel). That's usually not even necessary since there are usually rules (can't climb X elevation change as an example). It is useful in some limited situations though.

 

Unless you're using path data in a shader, there is very little reason to use a texture though. You'd often duplicate the data anyways since you still need to write code that can path with better knowledge than just neighboring cells unless you don't have AI players and don't allow the user to move to distant points with a single action.

 

If that's not the answer you're looking for, you might try posting in a more general forum than OpenGL. It sounds like you're asking about pathing, terrain, etc. in general, not anything specific to OpenGL.

Share this post


Link to post
Share on other sites

If you are asking what i think you are asking I also use texture arrays but I store selection info in the vertex RGBA components. (up to) 2 textures and a transparency for belding (if req)

Share this post


Link to post
Share on other sites

Automatic selection of textures for grass, rocks, cliff-sides, etc. is one part, but paths need to be manually drawn through the terrain via some kind of editor.  Your terrain system needs to support not only automatic texture selection based on height and slope, but also manual texture applications for artists.

 

 

L. Spiro

Share this post


Link to post
Share on other sites

Depends what you mean by "path" is this just where you can walk on the terrain? OR do you mean painting dirt trails and such?

Typically for AI paths, you take the height map and create an array of walkable squares. Each square is walkable if the normal of it is pointing up towards the sky. For instance a 45 degree slope might be your cap:

if (dot_product(Tile.normal, Vec3(0,1,0)  < .5) { // terrain tile is tagged as walkable;}

Share this post


Link to post
Share on other sites

You could have a look at texture splatting.

If you use all four channels of a splat/detail texture you can have four types in a single base texture, resulting in four possible textures. I'm using two splat textures so i can have up to eight different textures applied to the terrain. This is more than enough for a single terrain patch.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!