So I want to add extra instancing attributes to my geometry instancing setup.
I know that I already have transformation matrix arranged for me. I tried to follow the logic of this thread Hardware instancing and color, and did the following:
- overriden instancingVS chunk with
attribute vec4 instance_line1;
attribute vec4 instance_line2;
attribute vec4 instance_line3;
attribute vec4 instance_line4;
attribute vec4 block_uv; //xy : uv uffset, zw : uv scale
- overriden uv0VS chunk with:
vec2 getUv0() {
vec2 resultVertex = vertex_texCoord0 * block_uv.zw;
return resultVertex + block_uv.xy;
}
- added extra vertex format semantic:
const formatDesc = [
//
// transformation matrix property block
{ semantic: pc.SEMANTIC_TEXCOORD2, components: 4, type: pc.TYPE_FLOAT32 },
{ semantic: pc.SEMANTIC_TEXCOORD3, components: 4, type: pc.TYPE_FLOAT32 },
{ semantic: pc.SEMANTIC_TEXCOORD4, components: 4, type: pc.TYPE_FLOAT32 },
{ semantic: pc.SEMANTIC_TEXCOORD5, components: 4, type: pc.TYPE_FLOAT32 },
//
// uv offset\scale
{ semantic: pc.SEMANTIC_TEXCOORD6, components: 4, type: pc.TYPE_FLOAT32 }
];
and then layed out all of the data in float array as expected. However, I’m seem to be missing attribute definition in shader itself, since I get:
Vertex shader attribute "block_uv" is not mapped to a semantic in shader definition.
so. aside from having a fully custom shader for this, how can I access and add attributes to existing standard shader, if that’s even possible?