Sign in to follow this  
Shanee

GPU clipmaps texture question

Recommended Posts

Shanee    207
Hi!

I implemented GPU Clipmaps to replace my old Chunked LoD system and I have texture splatting of up to 5 texture but I have a problem:

The whole idea of GPU Clipmaps and the system I am using now is so it streams the height data from disk as needed and the terrain can continue forever without loading screen. But how would I go for changing the 5 texture I am blending on the go? considering that I am filling up heights into a height map in real time as is done in the Clipmaps technique, it means that I can't just say "from this chunk use those other 5 textures" as there are no specific chunks when it moves to the Clipmaps.

Anyone may have an idea on that which allows to keep the open world with no loading or zone transitions but still allow for smooth change of the 5 blending textures?

Thanks in advance :)

Share this post


Link to post
Share on other sites
Funkymunky    1413
Well, how are you streaming in your other textures? If you're using heightmap data from the disc, you still need to stream in those source textures to sample from when rendering your toroidally accessed heightmap. You would need a similar streaming mechanism for changing the splatting textures too.

Share this post


Link to post
Share on other sites
Shanee    207
I can easily stream textures from disc, the problem is that due to the nature of geometry clip mapping I can't just say "from this line start using those 5 textures instead" as it will change everything to use the 5 textures, also there are no specific borders in GPU clipmaps, as it works by dynamically filling a height texture that creates different levels.

I could instead stream a whole texture and use something like mega texturing but somehow I feel that will be both harder to edit and harder to create good detail per pixel.

Share this post


Link to post
Share on other sites
SergioJdelos    468
Are you using D3D9 (or OpenGL 1.x/2.x) or D3D10/11 (or OpenGL 3.x/4.x)?

If you are using D3D10 or up, you can use a Texture Array with the diferent textures in each slice in combination with a Index Map (a texture with indices).

Share this post


Link to post
Share on other sites
Funkymunky    1413
well wait a second, you have to be using Shader Model 3.0 because the algorithm relies on vertex texture fetch.

if you want to have different splatting sources for different sections of the terrain, you'll need to store that data then. You're already storing the height data and the normals... why not store a splat index in the alpha channel of the normals texture you generate? Regardless, you have to have some system on the CPU that determines what splatting textures are necessary to render the map from the current position, so as to bind them before rendering your vertex data.

Share this post


Link to post
Share on other sites
Shanee    207
Yes, I am using shader model 3, this was never asked.

I can put the blend map and stream it to the texture, I have, I said that already.
Are you suggesting to put 20 different texture and choose which 5 of them to take by using the alpha value of the normals texture as an index?

I could do that, but as far as I remember reading "dynamic branching" isn't that effective and it will be as if it sampled all possible 20 textures, which will be a performance kill. So is it?

Share this post


Link to post
Share on other sites
Funkymunky    1413
you'll have to come up with some kind of system within your framework (perhaps a quadtree?) which let's you know exactly which textures are going to be necessary based on your current position within the terrain. branching in the shader is irrelevant; you have to know exactly which textures to upload to the card in order to draw the full terrain from an arbitrary position within your height data.

Share this post


Link to post
Share on other sites
Shanee    207
Quote:
Original post by Funkymunky
you'll have to come up with some kind of system within your framework (perhaps a quadtree?) which let's you know exactly which textures are going to be necessary based on your current position within the terrain. branching in the shader is irrelevant; you have to know exactly which textures to upload to the card in order to draw the full terrain from an arbitrary position within your height data.


Knowing which textures I need is not the problem as I said, the problem is the way GPU clip mapping works that there are no specifically defined quads that I can say "here start using those 5 textures for the splatting" as you feel in the heights as you move around into a texture from a steam.

Share this post


Link to post
Share on other sites
kauna    2922
I am having the same obstacle too with my clip maps.

At this moment I am using two RGBA alphamaps to have up to 8 textures for the whole terrain. I haven't noticed too big performance hit with sampling so many textures, but it is something that I know that could be done better. Besides it is rather limiting to have just 8 textures for huge terrains.

