How exactly do I do this in unity...

Discussion in 'Other Discussion' started by Innocuous, Feb 11, 2018.

  1. Innocuous

    Innocuous Lieutenant

    Joined:
    Jan 16, 2018
    Messages:
    23
    Likes Received:
    9
    The following is a complex graphics issue in unity. I thought that since Empyrion has similar systems to what I am trying to achieve, people in this community might know the answers to my questions.

    Alright I have an issue with materials. I have a pretty nice setup for a voxel game, can create any shape and it occludes the inward facing faces. The problem arises when I try to apply materials to each face of the voxel shape. I was doing this by making an array of materials, and adding a single material for every face. The problem with this is that it lags . To test this, I generated a cube of 32x32x32 cubes.


    without materials:
    [​IMG]
    With materials:
    [​IMG]



    I want to be able to have different materials for each face, so I can colorize and texture them differently. This is basically just like Empyrion's ship building...

    I'm a bit confused about what approach I should strike this problem with. These are some ideas I have:

    1. Some sort of splat-map shader, which I have little experience with.
    2. Make a massive texture by sending an array of floats to the GPU, then change the UVs of the different faces of the mesh to match it. Sounds a bit silly and might be a waste of time.
    3. Somehow use shared materials or instanced materials in a way I don't understand yet.
    This is just for fun, and so I can teach myself skills that I will hopefully use in the future for a job.
     
    #1
  2. Innocuous

    Innocuous Lieutenant

    Joined:
    Jan 16, 2018
    Messages:
    23
    Likes Received:
    9
    Well, I figured it out. I'm doing it Minecraft style, so I'm grabbing the textures from the same sheet.

    Behold, my algorithm with a metal panel texture spammed across a lattice of cubes.

    [​IMG]
     
    #2
    monktk likes this.
  3. Innocuous

    Innocuous Lieutenant

    Joined:
    Jan 16, 2018
    Messages:
    23
    Likes Received:
    9
    I added a second vertex color so I can colorize the textures with two textures at once for different parts. Also improved the shader so its really nice looking.

    [​IMG]

    I did this in a hacky way. In order to make new vertex colors, I used the secondary uv map and pluged it in as a color in the shader.
     
    #3
    Last edited: Feb 16, 2018

Share This Page