Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: User Clip planes on Nvidia

  1. #1
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    User Clip planes on Nvidia

    I am using clip planes to do reflections and on my Nvidia card and if I specify 0, -1, 0, 0 for a reflection on Y axis my Nvidia card will not chop off whats above the plane? On my ATI card it works fine and I can get the ATI card to render the same image as the Nvidia card, but I can also get the ATI card to clip the image so it chops off the image at the plane??? So who's right? I am thinking user defined clip planes aren't working on Nvidias cards? Unless there is some special way I need to setup the clip plane for Nvidia vs. ATI? Thanks

  2. #2
    Member Regular Contributor Jackis's Avatar
    Join Date
    Sep 2005
    Location
    Saint-Petersburg, Russia
    Posts
    279

    Re: User Clip planes on Nvidia

    You may use oblique frustum clipping, which modifies near projection plane to be an extra cliplane. It works on nVidia and ATi both, cause it works everywhere ))
    Try googling on "oblique frustum clipping", there is a code sample from Eric Lengyel somewhere, I don't remember exactly. Do not forget to transfom clipplane in currently set modelview transformation space!

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    Re: User Clip planes on Nvidia

    Originally posted by Jackis:
    You may use oblique frustum clipping, which modifies near projection plane to be an extra cliplane. It works on nVidia and ATi both, cause it works everywhere ))
    Try googling on "oblique frustum clipping", there is a code sample from Eric Lengyel somewhere, I don't remember exactly. Do not forget to transfom clipplane in currently set modelview transformation space!
    I would rather use the OpenGL ones... Unless this is a known problem I will look into the ones Eric has come up with.

  4. #4
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,007

    Re: User Clip planes on Nvidia

    I highly recommend the Eric Lengyel clipplanes as metioned above:
    http://www.terathon.com/code/oblique.html

    for reflection plane mirrors as they are free. (OpenGL clipplanes can involve a speed expense)

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Roseville, CA
    Posts
    162

    Re: User Clip planes on Nvidia

    On Nvidia hardware, unless you're using the conventional transform path or a position-invariant vertex program, you need to explicitly calculate clip plane distances in yourself. You can use the NV_vertex_program2 option to output to result.clip[i]. The hardware interpolates these distances during rasterization and kills any fragments for which any one of them goes negative.

    ATI hardware works differently, and I believe they actually do a geometric clip. (Someone correct me if that's not true.)

    Either way, you do pay a small performance price by using OpenGL clip planes, and as you've noticed, there isn't one way that works well on hardware from both companies. The oblique view frustum only modifies the projection matrix, however, and is guaranteed to work on all hardware at absolutely no performance cost.

  6. #6
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    Re: User Clip planes on Nvidia

    Originally posted by Eric Lengyel:
    On Nvidia hardware, unless you're using the conventional transform path or a position-invariant vertex program, you need to explicitly calculate clip plane distances in yourself. You can use the NV_vertex_program2 option to output to result.clip[i]. The hardware interpolates these distances during rasterization and kills any fragments for which any one of them goes negative.

    ATI hardware works differently, and I believe they actually do a geometric clip. (Someone correct me if that's not true.)

    Either way, you do pay a small performance price by using OpenGL clip planes, and as you've noticed, there isn't one way that works well on hardware from both companies. The oblique view frustum only modifies the projection matrix, however, and is guaranteed to work on all hardware at absolutely no performance cost.
    Hi Eric. I am thinking about giving your code a try. I do have the GEM 5 book. My question is logical order to use your function...

    1.save current projection matrix?
    2.call your function with parameters I would have sent to glClipplane()
    3.do rendering
    4.reset projection matrix to saved one?
    5.repeat for my refraction code ect...

    Would this be correct? If I don't save the current projection I should lose my setup of gluPerspective right? Thanks for all the help and ideas...

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Roseville, CA
    Posts
    162

    Re: User Clip planes on Nvidia

    That sounds fine except for step 2. The glClipPlane() function transforms the plane by the inverse transpose of the model-view matrix to move it into eye space. My function assumes that this transformation has already been applied to the plane.

  8. #8
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    Re: User Clip planes on Nvidia

    Originally posted by Eric Lengyel:
    That sounds fine except for step 2. The glClipPlane() function transforms the plane by the inverse transpose of the model-view matrix to move it into eye space. My function assumes that this transformation has already been applied to the plane.
    So I would need another function to take my 0.0, -1.0, 0.0, 0.0 values and transform them by inverse of the model view matrix and then send those new 4 values into your function. If I am understanding you .

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Roseville, CA
    Posts
    162

    Re: User Clip planes on Nvidia

    Yes, just do whatever is necessary to put the plane in eye space, and then call my function.

  10. #10
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    Re: User Clip planes on Nvidia

    Originally posted by Eric Lengyel:
    Yes, just do whatever is necessary to put the plane in eye space, and then call my function.
    Ugh, I knew I was going to hit a wall with the math behind moving my plane into eye space. If I was doing it in GLSL I would call
    Code :
    gl_ModelViewProjectionMatrixInverseTranspose
    and multiply it by the plane values... But I don't have that available to me under FFP AFAKI?

Posting Permissions

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