📓
engine
  • Kakara Engine
  • Debugging
  • Getting Started
    • Getting the Engine
    • A New Game
    • Game Items
    • Components
    • Textures
    • Model Loading
    • The Camera
    • Player Input
      • Practical use of the Input
    • Lighting
    • User Interface
  • Scene System
    • Scene System
  • Render System
    • Extensible Render Pipeline
      • Standard Shader Format
      • Voxel Shader Format
      • Particle Shader Format
      • Lighting Shader Format
      • Custom Pipelines
  • Java Documentation
Powered by GitBook
On this page
  • Vertex
  • Fragment

Was this helpful?

  1. Render System
  2. Extensible Render Pipeline

Lighting Shader Format

PreviousParticle Shader FormatNextCustom Pipelines

Last updated 4 years ago

Was this helpful?

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 method.

Vertex

For the vertex format it is required to have the modelLightView matrix. See the and the 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:

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;
Graphics#renderLights()
standard
voxel