package dof import rl "vendor:raylib" import "core:math/rand" import "core:fmt" import r3d "../r3d" X_INSTANCES :: 10 Y_INSTANCES :: 10 INSTANCE_COUNT :: X_INSTANCES * Y_INSTANCES main :: proc() { // Initialize window rl.InitWindow(800, 450, "[r3d] - DoF example") defer rl.CloseWindow() rl.SetTargetFPS(60) // Initialize R3D with FXAA r3d.Init(rl.GetScreenWidth(), rl.GetScreenHeight()) defer r3d.Close() r3d.SetAntiAliasing(.FXAA) // Configure depth of field and background env := r3d.GetEnvironment() env.background.color = rl.BLACK env.dof.mode = .ENABLED env.dof.focusPoint = 2.0 env.dof.focusScale = 3.0 env.dof.maxBlurSize = 20.0 // Create directional light light := r3d.CreateLight(.DIR) r3d.SetLightDirection(light, {0, -1, 0}) r3d.SetLightActive(light, true) // Create sphere mesh and default material meshSphere := r3d.GenMeshSphere(0.2, 64, 64) defer r3d.UnloadMesh(meshSphere) matDefault := r3d.GetDefaultMaterial() // Generate instance matrices and colors spacing: f32 = 0.5 offsetX := (X_INSTANCES * spacing) / 2.0 offsetZ := (Y_INSTANCES * spacing) / 2.0 idx := 0 instances := r3d.LoadInstanceBuffer(INSTANCE_COUNT, {.POSITION, .COLOR}) defer r3d.UnloadInstanceBuffer(instances) positions := cast([^]rl.Vector3)r3d.MapInstances(instances, {.POSITION}) colors := cast([^]rl.Color)r3d.MapInstances(instances, {.COLOR}) for x in 0..