0

I've found examples online of how to perform diffusion lighting but I can't seem to find any regarding how things would change when using skeletal matrices.

Does anyone have an example I could look at?

I specifically used this page as an example to learn diffusion lighting: http://learningwebgl.com/blog/?p=684

genpfault
  • 51,148
  • 11
  • 85
  • 139
Xavier
  • 8,828
  • 13
  • 64
  • 98

1 Answers1

1

No matter what kind of transformation you apply to your vertices, the most important thing is to keep consistent; know in what space you are performing your transformations. Assuming object_matrix is the transformation of your object and camera_matrix the view transformation:

vec4 pos = VertexPosition;
// pos is in object space

pos = object_matrix * pos;
// pos is now in world space

pos = camera_matrix * pos;
// view space

Light coordinates are usually in world space, in which case:

pos = object_matrix * pos;
// perform diffuse lighting computations here
pos = camera_matrix * pos;

If by "skeletal matrices" you refer to skeletal animation, they're done in object space.

Hope this helps.

Yno
  • 786
  • 4
  • 9