aboutsummaryrefslogtreecommitdiff
path: root/src/fb
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2025-12-31 18:34:54 +0100
committervimene <vincent.menegaux@gmail.com>2025-12-31 18:34:54 +0100
commitf9c6bd77af826423fba4aeec86b227ccd7102b4e (patch)
treeea54539034d4494df761d8fea3901acbf5803588 /src/fb
parent8ab4780f134c33a9e11ac0fe0bd866e17d3ee650 (diff)
downloadengine-vulkan.tar.gz
added back the software renderervulkan
Diffstat (limited to 'src/fb')
-rw-r--r--src/fb/pixfb.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/fb/pixfb.cpp b/src/fb/pixfb.cpp
index 55c356f..b38ec30 100644
--- a/src/fb/pixfb.cpp
+++ b/src/fb/pixfb.cpp
@@ -24,7 +24,7 @@ void PixelFrameBuffer::resize(unsigned int w, unsigned int h) {
}
void PixelFrameBuffer::clear() {
- std::fill(pixels_vector.begin(), pixels_vector.end(), 0x000000FF);
+ std::fill(pixels_vector.begin(), pixels_vector.end(), 0xff000000);
}
extern Camera* camera;
@@ -41,8 +41,14 @@ void PixelFrameBuffer::draw_point(int x, int y, const Vector3& loc, const Vertex
else attenuation = (attenuation - .7f) / .1f;
float light = -normal.dot(u) / u_len_sq;
if (light < 0.f) light = 0.f;
- float final_light = .05f + light * attenuation * .8f * .95f;
+ float final_light = .003f + light * attenuation * .8f * .997f;
if (final_light > 1.f) final_light = 1.f;
+ // gamma correction
+ // TODO: improve, we shouldn't do it here
+ if (final_light <= .0031308f)
+ final_light = final_light * 12.92f;
+ else
+ final_light = 1.055f * pow(final_light, 1.f / 2.4f) - .055f;
std::uint32_t c = (int) (final_light * 255.f);
- pixels_vector[x + y * w] = c << 24 | c << 16 | c << 8 | 0xff;
+ pixels_vector[x + y * w] = 0xff000000 | c << 16 | c << 8 | c;
}