Jump to content
  • Advertisement
Sign in to follow this  
paic

Geometry clipmap and texturing

This topic is 4862 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, The current state : For the moment, I have a geometry clipmap terrain without compression / decompression. I run a 1024x1024 grid with it. For the texturing part, I use brute force : I have a 2048² blending color, a 2048² color texture, a 1024² normal map, and a 512² detail texture. In the shader, the texturing looks like :
float4 blend  = tex2D(g_BlendingTextureSampler, iTexCoord0);
float4 color  = tex2D(g_ColorMapTextureSampler, iTexCoord0);
float4 detail = tex2D(g_DetailTextureSampler, iTexCoord1);
float3 normal = tex2D(g_NormalMapTextureSampler, iTexCoord0).xyz - 0.5f;
	
normal = normalize(normal);
float4 diffuse = get_diffuse_lighting(normal);

detail = detail * blend;
float overlay = detail.r + detail.g + detail.b + detail.a;
overlay = overlay * 2.0f;

oColor  = overlay * color * diffuse;

This way, I have my terrain running quite fast, with 4 different detail textures. The problem : The problem is that with this method, blending and coloring is not really precise. For example, with a grid of 2m resolution, 1 pixel == 1 meter. So, for example, I can't draw a road with this, because the border will be blended over a 1 meter area. And for a road, we would like to have quite sharp transition on the borders. A soution ? I was thinking of having bigger texture resolutions. In each clipmap, I would have fixed size textures, which I would update toroïdally at each frame. This way, I can have a precise blending / coloring over the terrain : for a clipmap of 125² vertices and a grid resolution of 2m, a texture of 512² would give a precision of 25cm. This allow sharper transition, and more precise blending / coloring. But I don't know if it's possible. - The toroïdal update of the texture will completely screw the texture, and I'm not sure I can address it correctly in the pixel shader (well, I think it's possible, but not 100% sure) - The texture sampling will also probably be a problem since there are discontinuities in the texture. - The transition between clipmaps. Even if the 2 previous points are solved, how do I address smooth transition regions between clipmaps. For vertices' height, it's not difficult : store the coarser height in w. For textures, I don't have the place to store the coarser values. So I probably will end up setting the 4 textures of the current clipmap and the 4 of the coarser one, and interpolate between the 2. Don't know the impact on the performances :/ One other solution which Lutz sent to me some times ago is to compute the final texture on the CPU during update and for each clipmap. This way, you can do the transition with 2 textures. The shader becomes a lot more simple. But (I hate those "but" T_T) Do I have to recalc the whole texture, or can I toroïdally update it ? Because rebuilding many 512² textures each frame doesn't seem to be really CPU friendly :/ Conclusion So, I would like to have a more precise texturing, but I'm lost with a lot of questions. For the moment, I can keep my terrain as is, but if any of you has a good / precise texturing system implemented for geometry clipmap, I would really appreciate a little help ^^ Few, sorry for the long post, and thx in advance for any pointer / idea / answer ^^

Share this post


Link to post
Share on other sites
Advertisement
I am using vert colors with a global texture and detail textures at the moment so I can't speak from experience, but...(!)
Quote:

But I don't know if it's possible.
- The toroïdal update of the texture will completely screw the texture, and I'm not sure I can address it correctly in the pixel shader (well, I think it's possible, but not 100% sure)

The UVs for accessing the textures would remain the same regardless of the resolution, always 0.0 is left and 1.0 is right. You just have to add a fixed offset, and use the wrapping.
Quote:

One other solution which Lutz sent to me some times ago is to compute the final texture on the CPU during update and for each clipmap. This way, you can do the transition with 2 textures. The shader becomes a lot more simple.
But (I hate those "but" T_T) Do I have to recalc the whole texture, or can I toroïdally update it ? Because rebuilding many 512² textures each frame doesn't seem to be really CPU friendly :/

How does this work? Does it calculate lighting on the texture aswell? Surely detail textures still need to be blended in the fragment shader.

Share this post


Link to post
Share on other sites
Hi, and thx for the reply.

First : I know I can get the UV by using the same rule as the one I use to build my index buffer. But what I fear most is the texture filtering : as toroidally updating the texture will create discontinuities in the texture, the filtering at those discontinuities will gives ... strange result. If it's not really visible, that's fine. That's why I wanted to know.

Second : I'm not 100% sure how Lutz does that, but my guess is that he does the texture splatting on the CPU. Lighting is done via a lightmap. I wasn't clear : for each clipmap, with this method, you have 1 lightmap and 1 final texture. But I don't know if toroidal update is possible for the previous reasons.

Share this post


Link to post
Share on other sites
Quote:

First : I know I can get the UV by using the same rule as the one I use to build my index buffer. But what I fear most is the texture filtering : as toroidally updating the texture will create discontinuities in the texture, the filtering at those discontinuities will gives ... strange result. If it's not really visible, that's fine. That's why I wanted to know.

Thats a good point, and something I hadn't considered. I am implementing textures and normal maps over the weekend to replace my vertex colors and normals, so hopefully I will be able to work that one out.
Do you have a site with screenies etc?

Share this post


Link to post
Share on other sites
The discontinuity is not a problem even with filtering. You just have to shift texture coords by half pixel.

I am doing this for my normalmap and alpha maps - both computed similar way as the elevation (but with diffrent packing into texture).


ghostace

Share this post


Link to post
Share on other sites
GhostAce : That's what I wanted to hear ^^
So, updating the texture toroidally is fine ? That's a good news ! As soon as I have time I'll try to implement that. Thx again !

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!