diff options
| author | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
| commit | db41d43345ea73cf7c1bbb29448e52ffb822e3e0 (patch) | |
| tree | 4635d654e301b3f31f8d2626f3bc2c6f2a6e50a8 /src/fb/pixfb.cpp | |
| parent | 7f08187a46e30925e4563585fab2c6f92400330a (diff) | |
| download | engine-db41d43345ea73cf7c1bbb29448e52ffb822e3e0.tar.gz | |
added textures for the hardware renderer
- removed "using" directive in .hpp
- reverse order of arguments for quaternion rotation, i.e. q.rot(v)
instead of v.rot(q), where q is a quaterinon and v a vector
- pass the inverse of the view matrix to render_and_present_frame, to
allow light calculation in shaders (we used to just pass the matrix of
the quaternion of the transformation, i.e. discard scaling and
translations)
- added another mesh and texture (viking_room) for testing purposes
- added transparent background option
- added Quaternion::look_towards(), which is the equivalent of
Matrix4::look_at() but only for rotations
- various improvement to .obj parsing
- load texture coordinates from .obj file
- merged duplicate vertices in Mesh::linearize_indices()
Diffstat (limited to 'src/fb/pixfb.cpp')
| -rw-r--r-- | src/fb/pixfb.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/fb/pixfb.cpp b/src/fb/pixfb.cpp index b38ec30..c629adb 100644 --- a/src/fb/pixfb.cpp +++ b/src/fb/pixfb.cpp @@ -8,6 +8,7 @@ using namespace engine::fb; using + engine::math::Vector2, engine::math::Vector3, engine::o3d::VertexData, engine::o3d::Camera; @@ -29,17 +30,15 @@ void PixelFrameBuffer::clear() { extern Camera* camera; -void PixelFrameBuffer::draw_point(int x, int y, const Vector3& loc, const VertexData& vd, const Vector3& normal) { - (void) loc; - (void) vd; +void PixelFrameBuffer::draw_point(int x, int y, const Vector3& /* loc */, const Vector3& normal, const Vector2& /* uv */, const VertexData& vd) { auto u = vd.world_loc - camera->transform.loc; float u_len_sq = u.length_squared(); u = u.normalize(); - float attenuation = Vector3(0.f, 0.f, -1.f).rot(camera->transform.rot).dot(u); + float attenuation = camera->transform.rot.rot({ 0.f, 0.f, -1.f }).dot(u); if (attenuation < .7f) attenuation = 0.f; else if (attenuation > .8f) attenuation = 1.f; else attenuation = (attenuation - .7f) / .1f; - float light = -normal.dot(u) / u_len_sq; + float light = -normal.normalize().dot(u) / u_len_sq; if (light < 0.f) light = 0.f; float final_light = .003f + light * attenuation * .8f * .997f; if (final_light > 1.f) final_light = 1.f; |
