Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Advanced Stencils

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
User avatar
Gsand
Posts: 28
Joined: 24 Oct 2016, 18:00
Location: Los Angeles, California

Advanced Stencils

Post by Gsand » 25 Aug 2017, 07:19

There have been a few posts discussing Advanced Stencils and a scene or 2 showing how to nest Advanced Stencils into a hierarchy.
Been doing some research to try and better understand how the Stencil buffer works and would be grateful for a few explained answers.

What is the Reference property vs the Mask property?

Thanks all

User avatar
Götz_B
Posts: 180
Joined: 21 May 2013, 13:01

Re: Advanced Stencils

Post by Götz_B » 01 Sep 2017, 11:37

Hi Greg,

Reference is the actual value which is tested against.

The mask is applied to the reference value before the test. The mask can be used to use only certain bits of the reference value. It's is a bit wise AND operation. 3 in binary code is 0011. So applying this mask to a reference value, means only the lowest two bits of the reference value are used.

A mask value of -1 means the Reference is not masked at all. Cause -1 in binary code means every bit is 1.

Hope that helps a bit...

User avatar
Gsand
Posts: 28
Joined: 24 Oct 2016, 18:00
Location: Los Angeles, California

Re: Advanced Stencils

Post by Gsand » 12 Sep 2017, 22:09

Götz,

Thanks for the clues. can you elaborate more what the reference is? Is it a grid of 8 bit numbers?

User avatar
lerou
Posts: 345
Joined: 06 Sep 2013, 07:14
Location: Hamburg, Germany

Re: Advanced Stencils

Post by lerou » 13 Sep 2017, 09:01

The reference is an integer value - the stencil buffer is an integer buffer. The size is usually 8 Bits per pixel. Using the built in stencil nodes you can use one of eight layers. That's basically each bit used separately (reference value: 1, 2, 4, 8, ..). Using the advances stencil node you can define your own reference value (23, 42, ..). Using 2^n is useful because you can combine them and use the masking (see bit operations in programming languages). However in most cases you just need to mask an area, so you're usually just setting a reference value and check against it (equal or not equal). If you have several elements in screen that use stencil you should use different stencil reference values. Imagine a text box where you use stencil to limit text drawing to some box - if you have more than one box and they overlap, you could get undesired behaviour if you use the same reference value for all text boxes.

Post Reply