Lighting Dynamics Demo

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

Re: Lighting Dynamics Demo

Post by spynaz »

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
:D Thanks bro!
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Lighting Dynamics Demo

Post by T-Bone »

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.
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: Lighting Dynamics Demo

Post by timmeh42 »

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.
User avatar
spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

Re: Lighting Dynamics Demo

Post by spynaz »

How would I change the color of the light?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Lighting Dynamics Demo

Post by T-Bone »

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? :neko:
User avatar
spynaz
Party member
Posts: 152
Joined: Thu Feb 28, 2013 5:49 am

Re: Lighting Dynamics Demo

Post by spynaz »

How would I change the color of the light in the pixel effect one?
User avatar
bramblez
Citizen
Posts: 50
Joined: Sun Jul 29, 2012 1:21 pm
Location: Russia, Moscow

Re: Lighting Dynamics Demo

Post by bramblez »

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
(45.03 KiB) Downloaded 245 times
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

Post by bohdan77 »

Someone made this video.
http://youtu.be/Gy9tvA9AlSg
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Lighting Dynamics Demo

Post by raidho36 »

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. :P

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
6) after that, merge (with addition blend mode) shadow render buffer to shadow accumulator buffer
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: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Lighting Dynamics Demo

Post by jjmafiae »

2 words:

FUCKING COOL!
Post Reply

Who is online

Users browsing this forum: No registered users and 69 guests