major gfx refactor
This commit is contained in:
parent
0c0aa792c1
commit
3c3e961995
58 changed files with 3681 additions and 2982 deletions
31
src/gfx/shaders/cpu/unlit.c
Normal file
31
src/gfx/shaders/cpu/unlit.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "pxl8_shader.h"
|
||||
#include "pxl8_shader_builtins.h"
|
||||
|
||||
u8 pxl8_shader_unlit(
|
||||
pxl8_shader_ctx* ctx,
|
||||
const pxl8_shader_bindings* bindings,
|
||||
const pxl8_shader_uniforms* uniforms
|
||||
) {
|
||||
u8 tex_idx = 0;
|
||||
if (bindings && bindings->atlas) {
|
||||
tex_idx = pxl8_sample_indexed(bindings, ctx->v_uv);
|
||||
if (tex_idx == 0) return 0;
|
||||
} else {
|
||||
if (uniforms && uniforms->dither) {
|
||||
tex_idx = pxl8_gfx_dither(ctx->v_color, (u32)ctx->x, (u32)ctx->y);
|
||||
} else {
|
||||
f32 clamped = pxl8_clamp(ctx->v_color, 0.0f, 255.0f);
|
||||
tex_idx = (u8)(clamped);
|
||||
}
|
||||
}
|
||||
|
||||
if (uniforms && uniforms->emissive) {
|
||||
u32 rgb = 0x00FFFFFF;
|
||||
if (bindings && bindings->palette) {
|
||||
rgb = bindings->palette[tex_idx] & 0x00FFFFFF;
|
||||
}
|
||||
pxl8_set_light_tint(ctx, rgb, 1.0f);
|
||||
}
|
||||
|
||||
return tex_idx;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue