if i modify groverburger's simplest 3d example to render the spinning cube to a special canvas:
Code: Select all
local lg = love.graphics
canvas_settings = {
["type"] = "2d",
["format"] = "depth32f",
["readable"] = true,
["msaa"] = 0,
["dpiscale"] = lg.getDPIScale(),
["mipmaps"] = "none",
}
temp_canvas = lg.newCanvas(
lg.getPixelWidth(),
lg.getPixelHeight()
)
depth_canvas = lg.newCanvas(
lg.getPixelWidth(),
lg.getPixelHeight(),
canvas_settings
)
Code: Select all
function love.draw()
love.graphics.clear()
-- draw the mesh using the shader to the canvas pair
lg.setCanvas({temp_canvas, nil, ["depthstencil"]=depth_canvas, ["depth"]=true}}) -- <<<
lg.clear()
lg.setDepthMode("lequal", true)
Shader:send("modelMatrix", GetTransformationMatrix({0,0,4}, {Timer,Timer,Timer}, {1,1,1}))
lg.setShader(Shader)
lg.draw(Mesh)
-- set canvas back to the default
lg.setCanvas()
lg.setShader()
lg.setDepthMode()
if love.keyboard.isDown("space") then
--shader2:send("depthmap",depth_canvas)
--lg.setShader(shader2)
lg.draw(depth_canvas)
--lg.setShader()
else
lg.draw(temp_canvas)
end
end
source of demo: https://github.com/groverburger/simplest_3d
edit: solved, see below