Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


OpenGL terrain


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
5 replies to this topic

#1 martyj2009   Members   -  Reputation: 114

Like
0Likes
Like

Posted 11 January 2014 - 01:02 PM

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?



Sponsor:

#2 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 11 January 2014 - 04:58 PM

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.



#3 empirical2   Members   -  Reputation: 567

Like
0Likes
Like

Posted 12 January 2014 - 04:51 PM

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)



#4 L. Spiro   Crossbones+   -  Reputation: 14026

Like
1Likes
Like

Posted 13 January 2014 - 11:53 PM

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


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 dpadam450   Members   -  Reputation: 934

Like
0Likes
Like

Posted 15 January 2014 - 04:57 PM

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;}



#6 Murdocki   Members   -  Reputation: 274

Like
0Likes
Like

Posted 17 January 2014 - 01:00 PM

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.






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