Shtille's blog A development blog

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

Physical based rendering shader

Physical based rendering has become a common lighting model for decent engines like Unreal Engine 4, Unity, etc. I’ve found several implementations on the web. And made a simple application based on Shtille Engine framework which allows to test its visual appearance. The PBR material should be UE4-like (consist of 4 textures: albedo map, normal ... Read more