@zzuegg said:
Hello, i am stuck again with a kind of big problem. I know this is not quite a JME task since Tessellation is not yet officially supported. But i hope that someone is here who has a bit experience with is.
The idea was to create a terrain system which allows easy editing, high details, LOD as well as any form (caves ... ).
So after thinking during work about this i ended with the idea that using a Bloxel enging would solve the easy-editing and any form task. On modern hardware tessellating these object with a Catmull clark tessellation shader should eliminate the Block-look and solve the LOD task.. (The form of the terrain can be adjusted by adjusting the Normals)
Bloxel + Tessellation = Roxel (Roundes Voxels, and the name sounds cool ;) )
Now i have search for two day's for implementations of a Catmull clark algorithm. And beside Math-Papers showing nice results without any code :( (Which are unfortunately over my head (I am quite not a math guy) i found two different methods.
-Adaptive PN
-Phong Tessellation
However, both of them are not similar to Catmull clark's result. They are both extruding the tessellated part, while the original vertices stay at the same position.
Here is a picture: With 'debug show normals' texturing. In this picture i have used a Tessellation level of 6 for the whole mesh.
http://i.imgur.com/0i99z.jpg
Anyone has a link to a working Catmull shader, or knows a relativly easy to follow paper?
Per GPUGems2:
Example 7-1. Subdiv.cg—Subdividing a Regular Mesh Using Catmull-Clark Rules
[java]
float4 main(float4 srcCoord,
uniform samplerRECT srcTexMap : TEXUNIT0) : COLOR
{
float3 wh, wv; // weight values
float3 s1, s2, s3;
float2 f;
// calculate weights based on fractional part of
// source texture coordinate
//
// x == 0.0, y == 0.0 use face weights (1/4, 1/4, 0)
// (1/4, 1.4, 0)
// ( 0, 0, 0)
// x == 0.5, y == 0.0 use edge weights (horizontal)
// (1/16, 6/16, 1/16)
// (1/16, 6/16, 1/16)
// ( 0, 0, 0)
// x == 0.0, y == 0.5 use edge weights (vertical)
// (1/16, 1/16, 0)
// (6/16, 6/16, 0)
// (1/16, 1/16, 0)
// x == 0.5, y == 0.5 use valence 4 vertex weights
// (1/64, 6/64, 1/64)
// (6/64, 36/64, 6/64)
// (1/64, 6/64, 1/64)
wh = float3 (1.0/8.0, 6.0/8.0, 1.0/8.0);
f = frac (srcCoord.xy + 0.001) < 0.25; // account for finite precision
if (f.x != 0.0) {
wh = float3(0.5, 0.5, 0.0);
srcCoord.x += 0.5; // fraction was zero -- move to texel center
}
wv = float3 (1.0/8.0, 6.0/8.0, 1.0/8.0);
if (f.y != 0) {
wv = float3 (0.5, 0.5, 0.0);
srcCoord.y += 0.5; // fraction was zero -- need to move to texel center
}
// calculate the destination vertex position by using the weighted
// sum of the 9 vertex positions centered at srcCoord
s1 = texRECT (srcTexMap, srcCoord.xy + float2 (-1, -1)).xyz * wh.x +
texRECT (srcTexMap, srcCoord.xy + float2 (0, -1)).xyz * wh.y +
texRECT (srcTexMap, srcCoord.xy + float2 (1, -1)).xyz * wh.z;
s2 = texRECT (srcTexMap, srcCoord.xy + float2 (-1, 0)).xyz * wh.x +
texRECT (srcTexMap, srcCoord.xy + float2 (0, 0)).xyz * wh.y +
texRECT (srcTexMap, srcCoord.xy + float2 (1, 0)).xyz * wh.z;
s3 = texRECT (srcTexMap, srcCoord.xy + float2 (-1, 1)).xyz * wh.x +
texRECT (srcTexMap, srcCoord.xy + float2 (0, 1)).xyz * wh.y +
texRECT (srcTexMap, srcCoord.xy + float2 (1, 1)).xyz * wh.z;
return float4 (s1 * wv.x + s2 * wv.y + s3 * wv.z, 0);
}[/java]