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

Thread: object-space location of the camera

  1. #1
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Kiev, Ukraine
    Posts
    130

    object-space location of the camera

    Normaly it is possible to do by multiplying ModelViewInverse by [0,0,0,1].

    But how to obtain object-space location of camera in GLSL shader(i.e. without sending MVI from application code)?
    Andrey Yaromenok

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    Santa Clara
    Posts
    5

    Re: object-space location of the camera

    Originally posted by ayaromenok:
    Normaly it is possible to do by multiplying ModelViewInverse by [0,0,0,1].

    But how to obtain object-space location of camera in GLSL shader(i.e. without sending MVI from application code)?
    you can do the multiplication in your c/c++ code, and send the result as a uniform.

    Pierre B.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Kiev, Ukraine
    Posts
    130

    Re: object-space location of the camera

    you can do the multiplication in your c/c++ code, and send the result as a uniform.
    Thanks, but I was asking about solution without sending MVI from app.
    Something like state.matrix.modelview.inverse from ARB_vp.
    Andrey Yaromenok

  4. #4
    Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    293

    Re: object-space location of the camera

    Join the club

    Especially this issue is a main point of critic to me, a clear step backwards from the ARB extensions.

    nVidia extended 'their' glslang with the inverse matrices, a very good extension in my opinion.

    /me hope for a revised spec of glslang, with a lot more, like:

    1) #include -> for some stuff like the following to extract from every shader into another file (point 2)
    #ifndef ARB_some_fancy_extension
    ... do stuff like typedef float half;
    #endif

    2) file support
    3) inverse and transpose versions of the matrices (or everything in the state as in the ARB extensions)

    p.s. another thing is, that operations like inverse(gl_ModelViewMatrix); should be for free (because gl_ModelViewMatrix is a uniform Variable.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Cologne, Germany
    Posts
    27

    Re: object-space location of the camera

    Originally posted by Chris Lux:
    Join the club

    Especially this issue is a main point of critic to me, a clear step backwards from the ARB extensions.

    nVidia extended 'their' glslang with the inverse matrices, a very good extension in my opinion.

    /me hope for a revised spec of glslang, with a lot more, like:

    1) #include -> for some stuff like the following to extract from every shader into another file (point 2)
    #ifndef ARB_some_fancy_extension
    ... do stuff like typedef float half;
    #endif

    2) file support
    3) inverse and transpose versions of the matrices (or everything in the state as in the ARB extensions)

    p.s. another thing is, that operations like inverse(gl_ModelViewMatrix); should be for free (because gl_ModelViewMatrix is a uniform Variable.
    In general, yes (so please not another flamewar about good and bad of the glsl-spec), just some notes:

    1) you can already accomplish this by simply passing the glShaderSourceARB several strings

    2) what do you mean with that? the problem is, that the gl might be running on a server, while your client has the files...

    3) there's noone stopping the compiler-writers to do exactly what you said in your p.s., I don't know if they already do, though.

    Jan

  6. #6
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Kiev, Ukraine
    Posts
    130

    Re: object-space location of the camera

    nVidia extended 'their' glslang with the inverse matrices, a very good extension in my opinion.
    For me is clear how to use Cg data types in nVidia GLSL inmplementation, but how to do this with Matrices?
    Andrey Yaromenok

  7. #7
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Kiev, Ukraine
    Posts
    130

    Re: object-space location of the camera

    Ok, I find, how to use Cg state and it is a sutable solution right now(anyway I use NV hardware). Thanks to all.

    But in general, it is really not clear situation with inverse/trasform in GLSL.
    Andrey Yaromenok

Posting Permissions

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