Skip to content

Instantly share code, notes, and snippets.

@jmiskovic
jmiskovic / lightprobe_skybox.lua
Last active May 20, 2025 14:26
A testbed for light probe generation from a dynamically rendered skybox
local shh = require'shh' -- grab from https://github.com/bjornbytes/shh
-- a newer version of skybox might be available https://github.com/jmiskovic/lovr-atmo
local skybox = {}
skybox.__index = skybox
local cubemap_transforms = {
Mat4():lookAt(vec3(0, 0, 0), vec3( 1, 0, 0), vec3(0, 1, 0)),
Mat4():lookAt(vec3(0, 0, 0), vec3(-1, 0, 0), vec3(0, 1, 0)),
Mat4():lookAt(vec3(0, 0, 0), vec3( 0, 1, 0), vec3(0, 0,-1)),
@jmiskovic
jmiskovic / glitch-hands.lua
Created January 7, 2023 17:18
Reaction-diffusion model with hands erasing the growth (for lovr framework)
local resolution = 1024
local group_size = 16
local tex1 = lovr.graphics.newTexture(resolution, resolution, {mipmaps = false, usage = {'render', 'sample', 'storage', 'transfer'}, linear = true})
local tex2 = lovr.graphics.newTexture(resolution, resolution, {mipmaps = false, usage = {'render', 'sample', 'storage', 'transfer'}, linear = true})
local tex = lovr.graphics.newTexture(resolution, resolution, {mipmaps = false, usage = {'render', 'sample', 'storage', 'transfer'}, linear = true})
local projection = lovr.math.newMat4():perspective(math.rad(110), 1, .1, 0)
local palette = {0xded4c8, 0xbeaa9c, 0x94837a, 0x645c59, 0x181e28, 0xdbaf88, 0xb8926f, 0x987052, 0x624a30, 0x2f2114, 0xdf8b79, 0xe26560, 0xb0454c, 0x5b3636, 0xe5be3e, 0xbe8e03, 0x916803, 0x644507, 0xf18b49, 0xd46b2b, 0xba5113, 0x7a3412, 0xeb8281, 0xd95b5b, 0xbf2f37, 0x64272c, 0xb58fb6, 0x7e638e, 0x594a66, 0x3c3145, 0x30bab3, 0x1390ac, 0x0b5472, 0x233552, 0xabcf5f, 0x789949, 0x39681d, 0x084739}
@jmiskovic
jmiskovic / directional_shadow.lua
Created December 21, 2022 16:55
directional shadow mapping in lovr
local light_pose = lovr.math.newMat4()
local light_view = lovr.math.newMat4()
local light_projection = lovr.math.newMat4():perspective(math.rad(120), 1, 0.01)
--light_projection:orthographic(-5, 5, -5, 5, 100, -100) -- why is near and far inverted? ¯\_(ツ)_/¯
local depthBufferSize = 1024
local depthtex = lovr.graphics.newTexture(depthBufferSize, depthBufferSize, {format = 'd32f', mipmaps = false, usage = {'render', 'sample'}})
local shadowmapper = lovr.graphics.newShader(
[[