Shadows draw functions too costy?
Posted: 08 Dec 2006, 08:33
This one should go to mailinglist,but unfortunately gna kept eating my mails and others',so I have to start a topic there:
I looked through the piedraw.c file today,it seems that the pieDrawShadows function uses 2 glLoadIdentity(),2 glMultiMaxtrix,2 inverse_matrix functions per a model/shape just to get the light source of a pie?
This is how it works if I understand correctly:
PieDrawShape2:
1.Retrieves modelview matrix from glGetFloatv(GL_MODELVIEW_MATRIX, glFloat *store) then stored it in property 'matrix' of a static array of 'shadowcasting_shape_t'.
PieDrawShadows:
2.Get lightsource via function 'glGetLightfv(GL_LIGHT0, GL_POSITION, pos_lgt0)'and loops through the 'shadowcasting_shape_t' array and loadIdentity then multiply/inverse every matrix value in that array just to get the 'offset x,y,z' to light source 'pos_lgt0',and finally pass the light source vector to PieDrawShadow.
PieDrawShadow:
3.appends the 'light source offsets' to x,y,z when drawing shapes.
In my opinion the light source 'offsets' should be fixed values,or at least all models/shapes should use the same offset values rather than doing such enormous amounts of matrix multiply/inverse,even if we want dynamic shadows based on game day time.
Please correct me if I am wrong,I am not even sure if I understand these openGL function properly,because my openGL is still in a 'non-exist' state.
I looked through the piedraw.c file today,it seems that the pieDrawShadows function uses 2 glLoadIdentity(),2 glMultiMaxtrix,2 inverse_matrix functions per a model/shape just to get the light source of a pie?
This is how it works if I understand correctly:
PieDrawShape2:
1.Retrieves modelview matrix from glGetFloatv(GL_MODELVIEW_MATRIX, glFloat *store) then stored it in property 'matrix' of a static array of 'shadowcasting_shape_t'.
PieDrawShadows:
2.Get lightsource via function 'glGetLightfv(GL_LIGHT0, GL_POSITION, pos_lgt0)'and loops through the 'shadowcasting_shape_t' array and loadIdentity then multiply/inverse every matrix value in that array just to get the 'offset x,y,z' to light source 'pos_lgt0',and finally pass the light source vector to PieDrawShadow.
PieDrawShadow:
3.appends the 'light source offsets' to x,y,z when drawing shapes.
In my opinion the light source 'offsets' should be fixed values,or at least all models/shapes should use the same offset values rather than doing such enormous amounts of matrix multiply/inverse,even if we want dynamic shadows based on game day time.
Please correct me if I am wrong,I am not even sure if I understand these openGL function properly,because my openGL is still in a 'non-exist' state.