Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Is this possible?

Discussion in 'Shaders' started by Cynikal, Jun 18, 2017.

  1. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    My game is voxel (cubed) base, and I made a building effect:



    In that video, it works for that specific object... But in my more advanced objects, it lags like crazy.

    Yes, I am using individual cubes, then merging them at the end.

    I don't normally ask for help, but is something like this achievable with shaders on a solid mesh?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    Sort of, depends on how you define "solid mesh".

    If the "solid" mesh is still broken up into individual cube meshes within a single mesh asset, you could add some data into an unused UV channel and use a vertex shader to animate the model like you're doing now. I wouldn't use that model once it's been "built", but it should be faster than what you're doing.
     
  3. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    I model using Qubicle (3D block based)... I can export it as a solid mesh solid face), or as the individual cubes. Per the video, it was the individual cubes.

    Now, the model in the video is pretty simple.. Larger cubes (I think about 100 individual cubes).

    Some of my actual models that i'd be applying this effect to, are smaller cube sizes (for more detail), and are about 1500 cubes... and the file size is about 300+mb.

    Ideally, i'd like to know if its possible to make a shader to "fake" the effect shown in the video.

    I don't know much about shaders, so i was curious if you had any recommendations on where to look at as far as to achieve this result.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    The problem is you would need the geometry to do the effect like you have it, or at least the positions of all of the voxels. I actually just worked on an almost identical effect and gave up mainly because of time limitations. However I came up with two ways to do it. One is what I described above, which works with simpler objects like your example as you noted. The more advanced method would be to somehow covert your voxels into a mesh that has one vertex per voxels in the order you want them to spawn, and can otherwise be polygon soup. You wouldn't ever render this mesh directly, but rather use it to spawn particles or use a geometry shader to build the box geometry for.

    Still very expressive. The hack I ended up using was just a cutoff shader with a noise scaled to match the voxels size. I had random box sprites fall from the sky at the same time, but removed them ultimately as it didn't add much to the effect since they didn't actually fall into place accurately.
     
  5. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    I don't know enough about shaders but...

    I notice in your video there are only ever 2 slices of cubes animated.
    You could perhaps combine each new slice as soon as it's all landed.
    So you build up slices, and then combine all the slices at the end.
    Maybe save you from entering batching lag.