diff options
| author | vimene <vincent.menegaux@gmail.com> | 2026-01-17 00:06:31 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2026-01-17 00:06:31 +0100 |
| commit | 0d10b77f77459333c5549711334f417623ab1f3e (patch) | |
| tree | 6584ab5d09fa72c93a70ac916bfdf401c7617157 /src/fb/chfb.cpp | |
| parent | 175c71637b6bea6dcdd0faf3d614339983809bb1 (diff) | |
| download | engine-0d10b77f77459333c5549711334f417623ab1f3e.tar.gz | |
improved software shaders
- unified terminal and graphical software renderer shaders
- added vertex shaders for software renderers
- removed VertexData
- moved shaders from frame buffers to their own class
- added FrameBufferConcept and ShadersConcept
Diffstat (limited to 'src/fb/chfb.cpp')
| -rw-r--r-- | src/fb/chfb.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/fb/chfb.cpp b/src/fb/chfb.cpp index 7341015..e7717eb 100644 --- a/src/fb/chfb.cpp +++ b/src/fb/chfb.cpp @@ -3,15 +3,10 @@ #include <cstdint> #include "math/vector.hpp" #include "math/quat.hpp" -#include "o3d/vertex_data.hpp" #include "o3d/camera.hpp" using namespace engine::fb; -using - engine::math::Vector2, - engine::math::Vector3, - engine::o3d::VertexData, - engine::o3d::Camera; +using engine::math::Vector4; CharacterFrameBuffer::CharacterFrameBuffer(unsigned int w, unsigned int h) { resize(w, h); @@ -30,11 +25,9 @@ void CharacterFrameBuffer::clear() { // taken from https://stackoverflow.com/a/74186686 char brightness_chars[] = " `.-':_,^=;><+!rc*/z?sLTv)J7(|Fi{C}fI31tlu[neoZ5Yxjya]2ESwqkP6h9d4VpOGbUAKXHm8RD#$Bg0MNWQ%&@"; -extern Camera* camera; -void CharacterFrameBuffer::draw_point(int x, int y, const Vector3& /* loc */, const Vector3& normal, const Vector2& /* uv */, const VertexData& /* vd */) { - auto v = camera->transform.rot.conjugate().rot(normal).normalize(); - float light = .1f + (v.z < 0.f ? 0.f : v.z) * .9f; +void CharacterFrameBuffer::draw_point(int x, int y, const Vector4& point) { + float light = .2126f * point.x + .7152f * point.y + .0722f * point.z; std::uint32_t c = (int) (light * static_cast<float>(sizeof(brightness_chars) - 1)); chars_vector[x + y * w] = brightness_chars[c]; } |
