suicmez/game/inc/suic_lighting.h

44 lines
1.4 KiB
C
Raw Normal View History

#pragma once
#include "suic_math.h"
#include <stdint.h>
/**
* Lighting system API.
* Supports directional lighting, shadows, ambient occlusion, and Phong shading.
*/
typedef struct SuicColor {
uint8_t r, g, b, a;
} SuicColor;
typedef struct SuicDirectionalLight {
SuicVec3 direction;
SuicVec3 color;
float intensity;
float ambientIntensity;
float shadowBias;
float shadowIntensity;
} SuicDirectionalLight;
/* Light creation */
SuicDirectionalLight suic_light_create(float dir_x, float dir_y, float dir_z,
float intensity, float ambient);
SuicDirectionalLight suic_light_create_default(void);
/* Basic lighting */
SuicColor suic_light_apply(SuicColor base, SuicVec3 normal, SuicDirectionalLight* light);
/* Lighting with shadows */
SuicColor suic_light_apply_shadows(SuicColor base, SuicVec3 normal, SuicVec3 worldPos,
SuicDirectionalLight* light);
/* Phong lighting (with specular) */
SuicColor suic_light_apply_phong(SuicColor base, SuicVec3 normal, SuicVec3 worldPos,
SuicVec3 camPos, SuicDirectionalLight* light);
/* Shadow calculations */
float suic_shadow_factor(SuicVec3 worldPos, SuicVec3 lightDir, float maxDist);
float suic_shadow_temporal(SuicVec3 worldPos, float timePhase);
/* Ambient occlusion */
float suic_ao_calculate(SuicVec3 worldPos, SuicVec3 normal);