Inject wireframe override color for HdRepr

Hello,

We have implemented a wireframe selection highlighting using scene indices. The high level mechanism is that through a chain of scene indices, with one specifically for wireframe, we introduce a HdRepr for inserting wireframe like so:

HdRetainedContainerDataSource::New(
        HdLegacyDisplayStyleSchemaTokens->displayStyle,
        HdRetainedContainerDataSource::New(
            HdLegacyDisplayStyleSchemaTokens->reprSelector,
            HdRetainedTypedSampledDataSource<VtArray<TfToken>>::New(
                { HdReprTokens->refinedWireOnSurf, HdReprTokens->wireOnSurf, TfToken() })));

This gives us the wireframe rendered as expected. In our code, the color for this wireframe is set through HdxTaskController’s SetRenderParams() where we set HdxRenderTaskParams’ wireframeColor parameter to the required color. Our understanding is that is this linked to Hydra’s renderpass management and the corresponding shader that Hydra injects.

We are now trying to set an override for this wireframe per prim. Looking through the code we found that there maybe a possibility. In renderPass.glslfx we noticed the shader code:

#if defined(HD_HAS_overrideWireframeColor)
    return HdGet_overrideWireframeColor();
#elif defined(HD_HAS_wireframeColor)
    return HdGet_wireframeColor();

In the Hydra codebase, there are tokens declared to override the wireframe color at a few places.

We are a little unclear how we are supposed to set this override color from the application side. It would be great to understand how to leverage this and set the override color for wireframe per prim.

Thanks!

Hi Rakesh,

I’m not actually sure at the moment where overrideWireframeColor is coming from. One thing you could try is to just define a primvar on your prim called “wireframeColor” or “overrideWireframeColor”? Those may warrant being moved to a “primvars:hydra:wireframeColor” down the line, but I’m curious if that just works.

Thanks!
Tom