I remember reading a paper about using one big textures (like 4k) for each of the nested grids. I can imagine that a texture of that size should be precise enough for at least distant terrain. You can stream and or generate the data for that terrain texture as you do for you terrain geometry, and it should be cheaper to sample one texture instead of 5 or more.

For the grids nearby your camera you'll probably need some sort of detail texturing, but there you can sacrifice a bit texture fillrate.

Cheers!

Share this post


Link to post
Share on other sites
Funkymunky    1413
You could have a quadtree where each node defines the 8 texture ids necessary to render a terrain from within that node. When you cross into a new node, you'll have to stream in any new textures that are needed for that node. Neighboring nodes will probably have a lot of texture ids in common, as this would be necessary for transitioning from one terrain type to another.

Share this post


Link to post
Share on other sites
Shanee    207
As I said, streaming isn't the problem.

GPU Clipmaps works by having this LoD grid as in this photo:
http://http.developer.nvidia.com/GPUGems2/elementLinks/02_clipmaps_02.jpg

That is actually a static vertex buffer always centered at camera's position.

You fill in the heights into a floating texture as you move around.

That's why you can't have a defined node in the Clipmaps, I can say "this area should use those 5 textures and that one should use the other 5 textures" but when I set the textures for the shader to use in multi texturing, the areas get blended because as you have no defined borders, instead you fill in the heights.

Meanings that the same grid has X amount of vertices that belong to one node and Y amount of vertices belonging to another node, so if I put 5 textures, some of the areas will show up with the wrong textures being blended in.

Share this post


Link to post
Share on other sites
Funkymunky    1413
Dude, I know how the algorithm works, I've implemented it myself. That's why I'm trying to reply to you here. You currently blend a set of 5 textures together to draw your terrain. You're wondering how to cleanly switch to another 5 textures to draw a different style of terrain.

How do you currently determine which texture of the 5 to sample from? I assume that since you're already rendering your height texture and normals texture (as per the original algorithm), you might be doing something like storing a value in the alpha channel of the normals texture to indicate which texture of the 5 to sample from.

So, if you want to switch to a different 5 texture set, you still have to account for the original 5 that might be necessary for rendering the terrain up to that point. You have to account for all possible necessary textures, so in the region in between the two distinct textured sets, you'd need all 10 bound (so as to draw terrain of either variety).

Therefore, if you had a quadtree mechanism set up that tracked the position of the player, you could determine exactly which sets of textures needed to be loaded at all times. This system could also pass a uniform to the clipmap update shader to help it write out your splatting value, handling the offset for the transition between the texture-set regions.

Share this post


Link to post
Share on other sites
Shanee    207
Thanks Funkymunkey,

First.. I am not a dude.

Second, yes, I know exactly which textures I am going to need and I understand what you are saying about needing to account to up to 10, actually up to 20 if you were to stand right in the middle of a 4 quads intersection which by chance all have different textures.

Thing is, that's the problem, isn't it? It is going to need 20 texture samples. I didn't quite I understand the last bit you said, did you mean to just add a a separate pass with a different shader for the transition parts?

Share this post


Link to post
Share on other sites
Funkymunky    1413
Your shader decides which of the 5 textures to sample from to draw the terrain. It picks from textures 1-5. For the second terrain type, it will sample from 6-10. I think, given some uniform input driven by the quadtree system (or whatever you decide to go with), you could tell it to sample from textures 1-5 or textures 6-10. You could do it all in a single pass as long as you have a manager that decides which textures need to be loaded and what uniforms need to be passed to the shader to let it know which texture set to draw from.

So the shader will determine that it needs texture 1, but the manager will realize that this is a block being drawn with the second texture set, and so it should sample from texture 6 instead. Once you're far enough "into" the second terrain type, you can stream in a third terrain type to replace textures 1-5, and then transition to that third texture set.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this