Jump to content
  • Advertisement
Sign in to follow this  
LPVOID_CH

OpenGL Terrain splatting

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

Hi all In my terrain engine I use terrain splatting (opengl/glsl) and it works quite well. I am using an alpha map with the 4 rgba channels. so, i can only use 4 different detail textures for splatting. my terrain's size is 256*256. i would like to use more detail textures than four. i read a variant where all detail textures are in one big texture (16 x 512*512 textures in a big 2048*2048 texture). but then, i have to generate the mipmaps myself and the shader is not straight forward. i could also use more texture samplers but the alphamap is limited by 4 chanels. I read also an approach to tile my terrain in patches, and then apply for each patch an alphamap. but i want to avoid this way, because it complicates the thing for my terrain editor (which supports terrain painting) anyone knows an article or a solution to have more than 4 detail textures and using only one alphamap for the terrain? I would be satisfied if I could use 8 detail textures. thx for your suggestions

Share this post


Link to post
Share on other sites
Advertisement
The easiest solution to me would be just using a second alpha texture. Of course this only works if your system supports that many texture samplers.

Another solution would be rendering the terrain in two passes. First with the lower 4 textures (without blending), then the other 4 (with additive blending).

Maybe 3d textures can help. Using the alpha value both as an index (texture coordinate) and for opacity. Of course this limits the number of bits for opacity and you still can't have more than 4 detail textures per fragment.

Share this post


Link to post
Share on other sites
It is actually possible to pack multiple values into a single one. Just search google for "glsl pack float to integer" and you might find something useful. When you do so you then have to manually filter the texture in the shader and also manually create mipmaps as the default linear or mip mapped interpolation produces wrong result in this case. Also if you store 2 values in a single 8 bit channel you can only have 4 bits per values which means you get only 16 different possible values for each variable which is probably too few.

I would advide to simply use an additional alphamap texture. Depending on how you implement things you could also have 5 detail textures with just a single alphamap.

Share this post


Link to post
Share on other sites
Do you really need a painted alpha map for each chunk?

You could also subdivide you terrain mesh and use texture coordinates to pass the blending factors to the gpu,
thats straight forward, each texture coordinate allows for 4 blend weights and you have up to 7 available, texcoord0 is used for the actual tex coordinates, with vertex attributes you may be able to pass even more, but frankly, who uses more than 16 detail textures?
That would be a good point to think about "mega textures", which you could also generate at runtime instead of streaming them from the HD.



Share this post


Link to post
Share on other sites
thank you for the approaches

i like the idea with texture coordinates, as i said, 8 detail textures are enough for my terrain. but using two alpha maps is also a good idea. but then i have 2 samplers used for the alpha values. i think the max texture units for a shader is 8 or 16 (depending on graphic cards) or can I assume that modern gpu's support at least 16 texture units for a shader?

cheers

Share this post


Link to post
Share on other sites
There's a quick way you could get one extra channel - make your 5 channels always sum to 1.0. That way the 4 channels you actually store implicitly define the 5th channel value : 1.0-(sum of 4 channels).

Storing the weights per vertex may make LOD changes more noticeable than using a texture, depending on your data and LOD scheme.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!