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)?
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
you can do the multiplication in your c/c++ code, and send the result as a uniform.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)?
Pierre B.
Thanks, but I was asking about solution without sending MVI from app.you can do the multiplication in your c/c++ code, and send the result as a uniform.
Something like state.matrix.modelview.inverse from ARB_vp.
Andrey Yaromenok
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: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.
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
For me is clear how to use Cg data types in nVidia GLSL inmplementation, but how to do this with Matrices?nVidia extended 'their' glslang with the inverse matrices, a very good extension in my opinion.
Andrey Yaromenok
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