Git Product home page Git Product logo

Comments (8)

mkrebser avatar mkrebser commented on July 18, 2024

If each voxel you have is a a single cuboid then you would need to write a fragment shader to make special textures. Voxel games like minecraft solve this problem by using texture atlas and having 2 triangles per square- which allows texture atlasing over a mesh.

This library maintains a hierarchy tree depth for every instance in the object hierarchy. When you take an object with 1000 children and delete its parent- the depth of every child changes. The depth has to be recalculated for every child recursively. This is required so the compute shaders will perform world2Object, object2World calculations in the correct order. Ie, it batch calculates relative positions using the depth ordering. Depth 0, 1, 2, etc...

In the parenting function, it should not recalculate the depth if it does not change. Ie, you reparent your root object to be at the same hierarchy depth- it does not do a recursive depth adjustment. I would recommend that you do not change the hierarchy depth of your root objects or other objects with many children.

See

I don't know enough about your use case to provide more than this. I would also suggest using the unity profiler and add samples to relevant locations in the code to track down which functions are causing performance issues.

from gpuinstance.

projectBreakableAccAPI avatar projectBreakableAccAPI commented on July 18, 2024

Okay, well I'm not changing the hierarchy depth, it's always one parent deep, so I don't think that's the problem. My question is mainly, if I give every instance its own texture, and change it as I go, will that interrupt the instancing and defeat the purpose of the whole library, or will it behave the same way it would without any textures?

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

As long as you are reusing materials you have previously created, you will see a benefit from instancing.

There is a guaranteed draw call for every unique (mesh, material).

Assuming you are just using the same cuboid for every voxel, this means you would get a minimum number of 1 draw call per unique material.

If every voxel has a unique material you will see no benefit from instancing

from gpuinstance.

projectBreakableAccAPI avatar projectBreakableAccAPI commented on July 18, 2024

Ok thanks for clearing that up! My next question would then be, would a unique uv map per voxel cause an additional drawcall as well? I assume it counts as a different mesh and therefore yes, but I just want to make sure.

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

If you are using a single texture atlas for all voxels and packing the uv coordinates into the vertex data then no, it would just be one draw call since the only thing changing is the offset/scaling on the shared texture.

from gpuinstance.

projectBreakableAccAPI avatar projectBreakableAccAPI commented on July 18, 2024

Oh ok then, well I guess I'll give that a shot, thanks!

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

Sorry misunderstood the question, yeah if you have a mesh which has different vertex data then it is guaranteed to be a unique mesh and cause a new draw call.

from gpuinstance.

projectBreakableAccAPI avatar projectBreakableAccAPI commented on July 18, 2024

Oh ok, nevermind then. It doesn't really matter regardless, as I realized that the texture would have exceeded the maximum size in unity, and been absurdly inefficient. I think I'm going to focus on optimizations other places, and then worst case scenario, write my grouped meshes to the render buffer without instancing. Thank you for being so helpful as always, and I'll be sure to let you know if I have any other problems :)

from gpuinstance.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.