Sign in to follow this  
Waaayoff

How to generate the elevation maps for GPU based geometry clipmaps?

Recommended Posts

Waaayoff    952
The lowest (coarsest) elevation map is simply the height map, right? What about the finer levels? How do i create their elevation maps?

Share this post


Link to post
Share on other sites
smasherprog    568
Use mipmaping. Create your heightmap as a texture on the gpu, and make sure the gpu generates mipmaps for it. Then, when you are sampling the heightmap, you have mipmaps to give you coarse or fine grained results.

Share this post


Link to post
Share on other sites
Waaayoff    952
[quote name='smasherprog' timestamp='1339271179' post='4947728']
Use mipmaping. Create your heightmap as a texture on the gpu, and make sure the gpu generates mipmaps for it. Then, when you are sampling the heightmap, you have mipmaps to give you coarse or fine grained results.
[/quote]

But, aren't mipmaps by definition smaller and at a lower resolution than the original texture? How can they represent finer levels?

Share this post


Link to post
Share on other sites
Waaayoff    952
Yeah, that makes sense.

Well i still don't know how to obtain the elevation maps for each level. In the paper they talk about synthesis and decompression.. But then how does the mipmapping fit into this... I'm so confused!!!

Someone please explain all of this to me...

Share this post


Link to post
Share on other sites
L. Spiro    25638
[quote name='Waaayoff' timestamp='1339264761' post='4947708']
The lowest (coarsest) elevation map is simply the height map, right? What about the finer levels? How do i create their elevation maps?
[/quote]
Your terms are confused. “Coarse” means “rough and without detail” while “fine” means “with detail”. Course is the far set of the terrain and fine is the single mesh that is right beneath you with the highest level of detail.


[quote name='Waaayoff' timestamp='1339272992' post='4947736']
But, aren't mipmaps by definition smaller and at a lower resolution than the original texture? How can they represent finer levels?
[/quote]
Each mipmap is the next coarser level.


[quote name='Waaayoff' timestamp='1339349098' post='4947962']
Also, in the paper they keep saying "toroidal access". What does that mean?
[/quote]
It means as the heightmap texture is being modified on the GPU, anything the falls off one edge wraps to the opposite edge, and as such when you are accessing the heightmap texture you need to do the same. Trivial with the repeat wrap mode.


[quote name='Waaayoff' timestamp='1339349657' post='4947967']
Yeah, that makes sense.

Well i still don't know how to obtain the elevation maps for each level. In the paper they talk about synthesis and decompression.. But then how does the mipmapping fit into this... I'm so confused!!!

Someone please explain all of this to me...
[/quote]
[url="http://research.microsoft.com/en-us/um/people/hoppe/gpugcm.pdf"]http://research.microsoft.com/en-us/um/people/hoppe/gpugcm.pdf[/url]

The 2.4.1 Upsampling section is talking about artificially generating even finer levels of detail and is used by the 2.3.5 The Vertex Shader section for interpolating between levels. For your basic implementation you don’t need to worry about this yet. It is designed to prevent holes between the rings, which is something you should handle after you have a working prototype.

Figure 2-1.
Each level of the pyramid represents a different mipmap level of the heightmap texture. Each ring reads from its own mipmap level. It is possible for you to use only one level (no mipmaps) but using mipmaps allows you better filtering potential (better interpolation between points) and reduces texture reads.

The 2.4.2 Residuals section is just talking about adding extra detail. It is optional and you should ignore it until you have a working prototype.


L. Spiro

Share this post


Link to post
Share on other sites
Waaayoff    952
Thanks for your reply [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

1) What does the original heightmap represent? The finest level?

2) I still don't know how to obtain the elevation maps. Maybe you mentioned it and i'm too dumb to follow :|. Let's say i have a 1024x1024 heightmap. If this is the finest level (question 1), how do i obtain the mipmaps that represent the coarser levels?

3) From my understanding, all rings have equal number of vertices, just at different spacing. But the vertex textures holding the height data are of different resolutions, right? What am i missing here?

I'm sorry but i just don't understand the concept itself, even after reading the paper twice. Edited by Waaayoff

Share this post


Link to post
Share on other sites
L. Spiro    25638
[list=1]
[*]Yes.
[*]Treat it as a texture and do basic mipmapping. It is a texture with mipmaps. Nothing more. tex2Dlod() allows you read any of the mipmaps you want.
[*]If you have an image that is 512×512 and you read pixels from [0, 0] to [10. 10], and if you assume each pixel represents 1 meter, then you just read 10 meters by 10 meters in world space. Assume you wanted to do the same thing but with the same image shrunken in half. The image is the same image as before but now it is scaled down to 256×256 (this is a mipmap). That means every pixel in the image is now 2 meters instead of 1. We are still going to read from [0, 0] to [10, 10], but if the vertex locations are still the same then we just packed 20 meters by 20 meters into the same space. This is wrong, and to fix it we have to double the distance between vertices. This is why the rings double in size each time while the source texture halves each time.
[/list]


L. Spiro

Share this post


Link to post
Share on other sites
Waaayoff    952
Thanks!

I re-read the article after your answers and now it all makes sense [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Edit: If anyone's interested, i also found this [url="http://geoinformatics.fsv.cvut.cz/gwiki/Modern_Algorithms_for_Real-Time_Terrain_Visualization_on_Commodity_Hardware#Geometrical_Clipmaps"]article[/url] to be helpful: Edited by Waaayoff

Share this post


Link to post
Share on other sites
Waaayoff    952
Ok i have another question.

To update the clipmap, i need a residual texture containing the heights which i obtain from the original compressed heightmap. Right? So does that mean that i have to update a dozen textures (one for each level) by decompressing the heightmap and its mipmaps, and then send the textures to the gpu to be sampled by the clipmap?

If so, how big should those textures be? Same size as clipmap?

Share this post


Link to post
Share on other sites
L. Spiro    25638
That may be one way to go about it. You may want to test if it is faster to update each level independently or to generate mipmaps after updating only the highest level (I suspect it may be faster to just update everything manually).

They should be the same size as their respective source textures.


L. Spiro

Share this post


Link to post
Share on other sites
Waaayoff    952
About the residuals, what is the point of using a filter to predict the finer levels and then using a residual texture to correct the prediction? Why not just read the true data? You're already sampling a texture, might just as well be the heightmap itself.

Share this post


Link to post
Share on other sites
L. Spiro    25638
They were trying to avoid extra texture reads in vertex shaders which were expensive at the time of that document’s writing (2004). These days that is no longer the case and you may decide to just add more fetches.


L. Spiro Edited by L. Spiro

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