From cf75cc42cd11c31ff9402751bec98ba607fd820f Mon Sep 17 00:00:00 2001 From: sanine-a Date: Sun, 1 Nov 2020 00:18:13 -0500 Subject: fix depth map bug in demo --- demo/ScreenQuad.lua | 12 +++++++----- demo/main.lua | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'demo') 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) -- cgit v1.2.1