Skip to content
Snippets Groups Projects

Add full 3D MLS and carving

Merged Nicolas Pope requested to merge exp/rendcheck into master
3 files
+ 59
32
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -47,7 +47,7 @@ using ftl::cuda::TextureObject;
const float3 Ni = make_float3(normals_in.tex2D((int)(x)+u, (int)(y)+v));
// Gauss approx weighting function using point distance
const float w = ftl::cuda::spatialWeighting(X,Xi,smoothing);
const float w = (Ni.x+Ni.y+Ni.z == 0.0f) ? 0.0f : ftl::cuda::spatialWeighting(X,Xi,smoothing);
aX += Xi*w;
nX += Ni*w;
@@ -55,22 +55,24 @@ using ftl::cuda::TextureObject;
}
}
nX /= contrib; // Weighted average normal
aX /= contrib; // Weighted average point (centroid)
if (contrib > 0.0f) {
nX /= contrib; // Weighted average normal
aX /= contrib; // Weighted average point (centroid)
// Signed-Distance Field function
float fX = nX.x * (X.x - aX.x) + nX.y * (X.y - aX.y) + nX.z * (X.z - aX.z);
// Signed-Distance Field function
float fX = nX.x * (X.x - aX.x) + nX.y * (X.y - aX.y) + nX.z * (X.z - aX.z);
// Calculate new point using SDF function to adjust depth (and position)
X = X - nX * fX;
//uint2 screen = camera.camToScreen<uint2>(X);
// Calculate new point using SDF function to adjust depth (and position)
X = X - nX * fX;
//uint2 screen = camera.camToScreen<uint2>(X);
//if (screen.x < depth_out.width() && screen.y < depth_out.height()) {
// depth_out(screen.x,screen.y) = X.z;
//}
depth_out(x,y) = X.z;
normals_out(x,y) = make_half4(nX / length(nX), 0.0f);
//if (screen.x < depth_out.width() && screen.y < depth_out.height()) {
// depth_out(screen.x,screen.y) = X.z;
//}
depth_out(x,y) = X.z;
normals_out(x,y) = make_half4(nX / length(nX), 0.0f);
}
}
void ftl::cuda::mls_smooth(
@@ -137,7 +139,7 @@ void ftl::cuda::mls_smooth(
const float3 Ni = make_float3(normals_in.tex2D((int)(x)+u, (int)(y)+v));
// Gauss approx weighting function using point distance
const float w = ftl::cuda::spatialWeighting(X,Xi,smoothing);
const float w = (Ni.x+Ni.y+Ni.z == 0.0f) ? 0.0f : ftl::cuda::spatialWeighting(X,Xi,smoothing);
aX += Xi*w;
nX += Ni*w;
@@ -145,22 +147,24 @@ void ftl::cuda::mls_smooth(
}
}
nX /= contrib; // Weighted average normal
aX /= contrib; // Weighted average point (centroid)
if (contrib > 0.0f) {
nX /= contrib; // Weighted average normal
aX /= contrib; // Weighted average point (centroid)
// Signed-Distance Field function
float fX = nX.x * (X.x - aX.x) + nX.y * (X.y - aX.y) + nX.z * (X.z - aX.z);
// Signed-Distance Field function
float fX = nX.x * (X.x - aX.x) + nX.y * (X.y - aX.y) + nX.z * (X.z - aX.z);
// Calculate new point using SDF function to adjust depth (and position)
X = X - nX * fX;
//uint2 screen = camera.camToScreen<uint2>(X);
// Calculate new point using SDF function to adjust depth (and position)
X = X - nX * fX;
//uint2 screen = camera.camToScreen<uint2>(X);
//if (screen.x < depth_out.width() && screen.y < depth_out.height()) {
// depth_out(screen.x,screen.y) = X.z;
//}
//depth_out(x,y) = X.z;
normals_out(x,y) = make_half4(nX / length(nX), 0.0f);
//if (screen.x < depth_out.width() && screen.y < depth_out.height()) {
// depth_out(screen.x,screen.y) = X.z;
//}
//depth_out(x,y) = X.z;
normals_out(x,y) = make_half4(nX / length(nX), 0.0f);
}
}
void ftl::cuda::mls_smooth(
Loading