summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-12-18 20:20:26 -0600
committersanine-a <sanine.not@pm.me>2020-12-18 20:20:26 -0600
commit91b914bc0eb97a76f2c3a1caa64fdfde29ca16a1 (patch)
treebf038b561eb80461c4b902ff350b813e4b48699d /demo
parent1b7a7a0d83353c9d4e67387d864011b1556330eb (diff)
add draw filtering and alpha to SpatialShader output
Diffstat (limited to 'demo')
-rw-r--r--demo/Node.lua7
-rw-r--r--demo/SpatialShader.lua2
-rw-r--r--demo/main.lua8
3 files changed, 9 insertions, 8 deletions
diff --git a/demo/Node.lua b/demo/Node.lua
index 7bd1ad5..6177fc5 100644
--- a/demo/Node.lua
+++ b/demo/Node.lua
@@ -32,14 +32,15 @@ Node.prototype.updateCascade = function(self, dt)
end
end
-Node.prototype.drawCascade = function(self, camera, shader)
- if self.draw then
+Node.prototype.drawCascade = function(self, camera, shader, filter)
+ filter = filter or function(node) return true end
+ if self.draw and filter(self) then
self:draw(camera, shader)
end
-- do not draw base nodes, but recursively draw children.
for _, child in ipairs(self.children) do
- child:drawCascade(camera, shader)
+ child:drawCascade(camera, shader, filter)
end
end
diff --git a/demo/SpatialShader.lua b/demo/SpatialShader.lua
index b15859f..68760ef 100644
--- a/demo/SpatialShader.lua
+++ b/demo/SpatialShader.lua
@@ -34,7 +34,7 @@ out vec4 color;
void main()
{
- color = vec4(texture(albedo, UV).xyz, 1);
+ color = texture(albedo, UV);
} ]]
local SpatialShader = {}
diff --git a/demo/main.lua b/demo/main.lua
index f60c345..f28510c 100644
--- a/demo/main.lua
+++ b/demo/main.lua
@@ -19,14 +19,15 @@ end)
local tex = honey.texture.load('lowres.png',
{minFilter='nearest', magFilter='nearest'})
-local cairo = honey.cairo()
+local cairo = honey.cairo({minFilter='nearest', magFilter='nearest'})
cairo:setColor(1, 1, 1)
cairo:moveTo(1024,0)
cairo:lineTo(0,1024)
cairo:stroke()
-cairo:setLineWidth(20);
-cairo:arc(512, 512, 256);
+cairo:setLineWidth(20)
+cairo:setColor(0,0,0)
+cairo:arc(512, 512, 256)
cairo:stroke()
cairo:updateTexture()
@@ -82,7 +83,6 @@ function honey.update(dt)
sceneRoot:updateCascade(dt)
if total_time > 1 then
print('FPS: '..tostring(total_frames/total_time))
- print(cairo)
total_time = 0
total_frames = 0
end