Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Shadow

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Shadow

    Ok so here I go, amateur me goes to learn how to do shadows... Oh man, OpenGL won't do it for me... Ok so I go look for tutorials... Then we find the shadow matrix ... Now I got smart and just figured, if that is the standard for shadowing in OpenGL, I can just copy and paste =-).

    So here's my problem. I have a sphere and a plane. I have a working shadowMatrix command and want to now: what variables, arrays and stuff that needs to go in the display code to get my shadows visible on the plane. I got reflections down and this is the only thing that hinders me =-(..

  2. #2
    Intern Contributor
    Join Date
    Jul 2000
    Posts
    57

    Re: Shadow

    You'll only need the shadow matrix. Render your scene. Determine the plane to render the shades on. Set the projection matrix, render in your favorite shade color

    Divide Overflow

    "I'm fat, you're ugly, I can lose weight.."

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Shadow

    Yah, I got that general idea down but I need the code for it ........


    cwhite40

  4. #4
    Intern Newbie
    Join Date
    Aug 2000
    Posts
    46

    Re: Shadow

    There's a good description in the back of the red book. I think there's even some example code in the glut distribution somewhere.

  5. #5
    Junior Member Regular Contributor Roderic (Ingenu)'s Avatar
    Join Date
    Mar 2000
    Location
    Horsham, West Sussex, UK.
    Posts
    161

    Re: Shadow

    You should check nVidia web site, they have a projected shadow demo.

    They are other infos about that on this web site, in the tutorial section.
    -* So many things to do, so little time to spend. *-

  6. #6
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Shadow

    Ok this really is not working. The glut code and nVida code are not well explained. I have no idea what to do here . Does anyone have well explained shadow code. I have tried this so many times I think I'm going to turn into a shadow .

    cwhite40

  7. #7
    Intern Contributor
    Join Date
    Apr 2000
    Posts
    78

    Re: Shadow

    I took the code form Mark Kilgard from nVidia corporation...

    void ShadowMatrixf (float mat[16],
    float pA, float pB, float pC, float pD,
    float vX, float vY, float vZ, float vW)
    {
    float Dot = pA * vX +
    pB * vY +
    pC * vZ +
    pD * vW;
    mat[0] = Dot - vX * pA;
    mat[1] = -vY * pA;
    mat[2] = -vZ * pA;
    mat[3] = -vW * pA;
    mat[4] = -vX * pB;
    mat[5] = Dot - vY * pB;
    mat[6] = -vZ * pB;
    mat[7] = -vW * pB;
    mat[8] = -vX * pC;
    mat[9] = -vY * pC;
    mat[10] = Dot - vZ * pC;
    mat[11] = -vW * pC;
    mat[12] = -vX * pD;
    mat[13] = -vY * pD;
    mat[14] = -vZ * pD;
    mat[15] = Dot - vW * pD;
    }

    Use this matrix this way:

    float mat[16]; // This is the sahdow matrix

    ShadowMatrixf (mat,
    0.0, 1.0, 0.0, 0.0, // The plane
    0.0, 10.0, 0.0, 1.0 ); // The light position

    render some geometry...
    glPushMatrix ();
    glMultMatrixf (mat);
    render the same geometry...
    glPopMatrix ();

    I hope this will help...

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Shadow

    Cool!!

    One more question though, what is the plane parameters supposed to be: vertices, points, normals?

    Thank You
    cwhite40

  9. #9
    Intern Contributor
    Join Date
    Apr 2000
    Posts
    78

    Re: Shadow

    the a,b & c parameters represent the plane normal the d parameter represent the lenght of this vector.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •