Object mask with primId AOV

Hello,

I’m trying to obtain object mask for data labeling. My initial idea was to render scene a couple of times with entire scene once and with only enabled needed object. But using primId would also solve the problem if it worked. Instead i’m receiving rgba (0, 0, 0, 255)

so I have
drawTarget.AddAttachment("color", GL_RGBA, GL_FLOAT, GL_RGBA);
and
renderer_.SetRendererAov(TfToken("primId"));
but the whole buffer rendered with one Id.

Rendering color works fine.
Renderer HdStorm,

    params_.frame = 1.0;
    params_.complexity = 1.f;

    params_.enableLighting = true;
    params_.enableSceneLights = true;
    params_.enableSceneMaterials = true;
    params_.complexity = 1.f;
    params_.cullStyle = UsdImagingGLCullStyle::CULL_STYLE_BACK_UNLESS_DOUBLE_SIDED;
    params_.drawMode = UsdImagingGLDrawMode::DRAW_SHADED_SMOOTH;

    params_.enableIdRender = false;
    params_.enableSampleAlphaToCoverage = true;
    params_.forceRefresh = false;
    params_.gammaCorrectColors = true;
    params_.highlight = true;

And at the end if it were working, how do I map back from primId to prim path.

Thanks.

Hi Volodymyr,

I’m not certain about the issue with not getting the right data into your frame buffer, but I do know how the mapping from primId works.

Have a look at UsdImagingGLEngine::DecodeIntersection()

This function does a decoding step from the color values, which is something I have not used yet. But once the primId is there it calls this

SdfPath primPath = _renderIndex->GetRprimPathFromPrimId(primId);

Which returns an Rprim Path, which is an internal Hydra path and that can be mapped to the path on the original UsdStage.

Also note that in order to support instanced prims in your selection/masking setup you also need to get the instanceId buffer as well. If you look at the posted code, you can see how that is decoded, which makes it a bit more complicated.

I hope this pointer is helpful.

  • Florian

Hi,

I think another good example is to look at :

Regards,
David

Thanks for code samples.

For now I went with twice rendering to obtain mask. I guess I will need to implement object mask using primId if performance will be a concern.
I guess I can mark it as a solution than.