1. Depending on how large the mesh is and how many you would need, and what else takes up resources, this could work just fine.
2. Yes, if you start using a SCNProgram you lose the default shaders.
"Or can we still use the default Scenekit vertex and fragment shaders even when using SCNProgram?”
Yes, you may be able to use shadermodifiers to reach you goal. Shadermodifiers allow you to add snippets of shader code to the default shaders. For example, I have a shadermodifier with a uniform “transmat” in the geometry entry point. Every frame or less often this transmat (mat4) is updated by setValue forKey. Inside the shadermodifier code I multiply the position of the vertex with the transmat matrix.
For example (note I use the alpha value of the color to determine if it's one of the vertices that need to be moved:
NSValue *transmatVal = [NSValue valueWithSCNMatrix4:transmat];
[_solidNode.geometry setValue:transmatVal forKeyPath:@"transmat"];
_solidNode.geometry.shaderModifiers = @{SCNShaderModifierEntryPointGeometry :
@"uniform mat4 transmat;\n"
"#pragma body\n"
"if (_geometry.color.a==0.5) {\n"
"_geometry.position = transmat * _geometry.position; }\n"
"_geometry.color = vec4(_geometry.color.r, _geometry.color.g, _geometry.color.b, 1.0);\n"
};
That works great (and blazing fast) because all the vertices that are moved need the same movement/rotation/scaling in my case.
Unfortunately, it’s (to my limited knowledge) not possible to add another buffer through shadermodifiers. But if your movement consist of only translations on x,y,z per vertex, AND you don’t use vertex colors, you could use the rgb values of the color semantic to store the translation. That way you can calculate the movement per vertex on the CPU, update only the geometrysource of the scngeometry that holds the colors, and let the gpu perform the actual movement.
This is how I update the SCNGeometry colors only by reusing the geometry sources for verts, normals and the element, i.e. only _colorSource is recalculated.
SCNGeometry *_rebuildGeometry = [SCNGeometry geometryWithSources:@[_SolidNode.geometry.geometrySources.firstObject, _SolidNode.geometry.geometrySources[1], _colorSource] elements:@[_SolidNode.geometry.geometryElements.firstObject]];