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 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( | |
| [[ |
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 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} |
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)), |
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
| --[[ 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
| -- 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
| -- 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
| -- 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
| 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
| #!/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() { |
OlderNewer