Is it possible to access multiple layers/sets of vertex colors?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gubbles

In Blender (2.79), I can assign multiple sets of vertex colors to a single mesh. My current workflow is exporting as Collada (.dae) to import into Godot. From cracking open the .dae file in a text editor at least, I can see it correctly stores however many sets of vertex color data I’ve applied, complete with the proper names that I’ve set in Blender. But in Godot’s shader language however, it doesn’t look like there’s a way to specify these separate sets?

void fragment() {
	// Assign vertex color to albedo color

In my experiments, the COLOR keyword only ever draws from the last set of vertex colors that were added in Blender. And unlike how we’re given both UV and UV2 to differentiate multiple UV layers/unwraps, it seems there’s no way to specify which of multiple sets of vertex colors that Godot draws from. This means that any other set other than the very last is inaccessible. Is there a way to access them that I’m missing here?

:bust_in_silhouette: Reply From: klaas

no, you cant. Godot only allows 1 set of vertex colors.

This is of what a Godot mesh is made of:

ARRAY_VERTEX = 0 — Array of vertices.
ARRAY_NORMAL = 1 — Array of normals.
ARRAY_TANGENT = 2 — Array of tangents as an array of floats, 4 floats per tangent.
ARRAY_COLOR = 3 — Array of colors.
ARRAY_TEX_UV = 4 — Array of UV coordinates.
ARRAY_TEX_UV2 = 5 — Array of second set of UV coordinates.
ARRAY_BONES = 6 — Array of bone data.
ARRAY_WEIGHTS = 7 — Array of weights.
ARRAY_INDEX = 8 — Array of indices.

you see … two sets of uv data only one color

And no, you cant change or customize that, its a core component of the engine.
You can allways store additional data into textures. Blender also can bake into textures, so maybe this is your way to go.

Huh… well that sucks. Thank you for the informative answer though! XD

I’m going for a very specific, N64-esque styling, where a single texture is multiplied over a vertex color. The idea was to have separate sets of vertex colors for times of day, such as day and night, and interpolating between the two sets to forego realtime lighting altogether. For that reason I’d rather avoid having to bake in and include separate lighting textures and UVs.

I wonder if it’s possible to export two versions of the same mesh, each with its own set of unique vertex colors, and use a shader on one to draw from the color data from the other? Though I’m not sure if there’s a way to access a separate mesh in the shader of another…

Gubbles | 2020-09-24 17:48


possible to export two versions of the same mesh, each with its own set of unique vertex colors, and use a shader on one to draw from the color data from the other?

No thats not possible

I suggest what you want is vertex lighting, Wich is allready built in. Just hit the Vertex lighting flag under flags in the spatial shader. You can then use the build in lights and change there color and intensity for your day and night cycle.

And dont worry for performance, you dont have to bake those informations into a color channel. Even on the lowest end hardeware vertexlighting is insanly fast.

Baking the lighting into a vertex is although not working for anything that rotates in the scene.

klaas | 2020-09-24 18:39