Distorting image to form shadow on wall [fake perspective.]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Ohsin
Prole
Posts: 4
Joined: Sat Sep 22, 2012 12:38 pm

Distorting image to form shadow on wall [fake perspective.]

Post by Ohsin »

Hello love2d
This is my first post and in this I want to share and seek some information.I got introduced to love2d through game 'Journey to the center of Hawkthorne (fan made game based on community TV show) and I wanted to create an effect of shadow on wall for fun :ultraglee: after some head banging i came up with this solution.

Divide screen into zones(canvas) like Floor ,Ceiling and Wall.For each zone Draw shadow image separately but for 'Ceiling' and 'Floor' skew image according to perspective and for 'Wall' keep it as it is.

My very first love file so code may be ugly ,I have very basic knowledge of Lua . :ehem:

ScreenShot :
xshVA.png
xshVA.png (24.38 KiB) Viewed 355 times
Please tell if it can be done some other way.Thank you!
Attachments
faux perspective.love
Shadow/Splatter Test by Ohsin
(5.68 KiB) Downloaded 131 times
jonyzz
Prole
Posts: 48
Joined: Sun Sep 02, 2012 9:35 pm

Re: Distorting image to form shadow on wall [fake perspectiv

Post by jonyzz »

Just an idea: Use love.graphics.setScissor to limit drawing area (floor/ceiling/wall) instead of using canvas.
Ohsin
Prole
Posts: 4
Joined: Sat Sep 22, 2012 12:38 pm

Re: Distorting image to form shadow on wall [fake perspectiv

Post by Ohsin »

How can I use 'scissors' method to create more than one independently drawable area on screen? It seems it can only define an ractangular area to draw on but that's it.I also tried using Quads but i don't know if i can skew them like images. :(
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Distorting image to form shadow on wall [fake perspectiv

Post by Nixola »

You can use a scissor to define an area and draw into it, then use a new scissor to define a new area and draw into it and a last scissor to define a third area to draw into ^^
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Ohsin
Prole
Posts: 4
Joined: Sat Sep 22, 2012 12:38 pm

Re: Distorting image to form shadow on wall [fake perspectiv

Post by Ohsin »

Nixola wrote:You can use a scissor to define an area and draw into it, then use a new scissor to define a new area and draw into it and a last scissor to define a third area to draw into ^^
That is exactly what I want ! But if i setScissors then draw then setScissors and draw again.The very first draw area gives weird results.Like in following example ball draws fine in second area but in first it starts to 'paint' the area.

Code: Select all

function love.update()
	mx = love.mouse.getX()
	my = love.mouse.getY()
end

function love.draw()
love.graphics.setScissor( 0, 0,200,200 )
love.graphics.setColor(255,0,0)
love.graphics.circle("fill", mx, my,50,25)
	
love.graphics.setScissor( 0, 200,200,200 )
love.graphics.setColor(0,255,0)
love.graphics.circle("fill", mx, my,50,25)
end
too new so sorry for if it is silly .
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Distorting image to form shadow on wall [fake perspectiv

Post by Boolsheet »

You have to disable the scissor or love.graphics.clear (called just before love.draw) will only clear that part of the screen. Just call love.graphics.setScissor without arguments to do that:

Code: Select all

love.graphics.setScissor()
Shallow indentations.
Ohsin
Prole
Posts: 4
Joined: Sat Sep 22, 2012 12:38 pm

Re: Distorting image to form shadow on wall [fake perspectiv

Post by Ohsin »

That did it! Thank you very much. :D I should have used it just like setCanvas ...silly me :P
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 14 guests