added shaders, but ran into performance issues. will need refactor

This commit is contained in:
2026-07-07 17:57:25 -07:00
parent ad2e84c279
commit 85cfdaab49
12 changed files with 139 additions and 78 deletions
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "shader.cpp"
namespace UwU {
class VGradientShader {
public:
VGradientShader(uint16_t y0, Color color0, uint16_t y1, Color color1) {
this->y0 = y0;
this->shaderColor0 = color0;
this->scale = 0xffffffff / (1 + (uint32_t)y1 - (uint32_t)y0);
this->shaderColor1 = color1;
}
uint16_t y0;
Color shaderColor0;
uint32_t scale;
Color shaderColor1;
Color color(uint16_t u, uint16_t v) {
(void)u;
uint32_t t = (((uint32_t)v - (uint32_t)y0) * scale) / 0x01000000;
// if (v == 42) {
// printf("(%u, %u)\n", u, t);
// }
return Helpers::lerpColor(shaderColor0, shaderColor1, (uint8_t)t);
}
};
}