Texture blending Shader using Vertex Coloring with Blender Model

Hi there, I’m trying to set up Texture blending using Vertex coloring with a Blender model ( to blend different texture edges ).

I have done some research on this and come across a few posts describing some of the solutions and some of the problems.

One of the problems seems to be Blender only exporting Vertex Colors using RGB, not RGBA ( if I have understood correctly ) - as mentioned by Jessy in this Post:

http://forum.unity3d.com/threads/15444-fbx-import-messes-up-vertex-colors?p=229027&viewfull=1#post229027

I've tried running that Python script without success, it's from 2009 though so...

I’ve also come across some shaders posted by Jessy here for blending Texture using Vertex colors :

http://forum.unity3d.com/threads/44749-Vertex-Paint

I’ve tried both RGB & RGBA versions - the RGB version seems to almost work, but not quite :

It seems to only get a part of the texture color, not the entire texture.

Jessy seems to be the expert on this, so maybe he’s around? - if not maybe someone else has encountered this and worked it out.

It seems that the best approach is to convert Blender’s exported RGB over to RGBA somehow, and use the better RGBA shader… but I’m no expert.

Also, while we’re here, I have a few additional questions about this approach :

  • Are there any lighting or other graphical issues?
  • Is the performance comparable with just using - say a diffuse shader with 2 materials?
  • any other drawbacks / complications?

Thanks for any help.

So, with further research, I’ve manage to solve the first issue - which is how to get Blender to export a customizable Alpha value for the vertex colors.

This involves modifying the ‘export_fbx.py’ ( C:\Program Files (x86)\Blender\2.58\scripts\addons\io_scene_fbx\ ):

Replace the existing code block ( search on the first line ), with the one below ( please note - back up the ‘export_fbx.py’ file beforehand ):

            for col in colors:
                fakeAlpha = (col[0]+col[1]+col[2]) / 3
                if i == -1:
                    file.write('%.4f,%.4f,%.4f,%.4f' % (col[0],col[1],col[2],fakeAlpha))
                    i = 0
                else:
                    if i == 7:
                        file.write('
			')
                        i = 0
                    file.write(',%.4f,%.4f,%.4f,%.4f' % (col[0],col[1],col[2],fakeAlpha))
                i += 1
                ii += 1  # One more Color

This just sets the Alpha value to an average of the RGB color intensities, so you can just use grayscale painting really.

( Nb: Blender invokes this export script, so it will work just by re-saving the .blend file )

BUT - now I’m back to same issue as I had with the RGB shader, in the using the RGBA shader, comes up with the same lack of texture - it only seems to use the FIRST color of each of the two textures to colorize the entire object.

I’m thinking maybe there is a texture import setting I don’t know about…

For anyone else interested in this :

Vertex Alpha for Texture Blending