[SOLVED] Question(s) about the Color buffer

IGNORE THIS


Hi everyone,

as I said in the title, I have some questions about the color buffer (VertexBuffer.Type.Color), which I can use to set a color per vertex.

This would be extremely useful, as I need to have a Mesh with a gradient in it. I can apply it to a vertex using this:

for (int i = 0; i < length; i++) {
    colorBuf[i] = color.mult((length-i)/length);
}

And in an update I set it like this:

this.setBuffer(VertexBuffer.Type.Color, 4, BufferUtils.createFloatBuffer(colorBuf));

I want to ask what this exactly does. Is this data send to the shader? If so, does Unshaded use it? If not, can I use it in my own? How?
Does it work on lines( setMode(Mode.Lines) )?
Because it doesn’t work for me.

Making a one-class test case is hard in this case, but I can post more relevant snippets.

Lol, I don’t think I have ever sold a problem of my own so fast.
forgot this:

mat.setBoolean("VertexColor", true);

Now I also see how to use this in a custom shader :slight_smile: .

1 Like

I know its solved, but for future reference anyone with similar issues… make sure you have

https://jmonkeyengine.github.io/wiki/jme3/advanced/jme3_shaders.html

and

http://javadoc.jmonkeyengine.org/com/jme3/shader/UniformBinding.html

bookmarked. It doesn’t look like they would have helped in this particular case, but overall for shader development, they are a must know, or at least know about, you WILL need to reference them at some point later =)

I would just append [SOLVED] in front of the topic title and remove that IGNORE title as I did exactly the opposide :wink:

Thanks for the links.
It would be great if all the in-wiki links worked too…

Done :chimpanzee_amused: