Advanced stencil buffer ops

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Advanced stencil buffer ops

Post by Kalda »

Hello!
I am just probably blind, but can't find answer in docs.
I need to manipulate with stencil buffer and use it for masking.
So is there any way to achieve these without modifying the library?

1) Stencil ops like invert/increment/decrement
2) Select depth/stencil buffer mode like 8-bits for stencil and 24-bit depth (and what is default)
3) Color masking (like render into blue channel only or disabling color rendering at all)
4) Rendering directly to stencil buffer from pixel shader

Thanks in advance! I'd be looking for this forever...
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Advanced stencil buffer ops

Post by Mel »

You have to modify the library. The stencil buffer is only used by the shadow volumes, and there is no any direct way to modify it.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Re: Advanced stencil buffer ops

Post by Kalda »

Ok thanks!
So question to library maintainers.
Is there any good reason for this? I offer to write the patch for SMaterial.
IMHO it is an elementary function of any 3D engine and should be accesible directly through Irrlicht API (Ogre also has it accessible in material system).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Advanced stencil buffer ops

Post by hybrid »

Well, we discussed this a while ago, and did not yet decide whether we really need stencil modes in the material system, or just in scene manager settings. Because it's only required to have it in SMaterial if these values change from object to object during one render stage. Otherwise, it could be provided via a different, e.g., a shadow scene and the main scene. But for a first start you could provide a patch for the basic driver interfaces to access stencil settings. These functions could then be used for the higher levels once we know where to put it.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Advanced stencil buffer ops

Post by hendu »

I've been using stencil ops without modifying the library for a long time.

Works well since irr doesn't touch the stencil when one doesn't use its stencil shadows.


The color masking is already supported, and rendering to stencil is really slow, so you really don't want to do that on any card.
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Re: Advanced stencil buffer ops

Post by Kalda »

2 hendu:
Well I need it for "Stencil then cover" vector graphics rendering like NV_path_rendering.
What I am trying to acomplish is to make accelerated VG library for my bachelor thesis.
And this is the best (fastest & simplest) way to do that. In fact it definitely is not that
slow as you say. The performance is really good. I got just nasty hacked demo at this point,
so I cannot provide any further info. But if everything will be according to plan, I will
release the library demo with source here in next few weeks.

2 hybrid:
I am on it ;)
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Advanced stencil buffer ops

Post by hendu »

Are you related to cairo by any chance? Recent talk on phoronix is that rendering trapezoids on the cpu is still faster unless you have a really good gpu (ivy bridge is not enough for example).
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Re: Advanced stencil buffer ops

Post by Kalda »

I am just cairo user ;)
Main point of the thesis is to let everything compute on GPU from path (line strip) and compare results.
But If you ever see the NV_path_rendering extension, they claim it is many times faster than cairo
(there are graphs in their paper). So I really look forward to see my results.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Advanced stencil buffer ops

Post by hendu »

Yes, on a high-end Nvidia GPU no doubt ;)


I googled nv_path_rendering benchmarks, and found this:
http://zrusin.blogspot.fi/2011/09/nv-pa ... ering.html

Qt software rendering was 4x the speed of the gpu-accelerated nv extension, on a Quadro 600.
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Re: Advanced stencil buffer ops

Post by Kalda »

Yes, as you say no doubt ;)
I cannot compare anything with that 'cause I am running on HD5870.
Second think is, I am currently targeting SM4 cards and working with
geometry shaders which eliminates many old cards. Thats why I am
interested in the results. At this point "only Carmack knows!" :D
Kalda
Posts: 47
Joined: Wed Aug 23, 2006 1:38 pm
Location: Prostejov, Czech Republic
Contact:

Re: Advanced stencil buffer ops

Post by Kalda »

So here comes the first diff for stencil access!
(I am ready for criticism and to modify it.)

Diff file here
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: Advanced stencil buffer ops

Post by TheMrCerebro »

It would help to have total control of the Stencil Buffer. Would be easier to make, optimizations shadows and other actions.
We know that the future is in use Shadow Maps, but there are still nostalgic like me :D

PD: Thanks Kalda for the DIFF!!!
Follow me on twitter: @themrcerebro
Post Reply