a couple questions about ‘the best way’
at the moment for supplying (*)data to the shaders with uniforms but with a lot of it eg lightposition, material shininess etc there
already exists stuff that mirrors this in opengl eg gl_LightSource[…], now im tempted to use these cause they feel like a ‘cleaner’
solution BUT will i get bitten by doing this. eg say i add to my fragment shader
vec3 lightpos = gl_LightSource[0].position.xyz;
then on my gffx the fasm cg printout ballons from 3kb upto 18kb due to the addition of
…
…
#var float gl_LightSource[7].spotCosCutoff : : (<null atom>.x, <null atom>.y, <null atom>.z, <null atom>.w) : -1 : 0
#var float gl_LightSource[7].constantAttenuation : : (<null atom>.x, <null atom>.y, <null atom>.z, <null atom>.w) : -1 : 0
#var float gl_LightSource[7].linearAttenuation : : (<null atom>.x, <null atom>.y, <null atom>.z, <null atom>.w) : -1 : 0
#var float gl_LightSource[7].quadraticAttenuation : : (<null atom>.x, <null atom>.y, <null atom>.z, <null atom>.w) : -1 : 0
DECLARE gl_ModelViewMatrixInverse$0;
DECLARE gl_ModelViewMatrixInverse$1;
DECLARE gl_ModelViewMatrixInverse$2;
DECLARE gl_ModelViewMatrixInverse$3;
DECLARE gl_LightSource$0$ambient;
DECLARE gl_LightSource$0$diffuse;
DECLARE gl_LightSource$0$specular;
DECLARE gl_LightSource$0$position;
…
…
though the instruction count is the same in both.
(*)not per vertex data of course
also a related question about optimal camera position
is there anything wrong in getting the viewers position from doing
vec3 camera_pos = vec3( gl_ModelViewMatrixInverse[3].xyz );
ie. is this the quickest way of using the camera position in my calculation shaders, or am i better off passing the camera’s position
as a uniform to the shader?