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 6 of 6

Thread: Projective texture weirdness

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    662

    Projective texture weirdness

    Hi guys,

    When do projective texturing, I get light on and close to the projection near plane.

    Here is a picture of the problem http://members.rogers.com/deseric/problem.jpg

    Here is a picture of the light and it's frustum touching the object http://members.rogers.com/deseric/projectlight.jpg

    Here is the projection texture I use : http://members.rogers.com/deseric/light.jpg


    Here is the code I use to setup the projection :

    Code :
         glActiveTextureARB(GL_TEXTURE0_ARB);
                 glClientActiveTextureARB(GL_TEXTURE0_ARB);
                 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
                 glEnable(GL_TEXTURE_2D);
     
                 glEnable(GL_TEXTURE_GEN_S);
                 glEnable(GL_TEXTURE_GEN_T);
                 glEnable(GL_TEXTURE_GEN_R);
                 glEnable(GL_TEXTURE_GEN_Q);
     
                 GLfloat splane[4] = {1,0,0,0};
                 GLfloat tplane[4] = {0,1,0,0};
                 GLfloat rplane[4] = {0,0,1,0};
                 GLfloat qplane[4] = {0,0,0,1};
     
                 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
                 glTexGenfv(GL_S, GL_OBJECT_PLANE, splane );
                 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
                 glTexGenfv(GL_T, GL_OBJECT_PLANE, tplane );
                 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
                 glTexGenfv(GL_R, GL_OBJECT_PLANE, rplane );
                 glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
                 glTexGenfv(GL_Q, GL_OBJECT_PLANE, qplane );
     
                 glMatrixMode(GL_TEXTURE);
                 glLoadIdentity();
     
     
     
                 //scale and bias to bring texcoord in [-1,1] to [0,1]
                 glTranslatef(0.5f, 0.5f, 0.0f);
              	 glScalef(0.5f, 0.5f, 1.0f);
     
    const GraphicTools::ViewVolume& theVolume = light.GetViewVolume();
     
                 glFrustum( theVolume.Left, theVolume.Right, theVolume.Bottom, theVolume.Top, theVolume.Near, theVolume.Far );
     
                 MultMatrix( light.GetFrame().GetWorldToFrame() );
                 MultMatrix( objectSpaceToWorldSpace );
    The light origin does not coincide with the light frustum which has it's near set to 3. I have tried moving back the near very close to 0, but nothing changed.

    This gives me trouble because when I remove the back projection, I need to fudge the the bias to a bit less 0.5 to remove the band. But when I do that, if I am very close to an object and some of it's vertices are behind the far plane ,I get a sharp cut in the middle of the light projection . This is because I use a 1d texture with one side black and one side white and use NEAREST has my filtering mode. So obviously some of the fugded texcoords fall in the black even they should be in the white.


    Anyone ever got that or have any clue why it is doing so?

    EDIT : fixed a link


    EDIT : BTW, the projection is correct when all the points are in front(or behind) the projector plane


    [This message has been edited by Gorg (edited 02-14-2003).]

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    662

    Re: Projective texture weirdness

    Ok. I found how to fix it but I don't understand why.

    The band only appears when use a mipmaping filtering mode, I have been trying to picture what happens but I don't see how the band appears.

    Anybody has a reason?

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Projective texture weirdness

    i couldnt actually see any problem in the screenshot.
    perhaps use GL_NEAREST

    edit - oh i see u do



    [This message has been edited by zed (edited 02-15-2003).]

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    662

    Re: Projective texture weirdness

    Zed, the problem is the band in the middle. Maybe I should have described the first picture a bit better.

    The 2 half-elipses on each side are the projection and the back projection. The band in the middle should not be there, but I found it only appears with filtering mode of type GL_*_MIPMAP_*.

    So I fixed my problem, but I still don't understand why it was a problem in the first place

    [This message has been edited by Gorg (edited 02-15-2003).]

  5. #5
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Projective texture weirdness

    ok i see,
    try using GL_REPEAT u it should give u an idea of whats happening
    well u need to do is for each mipmap level create a border around the image + use clamp_to_edge.

    glubuildmipmaps wont cut the ice

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    662

    Re: Projective texture weirdness

    Oh I see now what was happenning! Thanks Zed.

Posting Permissions

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