jPCT-AE - a 3d engine for Android > Support

Vertex colouring from last jPCT-AE version

(1/5) > >>

mxar:
Hi,

vertex colouring is supported by the latest jPCT-AE version?

Thanks in advance.

EgonOlsen:
Yes and no. There's no direct support but you can use VertexAttributes for this. Do something like


--- Code: ---int vertices = obj.getMesh().getUniqueVertexCount();
data = new float[vertices * 4];
for (int i = 0; i < data.length; i++) {
// set your color values here for each vertex...
}

VertexAttributes vas = new VertexAttributes("colorinfo", data, VertexAttributes.TYPE_FOUR_FLOATS);
obj.getMesh().addVertexAttributes(vas);

--- End code ---

and then write a shader (or modify one of the default shaders) and add


--- Code: ---attribute vec4 colorinfo;

--- End code ---

to the vertex shader. You can then use these color values in the shader for your own horrifying purposes... ;)

mxar:

Many thanks.
 

mxar:
Hi again,

How  can i assign the vertex color colorinfo in the vertex shader?

I need to use the position of vertex inside the vertex shader program?

I wrote a program based on previews reply but compiler shows the following error message:

"Error missing attribute position in vertex shader"

Also, should I write and a fragment shader?

Can you give me an idea of how the vertex and (if needed) fragment shader must be?


Thanks in advance

EgonOlsen:
Seems like as if you vertex shader consists solely of this one line...that's not what i meant. You have to provide a vertex and a fragment shader and the vertex shader has to have this colorinfo (or whatever name you choose) attribute in addition to the other attributes. You can modify one of the default shaders for this, i.e. unzip the jpct_shaders.zip in the lib directory of the distribution and pick a shader that fits. Which one that is, highly depends on your scene. If you want to be sure, you can simply pick defaultFragmentShader and defaultVertexShader. They include every feature that a scene in jPCT can use but if it doesn't, they might be slower than needed. Anyway, i would start with them. Add the colorinfo attribute to the vertex shader and do something with it. You most likely don't have to modify the fragment shader.
If you want to use vertex colors only without lighting or even textures, the shader can look a whole simpler than the default shaders. It depends, what you want to do with it...

Navigation

[0] Message Index

[#] Next page

Go to full version