How to add attributes in Shader?

For example in vtkPolyDataVS.glsl
attribute vec4 vertexMC;
I want to add another attribute like vertexMC;
These operations need to be placed in the shader.
I now call back the code data based on the PloydataMapper-CallBack. I think this processing can add uniform and attribute to the shader in Mapper; how to add attribute I have no clue, I just found these codes,

cellBO
.getVAO()
// VertexArrayObject
.addAttributeArray(
cellBO.getProgram(),
cellBO.getCABO(),
‘vertexMC’,
cellBO.getCABO().getVertexOffset(),
cellBO.getCABO().getStride(),
model.context.FLOAT,
3,
model.context.FALSE
);

but I can’t find where I add the data.
I hope you can give me some suggestions and methods, I look forward to your reply!

All the shader replacements happen before any attribute values are passed by the mapper. You should be able add a replacement for one of the Dec tags like:

 mapperViewProp.addShaderReplacements(
        'Vertex',
        '//VTK::PositionVC::Dec',
        true,
        '//VTK::PositionVC::Dec\n  attribute vec4 vertexMCN;\n',
        false
      );

As far as passing data for the attribute, you’d have to access the VAO and call addAttributeArray

Thank for your reply.
My idea is similar to what you think. I use mapperViewProp.addShaderReplacements to replace code in shaders.And,Get VAO by using PloydataMapper CallBack, and then call addAttributeArray.
Like this:

const mapperSpecificProp = mapper.getViewSpecificProperties();
mapperSpecificProp.ShaderCallbacks = [];
mapperSpecificProp.ShaderCallbacks.push({
	userData: ...,
	callback: function(userData, cellBO, ren, actor, model) {
		cellBO
        .getVAO()
        // VertexArrayObject
        .addAttributeArray(
        cellBO.getProgram(),
        cellBO.getCABO(),
        ‘vertexMC’,
        cellBO.getCABO().getVertexOffset(),
        cellBO.getCABO().getStride(),
        model.context.FLOAT,
        3,
        model.context.FALSE
        );
	}
});

But for passing data for the attribute, I did not find the corresponding parameter in addAttributeArray.
Maybe I don’t understand the code well enough. I hope you can give me some clear suggestions.
Looking forward to your reply!

I looked up the definition of VAO (details on how the data is stored and how to use it), if you want to import data you need to use a VBO (the vertex buffer object is responsible for the actual data storage).
The specific details are being advanced. If you have any better suggestions, I hope to share and discuss together!
Looking forward to your reply!

Right, they might be advanced topics but there are some good tutorials that explain the inner workings like Tutorial 32 - Vertex Array Objects

Thank you for your reply, I would like to ask if you have added attributes to Shader in VTK before?

Yes, there are attributes in both the polydata and volume mappers. If you’re asking about adding attributes via replacement shaders, I don’t think there is an existing example of it.

Thanks for your help this time, I can already customize the shader!