Graphics Programs Reference
In-Depth Information
_tankNormalMatrix[5] = _tankMVPMatrix[6]; // from 2nd
column, ending at [7]
_tankNormalMatrix[6] = _tankMVPMatrix[8];
_tankNormalMatrix[7] = _tankMVPMatrix[9];
_tankNormalMatrix[8] = _tankMVPMatrix[10]; // from 3rd
column, ending at [11]
System.arraycopy(_tankMVPMatrix, 0, _tankMVMatrix, 0,
16);
Matrix.multiplyMM(_tankMVPMatrix, 0,
_ProjectionMatrix, 0, _tankMVPMatrix, 0);
▪ Next, to obtain the S vector for the current vertex, take its differ-
ence with the light source position.
▪ For this, store the light source position in a global variable,
inside the vertex shader ( Listing 5-16 ). This variable is usu-
ally declared as a constant variable, by using the const
keyword:
const
vec4
lightPositionWorld
=
vec4(10.0, 10.0, 0.0, 1.0);
▪ As we are dealing with a point light source, we just need a
single vertex to represent it, irrespective of the shape of the
light source. If you have modeled this light source object in
Blender, you can obtain its center by reading the global me-
dian value from the properties shelf , as shown in Figure 5-9 .
 
 
Search WWH ::




Custom Search