Re: Decals with projected textures again??

New Message Reply Date view Thread view Subject view Author view

John Rohlf (jrohlf++at++tubes)
Tue, 25 Jul 95 9:37:54 PDT


>
> Hello again,
>
> I am following up my own posting because I have found out what the problem
> was, but I still don't know how to fix it.
>
> I wrote:
>
> > I have been working on something that uses a projected texture type of idea
> > for quite a while now. It requires pfDraw() to be called twice in each
> > frame. Now I've got it all kind of working except for co-planar polygons
> > (and multiprocessing because changing the draw-mask doesn't seem to be
> > having any effect, but that's another problem!).
> >
> > The first call to pfDraw() is really just there to get the zbuffer right,
> > and the second call is done using zfunction(ZF_EQUAL). Now for geometry
> > drawn with pfDecal() I have a problem.
> >
> > If I use PFDECAL_BASE_DISPLACE, then the laters do not appear at all. What
> > I would expect to be happening is this:
> >
> > - First call to pfDraw():
> > - Base geometry is drawn, with z=1 say.
> > - displacepolygon() is called.
> > - Layer geometry is draw, with z=1, but displacepolygon() offsets
> > this and makes it, say, z=2 instead (this avoids "Z-flickering").
> > - zfunction(ZF_EQUAL) is called.
> > - Second call to pfDraw():
> > - Base geometry is drawn, with z=1, exactly overwriting what was
> > there before, but leaving blank the sections where the layer
> > geometry was drawn (since here z==2).
> > - displacepolygon() is called.
> > - Layer geometry is draw, with z=1, but displacepolygon() offsets
> > this and makes it z=2 instead, exactly overwriting what was
> > previously rendered by the layer geometry.
> >
> > However this is not what happens, since I do not see my layers at all. In
> > fact the base is rendered as if the layers were never drawn.
>
> Using gldebug, I have discovered that the decal layers in a pfLayer node are
> drawn using zwritemask(0x0). This is usually fine, but makes it impossible
> to do what I wanted to do above (or the standard projected texture
> algorithm) as the ZF_EQUAL pass will fail for this geometry. All I need to
> do now is stop the call to zwritemask(0x0), but HOW? There is no way to
> pfOverride it.
>
> The only solution I can think of (which I DON'T like the idea of), is to
> change all the pfLayer nodes to pfGroup nodes and add call-backs to handle
> the decaling myself. There must be a better way!?!?!?

        I'm curious what kind of multipass algorithm you are using,
specifically the blendfunction() you use for the first and second passes.
If, on the second pass you use blendfunction(BF_ZERO, BF_SC) which
modulates the destination color (normal scene color) with the incoming
color (projected light source) then displaced decal should work because
only the base geometry will affect the frame buffer.
For the above blendfunction you must use a PFTE_DECAL pfTexEnv:
         
        pfEnable(PFEN_TEXTURE);
        pfApplyTEnv(decalEnv);
        pfApplyTex(projTex);
        pfDisable(PFEN_LIGHTING);

        pfOverride(PFSTATE_TEXTURE | PFSTATE_TEXENV |
                   PFSTATE_ENTEXTURE | PFSTATE_ENLIGHTING, 1);

         
BTW: in 2.0, PFDECAL_LAYER_DISPLACE no longer disables zwritemask.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:42 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.