matiasah / shadows

Shädows - A Shadows & Lights engine for löve
MIT License
169 stars 9 forks source link

How to ignore lighting? #32

Closed evanpaul closed 4 years ago

evanpaul commented 4 years ago

I'm still learning this library, so apologies if this is obvious. I am rendering a number of lights/stars, but I want to have a UI layer that is not affected by lighting. What's the easiest way to do this? I've tried playing around with canvases but I can't seem to get it to work

matiasah commented 4 years ago

How are you drawing everything to the screen? (your love.draw function)

evanpaul commented 4 years ago
function love.draw()
    camera:draw(function(l,t,w,h)
        map:draw()
        draw_objects()

        draw_ui()
        light_world:Draw()
        -- putting draw_ui() here makes the UI invisible
    end)
end

I am using gamera for camera rendering, which could be affecting things? Unsure.

flamendless commented 4 years ago

@evanpaul22 for UI, you could put that outside of the camera draw.

something like:

camera:draw(function(l,t,w,h)
        map:draw()
        draw_objects()

        light_world:Draw()
    end)

love.graphics.setCanvas(ui_canvas)
draw_ui()
love.graphics.setCanvas()

love.graphics.draw(ui_canvas)
matiasah commented 4 years ago

Could also possibly be the blend modes or translation, the light world uses it's own translation which gets changed every time it draws it's canvas. You could try setting those properties right before drawing the user interface.

Check out what I'm using on this method https://github.com/matiasah/shadows/blob/cc84387fb15cc7451f7d736a88c08f68b6372435/LightWorld.lua#L146

Please tell me what your results are.

evanpaul commented 4 years ago

@flamendless That worked! @matiasah I think you're right. Another solution that worked here was putting a call to love.graphics.reset() after the LightWorld:Draw() and before drawing UI.

Thanks to both of you for the support!