## Lighting Dynamics Demo

spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

### Re: Lighting Dynamics Demo

xXxMoNkEyMaNxXx wrote:Here, I made a pixel effect version completely from scratch:
spynazPE.love
I couldn't bear your insisting to index tables with strings, why not just use Lua? Instead of

Code: Select all

table["index"]
simply do

Code: Select all

table.index
Thanks bro!

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Lighting Dynamics Demo

Just wanted to point out that you can absolutely use shaders to get a pixely lighting. Just write your shader so that all pixels within a certain square size always get lit by the same amount. Or, perhaps even better, render everything in low-res with the shader (where every square is simply a pixel) and then scale it up.
Last edited by T-Bone on Wed May 08, 2013 10:52 am, edited 1 time in total.

timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

### Re: Lighting Dynamics Demo

T-Bone wrote:row-les
I don't even what is that.

Ontopic, this would also increase the speed dramatically - depending on the size of your squares, 2x2 squares would be a 4 times increase - compared to per-pixel.

spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

### Re: Lighting Dynamics Demo

How would I change the color of the light?

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Lighting Dynamics Demo

timmeh42 wrote:
T-Bone wrote:row-les
I don't even what is that.

Ontopic, this would also increase the speed dramatically - depending on the size of your squares, 2x2 squares would be a 4 times increase - compared to per-pixel.
Strange typo. Maybe I'm turning japanese?

spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

### Re: Lighting Dynamics Demo

How would I change the color of the light in the pixel effect one?

bramblez
Citizen
Posts: 50
Joined: Sun Jul 29, 2012 1:21 pm
Location: Russia, Moscow

### Re: Lighting Dynamics Demo

spynaz wrote:How would I change the color of the light in the pixel effect one?

Code: Select all

canvas:renderTo(function()

love.graphics.setColor(125, 125, 125, 125) -- color of light
...
end)
----
Ref wrote:Thanks!
Didn't appreciate the difference!
Docs say:
"os.clock() Return CPU time since Lua started in seconds."
Thought seconds were seconds - that CPU seconds were then same as Universal seconds.
Good catch!
Really appreciate input.
Edit:
Turns out on my computer that the os.clock() and os.time() happen to give the same elapsed time for this demo.
Demo actually is terminated by bee.buzz:isStopped( ) - when music is over.
hey, Ref. Can you explain me how to use dynamic lights from this .love to make it work for each bullet in this bullet lib?

Code: Select all

function bullets_load()

bulletspeed = 100
bullets = {
x = 0,
y = 0,
dx = 0,
dy = 0,
bullr = 2
}

end
function bullets_update(dt)

for i,v in ipairs(bullets) do
v.x = v.x + (v.dx * dt)
v.y = v.y + (v.dy * dt)
if checkCircularCollision(v.x,v.y,cx1,cy1,2,cr1) then
print("HIT!")
end
end

end
function bullets_draw()

love.graphics.setColor(0,0,0)

if shooting == 1 then
for i,v in ipairs(bullets) do
love.graphics.circle("fill",v.x,v.y,2)
end
end

end
function checkCircularCollision(ax, ay, bx, by, ar, br)

local dx = bx - ax
local dy = by - ay
local dist = math.sqrt(dx * dx + dy * dy)
return dist < ar + br

end
Attachments
white-snow.love
Last edited by bramblez on Thu Jun 13, 2013 6:26 pm, edited 1 time in total.

bohdan77
Prole
Posts: 1
Joined: Sat Jun 15, 2013 11:18 pm

### Re: Lighting Dynamics Demo

http://youtu.be/Gy9tvA9AlSg

raidho36
Party member
Posts: 1954
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Lighting Dynamics Demo

Yeah, it's pretty good. Once I did almost exactly the same thing with GameMaker, but due to it's exceptional performance my demo was nowhere close to what's seen on that video regardless vast efforts to keep it fastest possible. Oh well. I think I'd rewrote it for löve once I get used to it. Was considering switching long ago, but baby duckling syndrome is a powerful thing.

I assume it can be done easily with löve, since it only requires offscreen buffers and blending modes (and maybe graphical primitives):

0) render your scene lit white
1) for each light source perform the following
2) set target shadow render buffer, clear to black
3) render light source texture onto it
4) then for each shadow casting object
5) render shadow, particular algorighm depends on particular object type, obviously
7) after all light sources done, place composed shadow buffer onto scene with multiply blend mode.

And make sure you cull what's not visible, this is kinda tricky task. I'm not entirely sure how do I acheive this effect only using stencil buffers (probably just render-your-shadows-to-stencil -> render your light -> repeat over), so I just post how I did it.

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

2 words:

FUCKING COOL!

### Who is online

Users browsing this forum: Google [Bot] and 6 guests