2026-07-20 01:41:10 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include "../datatypes.cpp"
|
|
|
|
|
#include "../helpers.cpp"
|
|
|
|
|
#include "../buffer.cpp"
|
|
|
|
|
#include "shaderbase.cpp"
|
|
|
|
|
|
|
|
|
|
namespace UwU {
|
2026-07-20 14:31:28 -07:00
|
|
|
class VGradientShader : public ShaderBase<VGradientShader> {
|
2026-07-20 01:41:10 -07:00
|
|
|
public:
|
|
|
|
|
VGradientShader(uint16_t v0, uint16_t v1, Color c0, Color c1) {
|
2026-07-20 14:31:28 -07:00
|
|
|
this->v0 = (uint32_t)v0;
|
2026-07-20 01:41:10 -07:00
|
|
|
this->vScale = 0xffffffff / (1 + (uint32_t)v1 - (uint32_t)v0);
|
|
|
|
|
this->c0 = c0;
|
|
|
|
|
this->c1 = c1;
|
|
|
|
|
}
|
2026-07-20 14:31:28 -07:00
|
|
|
uint32_t v0;
|
|
|
|
|
uint32_t vScale;
|
2026-07-20 01:41:10 -07:00
|
|
|
Color c0;
|
|
|
|
|
Color c1;
|
|
|
|
|
|
2026-07-20 14:31:28 -07:00
|
|
|
Color shade(uint16_t u, uint16_t v) {
|
|
|
|
|
(void)u;
|
|
|
|
|
uint32_t t = (((uint32_t)v - v0) * vScale) / 0x01000000;
|
2026-07-20 01:41:10 -07:00
|
|
|
return Helpers::lerpColor(c0, c1, (uint8_t)t);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|