This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- require this file to have reduced input lag and game logic that runs consistently | |
-- inspired by https://gafferongames.com/post/fix_your_timestep/ | |
-- note: this decouples update() from draw(); update() can run multiple times per frame | |
local m = {} | |
m.update_delta = 1 / 60 | |
function lovr.run() | |
if lovr.timer then lovr.timer.step() end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://cargocollective.com/sagejenson/physarum | |
-- also [Coding Adventure: Ant and Slime Simulations](https://www.youtube.com/watch?v=X-iSQQgOd1A) | |
-- "agents" move around and leave behind a trail | |
-- they also detect others' trail and steer towards it | |
local m = {} | |
local agent_count = 1e4 | |
local iterations_per_frame = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Measures input lag of an application that draws a blue circle on the last known cursor location | |
# automates cursor motion for consistency; takes a screenshot and measures distance; averages over N runs | |
CURSOR_COLOR="#7c7c7c" # set this to your system cursor primary color | |
CIRCLE_COLOR="#0000ff" # the measured app should draw a circle of this color | |
TESTS_N=50 | |
get_window_info() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cam = require'cam' -- https://github.com/jmiskovic/lovr-cam | |
local player_pos = Vec3() | |
local player_vel = Vec3(0, 0, -0.01) | |
local function getWorldFromScreen(pass) | |
local w, h = pass:getDimensions() | |
local clip_from_screen = mat4(-1, -1, 0):scale(2 / w, 2 / h, 1) | |
local view_pose = mat4(pass:getViewPose(1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- directional light shadow mapping for lovr 0.18 (currenly on post 0.17.1 dev branch) | |
local m = {} | |
m.near = 0.01 | |
m.far = 500 | |
m.orthographic_span = 40 | |
m.perspective_fov = 90 | |
m.view_pose = lovr.math.newMat4() | |
:lookAt( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- manages "stages" with a stack interface | |
-- stage is Lua module with callbacks (load, update, draw, keypress...) | |
-- only single stage is active, one on top of the stack | |
-- after push and pop operation another stage takes over the callbacks | |
-- example stack: os > main_menu > level_selection > game_play > overlay_menu | |
-- example usage: | |
-- local stagestack = require'stagestack' | |
-- stagestack.push(require'main_menu') | |
local m = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creates a few hundred colliders which can be dragged around with right mouse button | |
-- Uses phywire.lua from https://github.com/jmiskovic/lovr-phywire | |
local phywire = require'phywire' | |
local world = lovr.physics.newWorld(0,0,0, false) | |
world:setLinearDamping(0.1) | |
world:setAngularDamping(0.1) | |
local mouse_collider = world:newSphereCollider(0,0,0, 0.001) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ Point light shaddow mapping (VSM Fixed) | |
-- usage snippets | |
local point_light = require('point_light') | |
point_light.load(1024, vec3(0, 1, 0)) -- depth texture resolution & light position | |
-- in lovr.update(dt), or at start of lovr.draw(pass) | |
local pass = point_light.getPass() | |
-- ... draw the scene using this pass ... | |
lovr.graphics.submit(pass) | |
-- if using within draw(), submit it together with main pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- LOVR demo: Creates a few hundred colliders and allows to drag them around using the right mouse button | |
-- Dependencies: | |
-- lovr-mouse.lua from https://github.com/bjornbytes/lovr-mouse/ | |
-- mousearm.lua from https://github.com/jmiskovic/lovr-mousearm | |
-- phywire.lua from https://github.com/jmiskovic/lovr-phywire | |
local mousearm = require'mousearm' | |
local phywire = require'phywire' | |
local world = lovr.physics.newWorld(0,0,0, false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), |
NewerOlder