Initial commit, stymied by LÖVR bugs
[lovr-particles] / main.lua
1 local mat4 = lovr.math.mat4
2
3 local features
4 local shaders = {}
5 local blocks = {}
6 local meshes = {}
7
8 function lovr.load()
9 features = lovr.graphics.getFeatures()
10 shaders.particles = lovr.graphics.newShader("shaders/particles.vert", "shaders/particles.frag")
11 blocks.particles = lovr.graphics.newShaderBlock("compute", {
12 particlePos = {"vec4", 1024},
13 }, { readable = true, writable = true })
14 shaders.particles:sendBlock('particleData', blocks.particles)
15 meshes.particle = lovr.graphics.newMesh(
16 {
17 {'vertPosition', 'float', 2},
18 },
19 {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}},
20 "triangles", "static"
21 )
22 meshes.particle:setVertexMap({3, 2, 1, 4, 3, 1})
23 end
24
25 function lovr.draw()
26 lovr.graphics.clear()
27 lovr.graphics.setColor(0, 0.5, 1)
28 local x, y, z = lovr.headset.getPose("head")
29 shaders.particles:send("headPos", {x, y, z})
30
31 blocks.particles:send("particlePos", {{0, 2, -2, 0}, {-1, 1, -4, 0}})
32 lovr.graphics.setShader(shaders.particles)
33 meshes.particle:draw(mat4(), 2)
34 end