Stencil doesn't work on render-targets

#1

Stencil doesn’t work on render-targets.
This is a funny observation, but I would like to know what caused this restriction and how it can be corrected?
Is it because render.FORMAT_DEPTH does not provide formats like D24S8 where there are bits for stencil?

0 Likes

#2

The solution has been found.
Render-target documentation (https://defold.com/ref/render/#render.render_target:name-parameters) doesn’t mention anything about stencil.
But if you do so:

  local color_params = {
        format = render.FORMAT_RGBA,
        width = RT_WIDTH,
        height = RT_HEIGHT,
        ...
    }
    local depth_params = {
        format = render.FORMAT_DEPTH,
        width = RT_WIDTH,
        height = RT_HEIGHT,
        ...
    }
    local stencil_params = {
        format = render.FORMAT_STENCIL,
        width = RT_WIDTH,
        height = RT_HEIGHT,
        ...
    }
  render_target = render.render_target("render_target_1", {
        [render.BUFFER_COLOR_BIT] = color_params,
        [render.BUFFER_DEPTH_BIT] = depth_params,
        [render.BUFFER_STENCIL_BIT] = stencil_params
  })

then the problems will be solved.

4 Likes

#3

Ah, the example only shows color and depth. But in the text it says “The table should contain keys specifying which buffers should be created with what parameters”.

0 Likes

#4

Formally, it is so.
However, the important thing is that it is impossible to find the word “stencil” in this context.
The fact is that without a keyword anchor it is not clear WHAT to look for and WHERE to find it.

I wouldn’t have thought of linking stencil and the render-target buffer together (if I wasn’t a DirectX expert).

0 Likes