PDA

View Full Version : object-space location of the camera



azazello
04-21-2004, 06:01 AM
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)?

Pierre B.
04-21-2004, 02:28 PM
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.

azazello
04-21-2004, 08:59 PM
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.

Chris Lux
04-21-2004, 11:30 PM
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.

jeickmann
04-22-2004, 12:17 AM
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

azazello
04-22-2004, 01:23 AM
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?

azazello
04-22-2004, 02:49 AM
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.