Shtille's blog A development blog

Custom spinlock vs pthread one speed comparison

#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

Making Decals (OpenGL Programming)

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

Box normal calculation

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

Program to test intersections

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

Logotype model creation

In the far 2007 year I developed an appearance of my own logotype. Now I gonna completely discribe it and make a model in 3DS Max program. Since I don’t have any vector graphics drawing software I gonna use the same program for 2D vector graphics. I defined logotype as two hemitoruses with a torus inside. Let’s start with two circle arcs. \[... Read more