Change Color of scanned area during scan

Hi together,

i’ve started playing arround with 0.10sdk and the Sample Scanner App. Is there a posibility to change the Color of the already scanned area (Kind of light Grey) into a customized Color?

i already tried to look for a solution in the Forum but it seems there is no matching Topic.

Best Regards


I think you’d have to write a function to use instead of STScene - renderMeshFromViewpoint


I’ve now focus back on that topic. I tried to understand whats happening and when the colorizing during scan is happening.

Unfortunately i found no colors to edit. I’ve got no approach in how to start solving this.

Any other hints?

Thanks a lot in advance

Hi @thorsten.steparsch

If you are working off the Scanner smaple code, you are going to want to be looking at the fragment shaders in CustomShaders.h. That’s where all the colors and shading are happening.

const char *fragmentShaderSource ()


gl_FragColor = vec4(v_luminance, v_luminance, v_luminance, 1.0);

Google OpenGL shaders or GLSL. Bit too long to explain in a forum post, but should give you a place to start.

-Andy W

1 Like

Hi @andy.warwick

thanks for your response, was a good starting point. For now i understood that the CustomShaders are responsible for the Meshing when Scan is Done.

I played around and was able to change the color with fixed values for testing.

In additon to that i also understood that the different classes in CustomShaders.h are for the different MeshViews.

But i was not able to find a ShaderClass which is able to change the color which is displayed during the scan, not afterwards.

Is the CustomShaders.h just responsible for the Colors after finishing Scan? As i had a look i just saw the usage just in the Is that correct or am I completely wrong?

Looks like shaders for actual scan display are in

-Andy W

but seems there is no one accessible… :frowning:


Do you mean that you would like to colorize the model while scanning? This is something that I have not seen done yet by anyone. Correct my if I am wrong but normally STColorizer is done after the scanning is completed.

Maybe one could try running STColorizer (bi-secondly or something) as background task during the scanning and then try using the custom shaders. I have no idea if this would work.


Hi Petja,

exactly, i would like to colorize the mesh while scanning. I think there is a Shader which is doing to current colorizing to the light gray color, but i can’t find it. All the CustomShaders are just modifiying the results in the MeshViewController.

Till now i don’t know where the shading of the mesh while scanning is happening. But i also think it is in the

i appreciate every kind of hint helping on this topic.

Thanks to all

Hi Thorsten,

I am pretty sure that you can’t find a place where you can just input your own colours into the scene mesh. You need to build this functionality. I might be wrong but this is how I see it.

I think like @jim_selikoff said earlier you would need to replace this function with your own…

   [_slamState.scene renderMeshFromViewpoint:cameraViewpoint 

…to draw the whole mesh again on the scene but like the example scanner project states this would a lot slower process.

/** Render the scene mesh from the given viewpoint.

A virtual camera with the given projection and pose matrices will be used to render the mesh using OpenGL. This method is generally faster than using sceneMeshRef and manually rendering it, since in most cases STScene can reuse mesh data previously uploaded to the GPU.

**@param** cameraPose A GLKMatrix4 camera position used for rendering.

**@param** glProjection Projection matrix used during rendering. See also [STDepthFrame glProjectionMatrix] and [STColorFrame glProjectionMatrix].

**@param** alpha A float value for transparency between 0 (fully transparent) and 1 (fully opaque)

**@param** highlightOutOfRangeDepth Whether the areas of the mesh which are below Structure Sensor minimal depth range should be highlighted in red.

**@param** wireframe Whether to render a wireframe of the mesh or filled polygons. When enabled, STMapper needs to be initialized with the `kSTMapperEnableLiveWireFrameKey` option set to `@YES`.

**@return** TRUE on success, FALSE if there is no STMapper attached to the same STScene with the corresponding (wireframe or triangles) live mode enabled.


Hopefully I am not driving you to a full desperation. :slight_smile: