diff options
Diffstat (limited to 'src/fb/pixfb.cpp')
| -rw-r--r-- | src/fb/pixfb.cpp | 12 |
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; } |
