Stencil buffer does not work [It does! stencil shadows soon]

Stencil buffer does not work can you spot my problem? It should only render when panda hits the card.

import direct.directbase.DirectStart
from pandac.PandaModules import loadPrcFileData
from pandac.PandaModules import NodePath,CardMaker,StencilAttrib
loadPrcFileData("", """
framebuffer-stencil 1
cm = CardMaker("cardmaker")
readerOnlyIfOne = StencilAttrib.make(1,StencilAttrib.SCFEqual,StencilAttrib.SOKeep,StencilAttrib.SOKeep,StencilAttrib.SOKeep,0,1,0)
dontRenderPutOne = StencilAttrib.make(1,StencilAttrib.SCFAlways,StencilAttrib.SOZero,StencilAttrib.SOReplace,StencilAttrib.SOReplace,1,0,1)
viewingSquare = render.attachNewNode(cm.generate())
view = loader.loadModel("panda")

I will write you some stencil shadows as soon as i figure out how panda uses the stencil buffer.

You should change the config before importing DirectStart.
I’m looking forward for your stencil shadow. :smiley:

thanks it works now and need to finish the rest of the shadow

its works even better if you set the stencil stuff to transparent even though it is not showing. I guess it effects draw order better then my manual sorting … which does not do any thing

i made all i could on the stencil shadows. The artifact you see in the image is done by not enough stencil bits. Although i have asked for 8:

from pandac.PandaModules import loadPrcFileData
loadPrcFileData("", """
framebuffer-stencil 1
stencil-bits 8

it still does not give them. It gives me only 1 or 0 bits. Is there any way around this problem as soon as i get the panda compiled i will try to find where the stencil source is.

thanks for all your input!

Great progress !

this is what I got :
I already have 8 bits stencil buffer, even without asking for it :
print 'accumulation bits:',fbProp.getAccumBits()
print 'alpha bits:',fbProp.getAlphaBits()
print 'color bits:',fbProp.getColorBits()
print 'depth bits:',fbProp.getDepthBits()
print 'stencil bits:',fbProp.getStencilBits()

the error was in my algorithms! Now fixed! I will clean up and speed up the code and post it soon.

stay tuned!

as I guessed, it must be your shader.
that’s GREAT, and would be GREATER if included in 1.4.0 shipment.

it uses no shaders. Its the 1980s shadow tech that is now becoming popular again with engines like doom and half life.

It still very slow and would have to be recoded in C++ for sure. When is the 1.4.0 shipment?

I know what it is.

How do you build the edges and extrude it ? iterating through the vertex data in Python ?
I would do that since I don’t have any C/C++ exp. That’s what keep me away from it.

this is a cool thing from McCool :

Shadow Volume Reconstruction from Depth Maps
Michael D. McCool
University of Waterloo

This is awesome work Treeform!
I’m currently using the shadow algorithm that is also going to be included in 1.4.0 - but I achieve very pixely shadows there. I’m looking forward to see this shadow working in my program!

Oh, and a question: can your method also project shadows on different objects than just a plane?

pro-rsoft, wikipedia always a great place to start :

pro-rsoft: yes it shadowed itself in the image. There is not real “lights” or shades in the scene. Yes iterating in python and making a new 3d shadow solid is the major slow down. But it can be used to generate a solid for say a game level once during startup.