Skip to main content
GameDev.net gamedev.net
🔒 Locked

Stencil shadow volumes without stencil usage

Started by _WeirdCat_ Jan 30, 2019 at 2:27 AM 3 replies 2.5k views
Original Post
_WeirdCat_
_WeirdCat_

I just found that using stencil in a framebuffer aint supported by the hardware and its emulated in software mode, now i wonder if i could somehow use a stencill pass in fragment shader, i need to combine whenever a z test fails or passes, thus i dont even know if this can be done - from my understanding only those fragments are passed to fragment shader which pass depth test right? - so maybe using diffrent glDepthFunc() would do the trick.

TRUE or FALSE?

Maybe theres a simplier solution?

Hodgman
Hodgman
9 minutes ago, _WeirdCat_ said:

I just found that using stencil in a framebuffer aint supported by the hardware and its emulated in software mode

What?

9 minutes ago, _WeirdCat_ said:

i need to combine whenever a z test fails or passes, thus i dont even know if this can be done - from my understanding only those fragments are passed to fragment shader which pass depth test right?

To get depth pass/fail info in a pixel shader, you'll have to implement z-buffering yourself in the pixel shader, by making your own "depth buffer" that's bound as a read-write texture (D3D: UAV / GL: Image). This sounds horribly slow though, so you should probably use the hardware depth/stencil as usual...?

_WeirdCat_
_WeirdCat_

Oh thats a good idea i just clear hw depth buffer and draw caps where i test from a depth tex if it fails or not.


About that first quote,

glFramebufferRenderbuffer(GL_FRAMEBUFFER,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER,
RBO_ID);

That what is causing framerate drop, i tried it with a framebiffers that even dont use stencil and simple drawing of a box takes about 1 second

_Silence_
_Silence_
4 hours ago, _WeirdCat_ said:

glFramebufferRenderbuffer(GL_FRAMEBUFFER,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER,
RBO_ID);

Why using a renderbuffer and not simply a texture attachment ?

Also try to explicitly give the good format, ie GL_STENCIL_INDEX8 (or similar if it exists on GLES). If you also need depth, GL_DEPTH24_STENCIL8 should be good (check GLES if such exist).

18 hours ago, _WeirdCat_ said:

I just found that using stencil in a framebuffer aint supported by the hardware and its emulated in software mode


4 hours ago, _WeirdCat_ said:

That what is causing framerate drop, i tried it with a framebiffers that even dont use stencil and simple drawing of a box takes about 1 second

This looks weird to me. And that doesn't mean this is emulated in software.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.