How to give the back buffer a depth buffer without using conf
Posted: Fri Feb 11, 2022 10:40 am
Is there a way to give the back buffer (default canvas) a depth buffer without using conf? I tried the following, but it doesn't work.
Context: Why do I want this behaviour? I want to have a setting to switch between post processing and not for my 3D game. The easy solution is to always have the back buffer have a depth buffer, but that feels wasteful as it isn't readable for post processing - requiring additional buffers for post processing as they won't be able to use the back buffer's depth buffer.
Another solution, if possible, is if there's an option to make the back buffer's depth buffer readable (if the system allows) - but I'm unaware of such an option.
Code: Select all
local lg = love.graphics
local w, g = lg.getPixelDimensions()
local depthcanvas = lg.newCanvas(w, h, {format="depth24", readable=true})
lg.setDepthMode("always", true)
love.draw = function()
lg.setCanvas({depthstencil=depthcanvas})
lg.setColor(1,1,1)
lg.rectangle("fill", 50,50,50,50)
--lg.setCanvas()
--lg.draw(depthcanvas) -- Only the depth buffer being drawn to and not the back buffer using the depth buffer
end
Another solution, if possible, is if there's an option to make the back buffer's depth buffer readable (if the system allows) - but I'm unaware of such an option.