implemented H and V GradientShaders

This commit is contained in:
2026-07-20 14:31:28 -07:00
parent 8a00e42f75
commit ee2c66f97b
11 changed files with 147 additions and 87 deletions
+7 -6
View File
@@ -8,21 +8,22 @@
#include "shaderbase.cpp"
namespace UwU {
class HGradienthader : public ShaderBase<HGradientShader> {
class HGradientShader : public ShaderBase<HGradientShader> {
public:
HGradientShader(uint16_t u0, uint16_t u1, Color c0, Color c1) {
this->u0;
this->u0 = (uint32_t)u0;
this->uScale = 0xffffffff / (1 + (uint32_t)u1 - (uint32_t)u0);
this->c0 = c0;
this->c1 = c1;
}
uint16_t u0;
uint16_t uScale;
uint32_t u0;
uint32_t uScale;
Color c0;
Color c1;
Color shade(uint16_t u, uint16_t u) {
uint32_t t = (((uint32_t)u - (uint32_t)u0) * uScale) / 0x01000000;
Color shade(uint16_t u, uint16_t v) {
(void)v;
uint32_t t = (((uint32_t)u - u0) * uScale) / 0x01000000;
return Helpers::lerpColor(c0, c1, (uint8_t)t);
}
};
+2 -2
View File
@@ -1,4 +1,4 @@
#include "shaderbase.cpp"
#include "colorshader.cpp"
// #include "hgradientshader.cpp"
// #include "vgradientshader.cpp"
#include "hgradientshader.cpp"
#include "vgradientshader.cpp"
+7 -6
View File
@@ -8,21 +8,22 @@
#include "shaderbase.cpp"
namespace UwU {
class VGradienthader : public ShaderBase<VGradientShader> {
class VGradientShader : public ShaderBase<VGradientShader> {
public:
VGradientShader(uint16_t v0, uint16_t v1, Color c0, Color c1) {
this->v0;
this->v0 = (uint32_t)v0;
this->vScale = 0xffffffff / (1 + (uint32_t)v1 - (uint32_t)v0);
this->c0 = c0;
this->c1 = c1;
}
uint16_t v0;
uint16_t vScale;
uint32_t v0;
uint32_t vScale;
Color c0;
Color c1;
Color shade(uint16_t u, uint16_t u) {
uint32_t t = (((uint32_t)v - (uint32_t)v0) * vScale) / 0x01000000;
Color shade(uint16_t u, uint16_t v) {
(void)u;
uint32_t t = (((uint32_t)v - v0) * vScale) / 0x01000000;
return Helpers::lerpColor(c0, c1, (uint8_t)t);
}
};