Game Development Reference
In-Depth Information
Object
Grid Points
Force
Force
Force
Force
Mass1 * Mass2
R 2
Force = G
Figure 5-27. The gravity grid
Next, I'll discuss what code is in the actual gravity grid vertex shader. The modelviewprojection
matrix is held in uMVPMatrix .
uniform mat4 uMVPMatrix;
The grid vertex locations are sent from the main program to the aPosition variable.
attribute vec3 aPosition;
The code in Listing 5-33 creates shader variables that deal with the following:
1.
The number of masses currently on the grid
2.
The maximum number of masses on the grid
3.
The mass values of all the objects on the grid
4.
The locations of all the objects on the grid
5.
The radius of the grid spotlight under the object
6.
The spotlight color related to the object that is displayed on the grid
Listing 5-33. Grid Object Information
uniform int NumberMasses;
const int MAX_MASSES = 30;
uniform float MassValues[MAX_MASSES];
uniform vec3 MassLocations[MAX_MASSES];
uniform float MassEffectiveRadius[MAX_MASSES];
uniform vec3 SpotLightColor[MAX_MASSES];
The color of the vertex that is input to the shader is held in vColor .
uniform vec3 vColor;
 
Search WWH ::




Custom Search