www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 there is Crack between zone and zone. « View previous topic :: View next topic » 
Author Message
inucasoftware
PostPosted: Thu Apr 19, 2012 2:58 am    Post subject: there is Crack between zone and zone. Reply with quote



Joined: 08 Jun 2011
Posts: 18

there is Crack between zone and zone.

mask texture is not seam.

i think that solve.

it is get one pixel on neighbor mask, when zone mask take.

how to solve?

Back to top
View user's profile Send private message
ALicu
PostPosted: Thu Apr 19, 2012 12:18 pm    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hello,

How big is your mask (what resolutions do they have)?

Sometimes the seams are caused by the filtering even though the masks appear continuous. That is why for example Graphite (our engine we are also licensing) is duplicating the masks pixels at the border of the zones so the filtering will not produce any seams.

Kind Regards,
Adrian L.
Back to top
View user's profile Send private message
inucasoftware
PostPosted: Fri Apr 20, 2012 12:59 am    Post subject: Reply with quote



Joined: 08 Jun 2011
Posts: 18

mask size is 1024 * 1024

how to get use on example Graphite?

please Explain splatting on Graphite.
Back to top
View user's profile Send private message
ALicu
PostPosted: Fri Apr 20, 2012 7:22 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi,

The mask size is ok. The seams should not appear (they may appear only when you go very close to the ground).

Seams appear due to linear filtering. So at the border of the zone, you sample from the border pixel and clamp there (because you cannot sample from the neighboring zone mask). So seams appear. In order to avoid this you just take the pixels from the neighboring zones and add them as borders to your mask.

Graphite takes each mask for a layer, duplicates a row and column of pixels for each edge by taking pixels from neighboring zones masks and then scale the mask back to the power of two. So in your case, for example, take the 1024x1024 mask, duplicate the pixels from the margin so now you have a mask of 1026x1026 and then just scale back to 1024. Or better, you can scale the content to 1022x1022 and then duplicate the pixels so the final size is 1024x1024 again.

Then, in real-time, inside your engine, when you are doing the splatting, there is no need to have the terrain UV for the mask saved in the file per vertex. You can just use a vertex shader code to generate uv between 0 and 1 for each terrain zone (0,0 is the left corner, 1,1 is the top-right corner). Something like this:

Code:

// Create the unitary texture mapping based on the zone geometry.
float2 UnitTexMap;
UnitTexMap.x = v.Pos.x / ZoneSize + 0.5f;
UnitTexMap.y = v.Pos.z / ZoneSize + 0.5f;


The above code just divide the vertex position with the zone size and then add 0.5 as the zone geometry is centered in 0,0.

Then, because you've added a pixel at the border, you need to bias the uv as follows:

Code:

Out.TextureUV0.x = (UnitTexMap.x * TextureMapMul + TextureMapAdd);
// Inverse Y as DirectX is UV top-down.
Out.TextureUV0.y = 1.0f - (UnitTexMap.y * TextureMapMul + TextureMapAdd);


Where TextureMapAdd is 1.f / mask_image_size and TextureMapMul is (mask_image_size-2.f) / mask_image_size. Basically the UV is biased to start from second pixel and go to the penultimate pixel. In this way we don't sample directly from the duplicated pixels at the border. But because we are doing linear filtering, these pixels are used to average with the pixels next to them. In this way the filtering appears continuous and there are no seams. It is like sampling from the neighboring zones directly.

The above code needs to be added in the vertex shader. The above is in DirectX HLSL but you can also use Cg, GLSL etc.

Graphite is licensed with full source code for interested clients. It is an optimized rendering solution that is 100% integrated with Grome. Not only it does the above trick but it also applies special shader lod for terrain, vertical mapping, virtual texturing and has many more features. Please send an email to contact@quadsoftware.com if you are interested in licensing it.

Kind Regards,
Adrian L.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group