> For the complete documentation index, see [llms.txt](https://kakara.gitbook.io/engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kakara.gitbook.io/engine/render-system/extensible-render-pipeline/lighting-shader-format.md).

# Lighting Shader Format

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()](https://ci.kingtux.dev/job/Kakara%20Engine%202/job/master/javadoc/org/kakara/engine/render/Graphics.html#renderLights\(org.kakara.engine.scene.Scene,org.kakara.engine.Camera,org.kakara.engine.lighting.LightHandler,org.kakara.engine.render.Shader\)) method.

## Vertex

For the vertex format it is required to have the modelLightView matrix. See the [standard](/engine/render-system/extensible-render-pipeline/standard-shader-format.md) and the[ voxel](/engine/render-system/extensible-render-pipeline/chunk-shader-format.md#vertex) 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.**

## Fragment

The following structs are needed by the lighting system:

```c
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:

```c
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;
```
