-
Notifications
You must be signed in to change notification settings - Fork 0
Lighting Format
Ryandw11 edited this page Jan 16, 2021
·
1 revision
The lighting format is a separate set of uniforms used to handle the lighting system. Implementing the lighting format in your shader allows you to use the Graphics#renderLights() method.
For the vertex format it is required to have the modelLightView matrix. See the standard and the chunk for the uniform names (and a layout).
Note: That uniform is not set by the Graphics#renderLights() method and is only needed if not using a custom format.
The following structs are needed by the lighting system:
struct Attenuation
{
float constant;
float linear;
float exponent;
};
struct PointLight
{
vec3 color;
vec3 position;
float intensity;
Attenuation att;
};
struct SpotLight
{
PointLight pl;
vec3 conedir;
float cutoff;
};
struct DirectionalLight
{
vec3 color;
vec3 direction;
float intensity;
};
struct Fog
{
int activeFog;
vec3 color;
float density;
};
Then the following uniforms are required:
const int MAX_POINT_LIGHTS = 5;
const int MAX_SPOT_LIGHTS = 5;
uniform vec3 ambientLight;
uniform float specularPower;
uniform PointLight pointLights[MAX_POINT_LIGHTS];
uniform SpotLight spotLights[MAX_SPOT_LIGHTS];
uniform DirectionalLight directionalLight;
uniform sampler2D shadowMap;
uniform Fog fog;