pxl8/src/gfx/pxl8_shader.h

82 lines
1.5 KiB
C
Raw Normal View History

#pragma once
#include "pxl8_lights.h"
#include "pxl8_math.h"
#include "pxl8_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pxl8_vertex_in {
pxl8_vec3 a_position;
pxl8_vec3 a_normal;
pxl8_vec2 a_uv;
u8 a_color;
u8 a_light;
} pxl8_vertex_in;
typedef struct pxl8_vertex_out {
pxl8_vec4 gl_Position;
pxl8_vec2 v_uv;
pxl8_vec3 v_world;
pxl8_vec3 v_normal;
f32 v_light;
f32 v_depth;
} pxl8_vertex_out;
typedef struct pxl8_shader_uniforms {
u8 ambient;
bool baked_lighting;
pxl8_vec3 celestial_dir;
f32 celestial_intensity;
bool dither;
bool dynamic_lighting;
bool emissive;
u8 fog_color;
f32 fog_density;
const pxl8_light* lights;
u32 lights_count;
bool textures;
f32 time;
} pxl8_shader_uniforms;
typedef struct pxl8_shader_bindings {
const u8* colormap;
const u32* palette;
const u8* atlas;
u32 width, height;
bool use_tiled;
union {
struct {
u32 stride;
u32 x, y;
} linear;
struct {
u32 base;
u8 log2_w;
} tiled;
};
} pxl8_shader_bindings;
typedef struct pxl8_shader_ctx {
i32 x, y;
pxl8_vec2 v_uv;
pxl8_vec3 v_world;
pxl8_vec3 v_normal;
f32 v_color;
f32 v_light;
f32 v_depth;
u32 out_light_color;
} pxl8_shader_ctx;
typedef u8 (*pxl8_shader_fn)(
pxl8_shader_ctx* ctx,
const pxl8_shader_bindings* bindings,
const pxl8_shader_uniforms* uniforms
);
#ifdef __cplusplus
}
#endif