# How to setup a zbias and alpha threshold for rendering decals

**URL:** <https://forum.aousd.org/t/how-to-setup-a-zbias-and-alpha-threshold-for-rendering-decals/2449>\
**Category:** Hydra\
**Tags:** cpp\
**Created:** [May 13, 2025, 11:58am UTC](https://forum.aousd.org/t/how-to-setup-a-zbias-and-alpha-threshold-for-rendering-decals/2449 "2025-05-13T11:58:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grimmigbeisser](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@Grimmigbeisser](https://forum.aousd.org/u/Grimmigbeisser)\
**Post date:** [May 13, 2025, 11:58am UTC](https://forum.aousd.org/t/how-to-setup-a-zbias-and-alpha-threshold-for-rendering-decals/2449/1 "2025-05-13T11:58:11Z")

</div>

Hi, i am setting up an HdxRenderTask with the following code:

auto decoRenderTaskId = GetControllerId().AppendChild(TfToken(“renderTask\_decorations”));  
GetRenderIndex()-\>InsertTask(&delegate, decoRenderTaskId);

```
HdxRenderTaskParams renderParams;
renderParams.camera = freeCameraSceneDelegate->GetCameraId();
renderParams.viewport = viewport;
renderParams.framing = framing;
renderParams.overrideWindowPolicy = overrideWindowPolicy;

renderParams.enableLighting = true;
renderParams.depthFunc = HdCmpFuncLEqual;
renderParams.cullStyle = HdCullStyleBack;
renderParams.alphaThreshold = 0.5f;

renderParams.depthBiasUseDefault = false;
renderParams.depthBiasEnable = true;
renderParams.depthBiasConstantFactor = 0.01f;
renderParams.depthBiasSlopeFactor = 1.f;

renderParams.blendEnable = false;
renderParams.depthMaskEnable = true;
renderParams.enableAlphaToCoverage = true;
renderParams.useAovMultiSample = true;

HdRprimCollection coll(HdTokens->geometry,
                       HdReprSelector(HdReprTokens->refined),
                       SdfPath::AbsoluteRootPath().AppendChild(TfToken("DecorationMeshes")));
coll.SetMaterialTag(HdStMaterialTagTokens->masked);

TfTokenVector renderTags = {HdRenderTagTokens->geometry};

delegate.SetParameter(decoRenderTaskId, HdTokens->params, renderParams);
delegate.SetParameter(decoRenderTaskId, HdTokens->collection, coll);
delegate.SetParameter(decoRenderTaskId, HdTokens->renderTags, renderTags

```

The collection is rendered , but without zbias and alpha masking applied. I debugged through hydra and veryfied that even the gl call is issued:  
glPolygonOffset(\_depthBiasSlopeFactor, \_depthBiasConstantFactor); is called with the correct values.  
Maybe i am missing something important to set this up? If i play around with other render task parameters they are reflected in the rendered scene. Only zbias and alpha treshold doesn’t seem to do anything. Why could this be?

Cheers,  
Robert

---

<div class="post-metadata">

**Author:** ![Grimmigbeisser](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@Grimmigbeisser](https://forum.aousd.org/u/Grimmigbeisser)\
**Post date:** [May 14, 2025, 11:08am UTC](https://forum.aousd.org/t/how-to-setup-a-zbias-and-alpha-threshold-for-rendering-decals/2449/2 "2025-05-14T11:08:46Z")

</div>

Sorry i found the reason. My fault: i needed negative bias values instead of positive. However the alpha threshold still not seems to do anything. How do i setup alpha masking? I suppose that is done in the preview shader?

---

<div class="post-metadata">

**Author:** ![Grimmigbeisser](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@Grimmigbeisser](https://forum.aousd.org/u/Grimmigbeisser)\
**Post date:** [May 15, 2025, 6:58am UTC](https://forum.aousd.org/t/how-to-setup-a-zbias-and-alpha-threshold-for-rendering-decals/2449/3 "2025-05-15T06:58:24Z")

</div>

Alright! I found the reason now why i don’t see alpha. It was because i forgot to connect the alpha texture output to the opacity input of the PreviewSurface shader. The rgb output of the UvTexture node outputs just rgb, not a and so without connecting alpha in addition, it won’t consider texture transparency of course.
