Continously update ColorMap of MeshVS_NodalColorPrsBuilder of MeshVS_Mesh

I'm trying to create a visualisation of a STL mesh where it's possible to continuously update the node colors.

I found MeshVS_Mesh and the MeshVS_NodalColorPrsBuilder where a color map can be specified as a Aspect_SequenceOfColor but i think this doesn't allow for continuous update of the node colors but always rebuilds the whole representation.

Is there a possibility with MeshVS_Mesh or any other mesh visualiser to specify the color sequence for the color map as a texture which will be used by a fragment shader to do the interpolation so the geometry doesn't need to be rebuilt?

Kirill Gavrilov's picture

I think that if you are looking for a fast update, you'll need to make own subclass of Interactive Object implementing ::Compute() method in desired way. It doesn't matter to use MeshVS_Mesh or a more basic class in this case - it might be simpler not using MeshVS_Mesh in case if you do not need to use it's other features (otherwise, you would have to re-implement them).

Dynamic update of a transfer function mapping values to colors could be implemented via custom GLSL program (which would avoid recomputing presentation at all, but could be limited by a number of attributes) or by defining a colormap texture (you would be able changing colors in the texture without re-uploading triangulation data).

Lion G.'s picture

Compute is not an option for me because the meshes might be huge :(

I'm new to OCCT shaders and played around a little and found that it's not obvious but easily possible to set all the uniforms of a shader (proxy) before each redraw. (Is this the idiomatic way btw?)

As you say, this is limited and if i understand right it's possible to update a bound texture sampler as well?

I used Graphic3d_Texture2D before with a texture set and no mipmaps but don't know how to update it dynamically without recomputing the whole mesh. Can you point me to some docs or give some hints?

Kirill Gavrilov's picture

There is a property Graphic3d_Texture2D::UpdateRevision() which could be used to ask TKOpenGl to upload new texture to GPU (new image should be returned by Graphic3d_Texture2D::GetImage()), combined with AIS_InteractiveObject::SynchronizeAspects(). Or, less efficiently, just set new Graphic3d_Texture2D instance to aspects.