Done buffer save/load tests for these libraries, and results are following: JPEG test took 0.017918 seconds PNG test took 0.088861 seconds So libjpeg is 5.5 times faster than libpng. Read more 11 Feb 2022 - less than 1 minute read
#include <cstdlib> #include <cstdio> #include <thread> #include <string> #include <chrono> #include <atomic> #include <pthread.h> class ScopeTimer { typedef std::chrono::high_resolution_clock clock; typedef std::chrono::duration<float> seconds; public: ScopeTimer(const char* message) : messag... Read more 10 Feb 2022 - 1 minute read
Suppose you’re drawing a complex three-dimensional picture using depth-buffering to eliminate the hidden surfaces. Suppose further that one part of your picture is composed of coplanar figures A and B, where figure B is a sort of decal that should always appear on top of figure A. Your first approach might be to draw figure B after you’ve drawn ... Read more 11 Sep 2018 - 2 minute read
In ray tracing we need to calculate box normal from ray intersection. Here’s the solution. vec3 BoxNormal(const Box box, const vec3 point) { vec3 center = (box.max + box.min) * 0.5; vec3 size = (box.max - box.min) * 0.5; vec3 pc = point - center; // step(edge,x) : x < edge ? 0 : 1 vec3 normal = vec3(0.0); normal += vec3(sign(pc.x), 0.0... Read more 10 Mar 2018 - less than 1 minute read
Made a program to test intersections: #include <iostream> #include <string> #include <cmath> struct vec3 { vec3(float x) : x(x), y(x), z(x) {} vec3(float x, float y, float z) : x(x), y(y), z(z) {} vec3 operator +(const vec3& v) const { return vec3(x + v.x, y + v.y, z + v.z); } vec3 operator -(const vec3&am... Read more 09 Mar 2018 - 2 minute read