• 13
• 18
• 19
• 27
• 9

# New demo and some trouble

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First of all, a screenshot and the binaries. This demo was tested on a Radeon 9700 Pro, but should work with any card supporting VS 2.0 & PS 2.0 Controls: +/- To add or remove a light; C for volume extrusion on the CPU (bug free). V for volume extrusion on the GPU (^%$#^$^%#^ %$%$\$ and more). Space to capture/let go of the mouse AQWSDE + arrows + mouse to navigate around the scene. P to switch from two passes volume rendering to a single pass using either ATI separate stencil or Nvidia two sides stencil. ESC exit Now the problem: I'm having some trouble getting shadow volumes extrusion on vertex program working properly. The problem is, the shadow casting is correct and similar to the algorithm executed on the CPU, however as soon as I turn on VS acceleration, I tend to get a lot of a flickering on some of the polygons in the scene. This flickering is not due to any common problem known with Shadow volumes caused for example by the near or far plane clipping the volume since I test thouroughly for those cases and then proceed to cap or uncap my shadows. The flickering gets worse as I increase the number of active lights in the scene, and at some point (from 2 active lights and up) I start to witness some transparent polygons from various part of my scene floating...scary I tried tempering with the polygon offset settings, that sure fixed the flickering with the first light, and reduced it tremendously in the second, however it is still there as the number of active lights increment beyond 2. Any suggestion? [Edited by - JavaCoolDude on August 22, 2004 2:18:09 AM]

##### Share on other sites
Btw since I couldn't find any source example on how to use ATI separate stencil to do shadow volumes in one pass, here's the code that I wrote:

From GLTransformGroup.cpp

 ...snip...      if(renderPath & NV_SHADOW_PASS || renderPath & ATI_SHADOW_PASS){        glDisable(GL_CULL_FACE);        if(renderPath & ATI_SHADOW_PASS){          glStencilFuncSeparateATI(GL_ALWAYS, GL_ALWAYS, 0, ~0);          if(needZFail){            glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);            glStencilOpSeparateATI(GL_BACK,  GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);          }          else          {            glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);            glStencilOpSeparateATI(GL_BACK,  GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);          }         }        if(renderPath & NV_SHADOW_PASS){          if(needZFail){            glActiveStencilFaceEXT(GL_BACK);            glStencilFunc(GL_ALWAYS, 0, ~0);            glStencilOp(GL_KEEP, GL_INCR_WRAP_EXT, GL_KEEP);            glActiveStencilFaceEXT(GL_FRONT);            glStencilFunc(GL_ALWAYS, 0, ~0);            glStencilOp(GL_KEEP, GL_DECR_WRAP_EXT, GL_KEEP);          }          else          {            glActiveStencilFaceEXT(GL_FRONT);            glStencilFunc(GL_ALWAYS, 0, ~0);            glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);            glActiveStencilFaceEXT(GL_BACK);            glStencilFunc(GL_ALWAYS, 0, ~0);            glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);               }           glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);        }        shapes[s]->doShadowPass(lightPosObjSpace, needZFail);      }      else      {        if(needZFail){          glStencilOp(GL_KEEP, GL_INCR, GL_KEEP);          glCullFace(GL_FRONT);          shapes[s]->doShadowPass(lightPosObjSpace, needZFail);          glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);          glCullFace(GL_BACK);             shapes[s]->doShadowPass(lightPosObjSpace, needZFail);        }        else        {          glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);          glCullFace(GL_BACK);          shapes[s]->doShadowPass(lightPosObjSpace, needZFail);          glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);          glCullFace(GL_FRONT);            shapes[s]->doShadowPass(lightPosObjSpace, needZFail);        }      }    }...snip...

It's a part of my scenegraph that I intend to open source as soon as I can get someone to show me or build me a site to host tutorials. I already have the webspace.

This demo's source is located right here:
http://www.realityflux.com/abba/C++/GLScene.cpp

[Edited by - JavaCoolDude on August 22, 2004 12:24:23 AM]

##### Share on other sites

A log was left, but it was completely empty.

##### Share on other sites
Nvidia card, right?...
I'm visting a friend with an FX tonight and we'll be trying to sort it out (something with the glVertexPointer being called before the glTexCoordPointer...I think.

##### Share on other sites
Nah, the flickering is due to ATI cards, I tested it on a GeForce Fx 5200+ and it was flawless.
However, to have it work on a non-ati card I had to set the elephant group to be a non-occluder in the .ini file (0 instead of 1).
Have no clue why, however when switching to immidiate mode (glVertex4fv) instead of glDrawElements, things work out fine...
Grrrrrrrr

##### Share on other sites
The flickering you are talking about is this kind of z-fighting, right ?
I have an ATI, and i experience exactly the same thing, whenever i do this :

1. render scene
2. use vertex program for whatever reason
2. 2nd pass with the same scene

I allways have z-fighting, and the way i overcome this is with glPolygonOffset, however i assumed this to be my own problem.
This could indeed be a driver bug, but in that case, many games would have this problem on ati boards, and to my knowledge i haven't heard of a single one.

##### Share on other sites
Like I said I played around with the PolygonOffset setttings since the first thing that jumped into my mind was Z-fighting.
enabling polygon offset with various factor size and units fixed the thing partially but a lot of visual artifacts still occur in the scene.
This problem doesn't occur while running on an nvidia FX card.
Have you tried the demo yet?

##### Share on other sites
do u enable the invarance flag (or what ever its called) for the vertex program

##### Share on other sites
Quote:
 Original post by zedzeekdo u enable the invarance flag (or what ever its called) for the vertex program

I'm transforming the incoming vertex into an extruded one or leave it just as it is according to its w component.
Therefore since the outgoing vertex isn't simply clipped by the modelview projection, I can't use "OPTION ARB_position_invariant".

!!ARBvp1.0PARAM modelviewProjection[4] = { state.matrix.mvp };PARAM lightPosition          = program.env[0];PARAM one  = {1.0, 1.0, 1.0, 1.0};TEMP  multiplier, position, newLightPosition;MOV newLightPosition, lightPosition;SLT multiplier, vertex.position.w, one;MUL newLightPosition, newLightPosition, multiplier;MOV position        , vertex.position;SUB position        , position       , newLightPosition; DP4 result.position.x, modelviewProjection[0], position;DP4 result.position.y, modelviewProjection[1], position;DP4 result.position.z, modelviewProjection[2], position;DP4 result.position.w, modelviewProjection[3], position;END

I wrote that bit, pelase point me out to any flaw that you might notice in it.

##### Share on other sites
I'm getting in touch with some ATI folks and hopefully we'll work towards sorting out this problem :)