Results 1 to 3 of 3

Thread: shadow volumes

  1. #1
    Member Newbie
    Join Date
    Mar 2003
    Location
    Austria
    Posts
    37

    shadow volumes

    im implementing shadow volumes. but the problem is the shadows dont appear.

    first i create the shadow volume which is stored in dList.

    Insel is my terrain on which the shadow should appear.

    then i use the following code snippet to render the scence.

    does anybody know what im making wrong?


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    Insel->configRendering();
    Insel->render();
    Insel->recoverContext();

    //glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
    //glDepthMask(GL_FALSE);

    glEnable(GL_STENCIL_TEST);
    //glDepthMask(GL_FALSE);
    glStencilFunc(GL_ALWAYS,0,0);

    glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
    glCullFace(GL_BACK);
    glCallList(dList);

    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);
    glCullFace(GL_FRONT);
    glCallList(dList);

    glDepthMask(GL_TRUE);
    glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
    //glCullFace(GL_BACK);
    glDepthFunc(GL_LESS);
    glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);

    //glStencilFunc(GL_EQUAL,1,1);
    glDisable(GL_LIGHTING);

    /*
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,0,Insel->terrainData);
    glDisable(GL_TEXTURE_2D);
    glColor3f(0.0f,0.0f,0.0f);
    for (int i=0;i<Insel->width-1;i++)
    {
    glDrawElements(GL_TRIANGLE_STRIP,Insel->width*2,GL_UNSIGNED_INT,Insel->indexes+i*Insel->width*2);
    }
    glDisableClientState(GL_VERTEX_ARRAY);
    Insel->configRendering();
    Insel->render();
    Insel->recoverContext();*/

    glStencilFunc(GL_EQUAL,0,1);

    Insel->configRendering();
    Insel->render();
    Insel->recoverContext();

    glDepthFunc(GL_LESS);
    glDisable(GL_STENCIL_TEST);

    i`m glad about every suggestion!

    Poons

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: shadow volumes

    You should disable depth and color writes when drawing the stencil volume (you have the right calls there but it's commented out). If you don't disable depth writes on the volume the second terrain pass and parts of your stencil volume rendering will fail the depth test. By definition all fragments inside the shadow volume would fail the depth test and no shadowing will occur.

    Apart from that it looks OK, but I just skimmed.

    [This message has been edited by dorbie (edited 05-08-2003).]

  3. #3
    Member Newbie
    Join Date
    Mar 2003
    Location
    Austria
    Posts
    37

    Re: shadow volumes

    i have commented it out to see if the shadow volume is correct. i have forgotten to comment it in but when i disable it, the shadow does not appear.

    thanks, for looking over the code.

    Poons

Similar Threads

  1. Replies: 1
    Last Post: 10-05-2014, 10:43 PM
  2. Shadow volumes
    By SiberianSTAR in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 08-17-2006, 05:11 PM
  3. Ohh yes... Shadow volumes again!
    By unreal in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-30-2004, 11:55 AM
  4. Shadow Volumes.
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-22-2002, 02:09 AM
  5. shadow maps vs shadow volumes
    By eigenafx in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-02-2001, 01:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean