Jump to content

SpiderPig

Developers
  • Posts

    2,279
  • Joined

  • Last visited

Blog Comments posted by SpiderPig

  1. Fixed a few issues.  I was only allocating enough voxel memory pages for the final level of subdivision that represented the surface.  I didn't take into account the fact that I needed space for the all their parent nodes too.

    Also have finally removed double vertices with the TransVoxel method.  In one scene there was 108k vertices, after the fix it went down to 30k.  About a 72% decrease! :D

    • Like 1
  2. This is a 2k Voxel Terrain with tri-planer texturing.  It's just diffuse right now, and the red is an area that will be textured differently. ;)  It's coming along nicely.  I think I'll work on normal maps and smooth shading.

    TheSeventhWorldTexturing_1.thumb.png.d0475c9404c54a33971bc08c2f214ea3.png

    The LOD algorithm needs work, the detail in the terrain falls off too sharply I feel.

  3. Thinking about it, 14GB seemed way to high and I was right - the problem was I was setting up a components node pool like this;

    voxel_pages = make_shared<VoxelPages>(node->bounds.size);

    Using the bounds size when they were only small (16m to 32m) were fine but when I made components as big as the terrain itself (4096m) it wasn't a good idea.  Some components were allocating 2048*2048 page size, so about 4 million nodes at one (1.6GB) and it only used a dozen of them from the pool.

    Making each page the size of the component fixed it right up. :D

    voxel_pages = make_shared<VoxelPages>(component_size);

    The 4K terrain now only uses 800MB.  ^_^

    • Like 2
  4. Have it working in real-time now.  The small white sphere is the viewer.  It still needs refining, instead of deleting components and then creating a new one I'll probably add the components to a "re-purpose" list.  It will save a bit of time, mainly in the creating of a new model and voxel node memory pools.  Other than that there are a few minor memory leaks.

    This is all in debug mode too.

    DynamicComponents.gif.9dfb73390f19ab99aa71a1bed3eef4b1.gif

    • Like 1
  5. Got it pretty much looking the way I wanted.

    ModifiedCube.png.03ae52d20cd4abfe03caaa03e65e3126.png

    ModifiedSDFCube.png.6060cab3466a814d20c4bac5356e9eb3.png

    float CalculateTerrainSurface(shared_ptr<VoxelObject> voxel_object, shared_ptr<VoxelBrush> brush, VoxelNode* node, Decimal3& position) {
        float radius = 32.0f;
        float size = voxel_object->GetSize();
        auto centre = voxel_object->GetPosition();
    
        auto ratio = 1.0f;
        auto local_y = position.y - centre.y + radius;
        if (local_y < radius * 2.0f) {
            ratio = 0.75f + (local_y / (radius * 2.0f)) / 3.0f;
        }
    
        auto dist = sdfBox(Vec3(centre.x, centre.y, centre.z), Vec3(radius * ratio, radius, radius * ratio), Vec3(position.x, position.y, position.z), 16.0f * ratio);
        return dist + (noise->GetFractal(8, position.x / size, position.y / size, position.z / size) + 1.0f) / 2.0f * 16.0f;
    }

     

  6. I didn't realise I could use 3D noise to create a heightmap without creating caves. :blink:

    This is using a sphere as the base and then sampling 3D simplex noise to create the terrain on that sphere.  What I did in Leadwerks was project a heightmap onto the face of a cube to render the terrain and I was going to do the same thing in Ultra too but the whole process of blending all the maps together is very convoluted.  This is actually very simple.

    3DSimpleNoise.png.dcddcbd2049fd605c92ba3576969b580.png

    float CalculateTerrainSurface(shared_ptr<VoxelObject> voxel_object, shared_ptr<VoxelBrush> brush, VoxelNode* node, Decimal3& position) {
        float radius = 32.0f;
        float size = voxel_object->GetSize();
        auto centre = voxel_object->GetPosition();
        Decimal3 local_pos = {position.x - centre.x, position.y - centre.y, position.z - centre.z};
    
        auto dist = sqrt((local_pos.x * local_pos.x) + (local_pos.y * local_pos.y) + (local_pos.z * local_pos.z)) - radius;
        return dist + noise->GetFractal(4, position.x / size, position.y / size, position.z / size) * 16.0f;
    }

    I think I can apply this to the cuboid shape I made above and then further manipulate how the terrain is made before eroding it.  I'm not sure yet, but I think I'll have to project the height values onto some 2D planes so I can perform erosion on them and then map them back.  Otherwise I'll have to erode either a cube map of points or the voxel octree itself.  The former will take a lot of memory for large terrains and the latter will probably far too slow.

    Food for thought!

  7. Not really... because each node has a set amount of vertices and triangles, if you want to have a smooth shape you have to interpolate the vertices down or up the nodes edge toward the surface.  There's no visual stepping or anything, it just creates a lot of small triangles where the vertices have been moved really close to a nodes corner.  Mostly it is just wasted geometry because they are so small but I've found it does give a more non-uniform look in the geometry compared to the 2D terrain rendering method with set patch sizes.

    In some cases the vertices could all be on top of one another and therefore the triangle is not visible at all, but it is still there.

    This is marching cubes without interpolation.

    MarchingCubesWithOutInterpolation.thumb.png.897dffdfbe6bb80619dc4c4d286cea47.png

    • Like 1
  8. Marching cubes are not the best for displaying geometry.  It's fine if you want a blocky look (let the vertex be created at the centre of every node edge) but if you interpolate to better match the object you want to represent, you end up with lots of different sized triangles.  Below is flat shading so it's more obvious, but you can see in wireframe the steps where triangles are squashed as it goes up to the next highest node.  SurfaceNets and DualContouring should be much better (and faster to generate) but there are aspects about both I don't really like.

    SurfaceNets, once the vertices are created, needs to be looped over a few times to slowly morph the vertices toward one another to create a smooth shape.  This means the object will shrink a little at the edges.

    DualContouring seems much better but does use some fancy math I can't wrap my head around (yet) to better represent sharp edges.  I think I am going to try and make something that is a combination of the two.

    MarchingCubes:

    MarchingCubesAstheticsSolid.thumb.png.0ed8e7adf4f37f56200ea714f8756903.png

    WireFrame:

    MarchingCubesAstheticsWireframe.thumb.png.008447220ac849e16f1b2d3d66b28260.png

  9. I've include Utilities.h in my project but am getting errors on these lines because the files do not exist in those folders?

    #include "../external/submodules/scintilla/include/ScintillaTypes.h"
    #include "../external/submodules/scintilla/include/ScintillaMessages.h"
    #include "../external/submodules/scintilla/include/ScintillaStructures.h"
    #include "../external/submodules/scintilla/include/ScintillaCall.h"
    #include "../external/submodules/scintilla/include/Scintilla.h"
    
    #include "../external/submodules/scintilla/include/ILexer.h"
    #include "../external/submodules/lexilla/include/Lexilla.h"
    #include "../external/submodules/lexilla/include/SciLexer.h"

     

×
×
  • Create New...