uneatenbreakfast
uneatenbreakfast

Reputation: 615

Showing a model with vertex painted colours in unity

I'm trying to get a model imported into unity from blender showing the vertex colours. I have a shader(shows vertex colours) which I've applied to the model but still just plain white. I know the shader works because I managed to get it working on another blender model, however I just don't know what the settings were used in the blender file.

Here's how I'm currently doing it: I create a model in MagicaVoxel and is coloured. I then exported it as a .obj file. I then import this into blender. If I switch into "texture" mode, I can see all the vertex colours on the model. I save this blender file as just "xxx.blend".

Then in Unity, I drag the .blend file over, and it imports the model. I apply a material and the vertex paint shader to the model on the stage.

Model should start showing the vertex paint colours, but it does not. Just remains white.

Does anyone have any ideas?

Cheers

Upvotes: 3

Views: 8957

Answers (2)

Andrea Leganza
Andrea Leganza

Reputation: 477

For other users searching a way of using vertex colors in Blender and importing into Unity WITHOUT ANY BAKING:

  1. select a face (or vertex or all the faces) on edit mode
  2. switch to vertex paint mode (ctrl+tab)
  3. Click on the white square icon next to "Vertex paint" dropdown menu on top left of the window ("PaintMak")
  4. ctrl + K to color all its vertices, or simply select a color with the picker available in multiple locations and paint vertices ( top of the windows, using N-> active tool, selecting and on right properties area "screwdriver and English key" icon = Active tool and workspace settings). IMPORTANT: you have to paint on the vertices, painting on the face won't work.
  5. Object material needs its "Base Color" input to be the output of the Vertex color node, so create this connection into the Shader Editor.
  6. Save the blender file into Unity project folder or export into FBX
  7. To display in object/edit mode colors switch view port shading to vertex (see screenshot)
  8. On Unity create a material with a custom Shader graph with pins the output of the "Vertex color" node to the "Base color" main node.

Note: when using vertex colors Blender creates a "Col" data field into the "Object data properties" (teen triangle icon).

Blender setup Display vertex color on Object/Edit mode Unity setup

Upvotes: 0

uneatenbreakfast
uneatenbreakfast

Reputation: 615

I managed to find a way to get vertex colours showing in Unity.

I needed to bake the texture into the vertex colours, to do this, with the object selected in blender, check the "vertex color paint" box under materials. (Shadeless can be checked if you don't want any shadows on the final bake)

Then switch into "vertex paint" mode (from object mode) and then in the properties under bake, check "bake to vertex colour", bake mode is "textures", then click bake.

Import blend file into Unity and apply vertex shader to see.

Upvotes: 2

Related Questions