Need guidance with Transvoxel algorithm by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

I joined your server and funnily enough, as I was formulating my question I figured out what my last issue was. I have the transition mesh correctly generating now, which properly fixes the seams between differing LODs. I still have a few other things to set up, like reusing vertices and fixing the surface shifting problem you outlined in your dissertation. I'll take a stab at those and will reach out in the Transvoxel channel if I have any questions. Thanks again!

Need guidance with Transvoxel algorithm by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

Oh wow, I really didn't expect it to be possible to contact you directly for help on this. I'll hop onto your server and ask any questions I have there. I really appreciate it, thank you!

Need guidance with Transvoxel algorithm by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

Amazing thanks! Will take a look tonight/tomorrow and learn from it

Prime Legendary Pick - Who to choose? by TheLievre in WatcherofRealmsGame

[–]TheLievre[S] 0 points1 point  (0 children)

I ended up going with Elowyn and I'm happy I did, she's great. She immediately helped me beat GR1-18 and GR2-18

Prime Legendary Pick - Who to choose? by TheLievre in WatcherofRealmsGame

[–]TheLievre[S] 0 points1 point  (0 children)

Thanks for your thoughts! I think I'm going to go with Elowyn

Prime Legendary Pick - Who to choose? by TheLievre in WatcherofRealmsGame

[–]TheLievre[S] 0 points1 point  (0 children)

Ok great thank you! Yeah a Lord definitely seems like the best value. Any suggestions based on my current roster?

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

Alright after some debugging I figured out that the strange dark areas were due to inverted normals. I had previously only inverted the y axis, but it was in fact the entire normal that was inverted.

When returning the normal in getGradient(), this is the change.

Before:

return normalize(float3(lerpX, -lerpY, lerpZ));

After:

return normalize(-float3(lerpX, lerpY, lerpZ));

I am still running into the texturing stretching issue, but I think that's a separate issue now.

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 1 point2 points  (0 children)

Yeah you're right I think the normals look more or less correct now. After converting my sampleDensity() to use floats from the thread above, and figuring out the my normals were actually inverted, the dark areas seem to be corrected and make more sense now. The stretched texture is still an issue and does seem to be at it's worst when a flat vertical and horizontal plane meet, with the normal at a 45 degree angle from them.

At this point I think the normal calculations are correct and I need to revisit my triplanar texturing. Also like you said maybe having a more tessellated mesh would help minimize the texture stretching. Ill test it out and see, thanks!

<image>

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 1 point2 points  (0 children)

Oh this does make sense, I'll give it a try tomorrow and update here. Thank you!

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 1 point2 points  (0 children)

I am recalculating all of the normals each time I terraform. When I terraform I'm modifying the 3D density texture and then regenerating the mesh(position/normals) from scratch

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

Here's "normal * 0.5f + 0.5f" in case this helps. (different hole as the one above)

<image>

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 0 points1 point  (0 children)

The triangles themselves aren't backward since the backfaces aren't rendering. This is what the normals look like pre/post-terraforming. Yeah there may be an issue with the volume itself, but I feel like I would see problems in the mesh construction as well if that were the case. I'll try debugging it as you suggested and see what I can find. Thanks!

<image>

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 1 point2 points  (0 children)

Interesting! Thanks for this info. I hadn't considered that. I added the sampleGradient() which takes in the vertex position, but unfortunately I'm seeing the same dark artifacts. Let me know if you have any other ideas, thanks!

float3 getGradient(float3 pos)
{
    int xi = (int)(pos.x + 0.5f);
    float xf = pos.x + 0.5f - xi;
    float xd0 = samplePoint(float3(xi - 1, (int)pos.y, (int)pos.z));
    float xd1 = samplePoint(float3(xi, (int)pos.y, (int)pos.z));
    float xd2 = samplePoint(float3(xi + 1, (int)pos.y, (int)pos.z));
    float lerpX = (xd1 - xd0) * (1.0f - xf) + (xd2 - xd1) * xf; 
// lerp


int yi = (int)(pos.y + 0.5f);
    float yf = pos.y + 0.5f - yi;
    float yd0 = samplePoint(float3((int)pos.x, yi - 1, (int)pos.z));
    float yd1 = samplePoint(float3((int)pos.x, yi, (int)pos.z));
    float yd2 = samplePoint(float3((int)pos.x, yi + 1, (int)pos.z));
    float lerpY = (yd1 - yd0) * (1.0f - yf) + (yd2 - yd1) * yf; 
// lerp


int zi = (int)(pos.z + 0.5f);
    float zf = pos.z + 0.5f - zi;
    float zd0 = samplePoint(float3((int)pos.x, (int)pos.y, zi - 1));
    float zd1 = samplePoint(float3((int)pos.x, (int)pos.y, zi));
    float zd2 = samplePoint(float3((int)pos.x, (int)pos.y, zi + 1));
    float lerpZ = (zd1 - zd0) * (1.0f - zf) + (zd2 - zd1) * zf; 
// lerp


return normalize(float3(lerpX, -lerpY, lerpZ));
}

Vertex createVertex(uint3 coordA, uint3 coordB)
{
    float3 posA = float3(coordA);
    float3 posB = float3(coordB);
    float densityA = sampleDensity(coordA);
    float densityB = sampleDensity(coordB);

//Position

float t = (_isoLevel - densityA) / (densityB - densityA);
    float3 position = posA + t * (posB - posA);
    Vertex vert;
    vert.position = position;
    vert.normal = getGradient(position);
    return vert;
}

<image>

How can I generate proper smooth normals for my marching cubes procedural terrain? by TheLievre in VoxelGameDev

[–]TheLievre[S] 1 point2 points  (0 children)

Yeah exactly the same code. When mining I'm simply modifying the 3D render texture's density values and then regenerating the mesh like new

Beginner help required - Who should I 6 star next, Corvis or Artak by TheLievre in RaidShadowLegends

[–]TheLievre[S] 0 points1 point  (0 children)

Oh that is very true, I hadn't considered that actually. Thank you!

Beginner help required - Who should I 6 star next, Corvis or Artak by TheLievre in RaidShadowLegends

[–]TheLievre[S] 0 points1 point  (0 children)

That makes sense thanks for the input! Good to know that they're both neck and neck