summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-11-01 00:18:13 -0500
committersanine-a <sanine.not@pm.me>2020-11-01 00:18:13 -0500
commitcf75cc42cd11c31ff9402751bec98ba607fd820f (patch)
tree95267aac01e9fde9fff6b6362464f2e9b4ac0e92 /demo
parent42d42c9ba3b741d167eaa2196c686962559686f1 (diff)
fix depth map bug in demo
Diffstat (limited to 'demo')
-rw-r--r--demo/ScreenQuad.lua12
-rw-r--r--demo/main.lua6
2 files changed, 10 insertions, 8 deletions
diff --git a/demo/ScreenQuad.lua b/demo/ScreenQuad.lua
index 938674c..5d78cf3 100644
--- a/demo/ScreenQuad.lua
+++ b/demo/ScreenQuad.lua
@@ -28,19 +28,21 @@ out vec4 color;
void main()
{
- color = vec4(texture(tex, UV));
+ color = vec4(1 - texture(tex, UV).xyz, 1);
} ]]
ScreenQuad.shader = honey.shader.new(vertexShader, fragmentShader)
-ScreenQuad.texture = honey.texture.new()
-honey.texture.create(ScreenQuad.texture, 'rgba', 640, 480);
+ScreenQuad.tex = honey.texture.new()
+ScreenQuad.depth = honey.texture.new()
+honey.texture.create(ScreenQuad.tex, 'rgb', 640, 480);
+honey.texture.create(ScreenQuad.depth, 'depth', 640, 480);
--honey.texture.load(ScreenQuad.texture, 'checkerboard.png', false)
-ScreenQuad.fb = honey.texture.new_framebuffer(ScreenQuad.texture, nil, 640, 480)
+ScreenQuad.fb = honey.texture.new_framebuffer(ScreenQuad.tex, ScreenQuad.depth, 640, 480)
ScreenQuad.draw = function(self)
- honey.texture.use(self.texture, 0)
+ honey.texture.use(self.tex, 0)
honey.mesh.draw(self.quad, self.shader)
end
diff --git a/demo/main.lua b/demo/main.lua
index 5474609..ab3e8b3 100644
--- a/demo/main.lua
+++ b/demo/main.lua
@@ -92,13 +92,13 @@ function honey.draw()
if buffer then
honey.set_framebuffer(ScreenQuad.fb)
- honey.enable_depth_test(true)
honey.clear_color(Vector.Vec4.new().array, true, true, false)
+ honey.enable_depth_test(true)
draw_suzanne()
honey.set_framebuffer(0)
- honey.enable_depth_test(true)
- honey.clear_color(Vector.Vec4.new{0,0,1,1}.array, true, true, false)
+ honey.enable_depth_test(false)
+ honey.clear_color(Vector.Vec4.new{0,0,1,1}.array, true, false, false)
ScreenQuad:draw()
else
honey.clear_color(Vector.Vec4.new{1,1,0,1}.array, true, true, false)