Skip to content

Instantly share code, notes, and snippets.

@bjornbytes
bjornbytes / oldvectors.lua
Created October 22, 2025 07:24
Implements old pre v0.19.0 LÖVR vectors with Lua tables
vec2, vec3, vec4, quat = {}, {}, {}, {}
Vec2, Vec3, Vec4, Quat = vec2, vec3, vec4, quat
lovr.math.vec2, lovr.math.vec3, lovr.math.vec4, lovr.math.quat = vec2, vec3, vec4, quat
lovr.math.newVec2, lovr.math.newVec3, lovr.math.newVec4, lovr.math.newQuat = vec2, vec3, vec4, quat
local function isvec2(t) return type(t) == 'table' end
local function isvec3(t) return type(t) == 'table' end
local function isvec4(t) return type(t) == 'table' end
local function isquat(t) return type(t) == 'table' end
local function ismat4(m) return type(m) == 'userdata' and m:type() == 'Mat4' end
@bjornbytes
bjornbytes / main.lua
Last active November 5, 2023 18:27
Supersampled Font Shader
fontShader = lovr.graphics.newShader('unlit', [[
Constants {
uint supersample;
};
// Standard sample locations from Vulkan spec
const vec2 samples16[16] = vec2[16](
vec2(.0625, .0625),
vec2(-.0625, -.1875),
vec2(-.1875, .125),
@bjornbytes
bjornbytes / renderdoc.lua
Created October 3, 2023 20:15
LuaJIT FFI bindings for RenderDoc, created to allow VR applications running in SteamVR to be captured properly/programmatically
--[[
local renderdoc = require 'renderdoc'
function lovr.draw(pass)
pass:cube(0, 1.7, -1, .5, lovr.timer.getTime())
if renderdoc.available and lovr.headset.wasPressed('right', 'trigger') then
renderdoc.api.StartFrameCapture(nil, nil)
lovr.graphics.submit(pass)
renderdoc.api.EndFrameCapture(nil, nil)
@bjornbytes
bjornbytes / stereo-mirror.lua
Last active May 2, 2023 00:57
Stereo Mirror Window
local mirror = {}
function mirror:init()
self.head = lovr.math.newMat4()
self.views = 2
self.width = lovr.system.getWindowWidth() * .5
self.height = lovr.system.getWindowHeight()
self.ipd = .063
self.fovy = .6
self.fovx = self.fovy * (self.width / self.height)