added shaders, but ran into performance issues. will need refactor
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class ColorShader : public Shader {
|
||||
class ColorShader {
|
||||
public:
|
||||
ColorShader(Color color) {
|
||||
this->shaderColor = color;
|
||||
@@ -16,7 +16,7 @@ namespace UwU {
|
||||
|
||||
Color shaderColor;
|
||||
|
||||
Color color(uint16_t u, uint16_t v) override {
|
||||
Color color(uint16_t u, uint16_t v) {
|
||||
(void)u;
|
||||
(void)v;
|
||||
return shaderColor;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class GradientShader : public Shader {
|
||||
public:
|
||||
GradientShader(Color color0, Color color1) {
|
||||
// this->x0 = x0;
|
||||
this->shaderColor0 = color0;
|
||||
// this->x1 = x1;
|
||||
this->shaderColor1 = color1;
|
||||
}
|
||||
// uint16_t x0;
|
||||
Color shaderColor0;
|
||||
// uint16_t x1;
|
||||
Color shaderColor1;
|
||||
|
||||
Color color(uint16_t u, uint16_t v) override {
|
||||
(void)v;
|
||||
return Helpers::lerpColor(shaderColor0, shaderColor1, u);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class HGradientShader{
|
||||
public:
|
||||
HGradientShader(uint16_t x0, Color color0, uint16_t x1, Color color1) {
|
||||
this->x0 = x0;
|
||||
this->shaderColor0 = color0;
|
||||
this->scale = 0xffffffff / (1 + (uint32_t)x1 - (uint32_t)x0);
|
||||
this->shaderColor1 = color1;
|
||||
}
|
||||
uint16_t x0;
|
||||
Color shaderColor0;
|
||||
uint32_t scale;
|
||||
Color shaderColor1;
|
||||
|
||||
Color color(uint16_t u, uint16_t v) {
|
||||
(void)v;
|
||||
uint32_t t = (((uint32_t)u - (uint32_t)x0) * scale) / 0x01000000;
|
||||
// if (v == 42) {
|
||||
// printf("(%u, %u)\n", u, t);
|
||||
// }
|
||||
return Helpers::lerpColor(shaderColor0, shaderColor1, (uint8_t)t);
|
||||
}
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ namespace UwU {
|
||||
public:
|
||||
Shader() {}
|
||||
|
||||
virtual Color color(uint16_t u, uint16_t v) {
|
||||
Color color(uint16_t u, uint16_t v) {
|
||||
(void)u;
|
||||
(void)v;
|
||||
return Color();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user