Author Topic: Using a different shader/material for each voxel face  (Read 56 times)

RunningPixel

  • Newbie
  • *
  • Posts: 15
    • View Profile
Using a different shader/material for each voxel face
« on: November 18, 2021, 12:46:42 PM »
Hi guys, I would need to setup a voxel having different materials/shaders for each (or at least one) cube face. Is it possible without having to use a prefab?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7565
    • View Profile
Re: Using a different shader/material for each voxel face
« Reply #1 on: November 18, 2021, 07:52:47 PM »
Using a prefab is quite easy.

You could also use the "Opaque 6 textures" render type and use the Material Override option to supply your own material. In this new material/shader, you could use the normal to determine which face is being rendered and execute one code or another in the fragment shader. This would be necessary since the cube faces are a single mesh in VP by default. If you want a different material per face, you would need multiple meshes or repeat the material 6 times which can't be done unless you use a Custom Voxel with a prefab.

RunningPixel

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Using a different shader/material for each voxel face
« Reply #2 on: November 19, 2021, 10:06:38 AM »
Using a prefab is quite easy.

You could also use the "Opaque 6 textures" render type and use the Material Override option to supply your own material. In this new material/shader, you could use the normal to determine which face is being rendered and execute one code or another in the fragment shader.

The tricky part is that I need to change the queue for that particular face.
e.g. a face renders the AR background and all the others render the standard voxel texture.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7565
    • View Profile
Re: Using a different shader/material for each voxel face
« Reply #3 on: November 19, 2021, 10:17:45 AM »
In that case you need different materials per each face. The only option possible in VP is by using a prefab which has 6 faces and each one has a material. Or build a mesh with 6 submeshes and attach 6 materials (more complex).