STATUS:
READY (CLICK EXECUTE)
SAMPLES:
0
SCENE DEFINITION (GLSL)
STOP
EXECUTE
// --- RENDER ENGINE MODE --- // 0 = Pure Ray Tracing (Sharp, instant, zero noise) // 1 = Path Tracing (Photorealistic, soft global illumination) #define RENDER_MODE 1 // --- ADJUSTABLE HINGE CONFIGURATION --- // Change this value (in degrees) to swing open the door dynamically! const float DOOR_ROTATION = 45.0; // --- MATERIAL CODES --- #define MAT_DIFFUSE 0 #define MAT_METAL 1 #define MAT_GLASS 2 // --- the envoirment --- #define USE_CUSTOM_SKYBOX 1 const vec3 SKYBOX_COLOR = vec3(0.02, 0.03, 0.06); // --- COLOR PALETTE PRESETS --- const vec3 C_GOLD = vec3(1.00, 0.78, 0.34); const vec3 C_CHROME = vec3(0.95, 0.95, 0.95); const vec3 C_GLASS = vec3(0.98, 1.00, 0.99); const vec3 C_WOOD = vec3(0.42, 0.26, 0.15); const vec3 C_WALL = vec3(0.85, 0.85, 0.82); // --- PREFAB GEOMETRY FUNCTIONS!!!!!!!! --- float sdSphere(vec3 p, vec3 center, float r) { return length(p - center) - r; } float sdBox(vec3 p, vec3 center, vec3 b) { vec3 q = abs(p - center) - b; return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); } // Rotation helper function for the door hinge vec3 rotateY(vec3 p, vec3 pivot, float angleDegrees) { float rad = radians(angleDegrees); float c = cos(rad); float s = sin(rad); vec3 local = p - pivot; return vec3(local.x * c - local.z * s, local.y, local.x * s + local.z * c) + pivot; } // --- Architectural Chamber Scene Graph --- void mapScene(vec3 p, inout float minDist, inout Material hitMat) { // PREFAB 1: Architectural Matte Floor float dFloor = p.y - (-1.0); if(dFloor < minDist) { minDist = dFloor; float chk = mod(floor(p.x * 2.0) + floor(p.z * 2.0), 2.0); vec3 col = mix(vec3(0.15), vec3(0.75), chk); hitMat = Material(vec3(0.0), col, 0.35, MAT_DIFFUSE, 1.0); } // PREFAB 2: Back Accent Wall with Structural Archway Hole float dWall = sdBox(p, vec3(0.0, 1.5, 4.5), vec3(3.0, 2.5, 0.1)); float dDoorCutout = sdBox(p, vec3(-0.8, 0.2, 4.5), vec3(0.6, 1.2, 0.5)); float dWallWithArch = max(dWall, -dDoorCutout); // Construct hole subtraction if(dWallWithArch < minDist) { minDist = dWallWithArch; hitMat = Material(vec3(0.0), C_WALL, 0.5, MAT_DIFFUSE, 1.0); } // PREFAB 3: HINGED DOOR (Rotates smoothly around its left edge coordinate) vec3 hingePivot = vec3(-1.4, 0.2, 4.5); vec3 rotatedDoorPos = rotateY(p, hingePivot, -DOOR_ROTATION); float dDoor = sdBox(rotatedDoorPos, vec3(-0.8, 0.2, 4.5), vec3(0.58, 1.15, 0.04)); if(dDoor < minDist) { minDist = dDoor; hitMat = Material(vec3(0.0), C_WOOD, 0.45, MAT_DIFFUSE, 1.0); } // PREFAB 4: Metallic Hinge Knob float dKnob = sdSphere(rotatedDoorPos, vec3(-0.35, 0.2, 4.56), 0.05); if(dKnob < minDist) { minDist = dKnob; hitMat = Material(vec3(0.0), C_GOLD, 0.05, MAT_METAL, 1.0); } // PREFAB 5: Polished Chrome Foreground Art Piece float dArt = sdSphere(p, vec3(1.1, -0.4, 3.0), 0.6); if(dArt < minDist) { minDist = dArt; hitMat = Material(vec3(0.0), C_CHROME, 0.01, MAT_METAL, 1.0); } // PREFAB 6: Decorative Heavy Crystal Glass Sphere float dGlass = sdSphere(p, vec3(0.0, -0.6, 2.2), 0.4); if(dGlass < minDist) { minDist = dGlass; hitMat = Material(vec3(0.0), C_GLASS, 0.0, MAT_GLASS, 1.6); } // PREFAB 7: Studio Ceiling Softbox float dLight = sdBox(p, vec3(0.0, 4.5, 3.0), vec3(2.0, 0.1, 2.0)); if(dLight < minDist) { minDist = dLight; hitMat = Material(vec3(14.0, 11.5, 9.0), vec3(0.0), 1.0, MAT_DIFFUSE, 1.0); } }