What's everyone working on? (tigsource inspired)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: What's everyone working on? (tigsource inspired)

Post by Whatthefuck »

Hooray for multithreaded colored lighting!

Image
Image
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by s-ol »

Whatthefuck wrote:Hooray for multithreaded colored lighting!
What exactly do the seperate threads do?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: What's everyone working on? (tigsource inspired)

Post by Whatthefuck »

S0lll0s wrote:
Whatthefuck wrote:Hooray for multithreaded colored lighting!
What exactly do the seperate threads do?
It computes the lighting on a separate thread, obviously.

Basically the way it works is the main thread sends a request for light computation and then goes on to draw other stuff. Once it's done drawing other stuff, it waits until the other thread is finished, finishes the lighting up and renders it.

This way if the rendering process of other stuff takes longer than the light computation, there is virtually no framerate impact from the light compute, since by the time it's done rendering other stuff, it'll just finalize the lighting (without waiting) and render it.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by s-ol »

Whatthefuck wrote:
S0lll0s wrote:
Whatthefuck wrote:Hooray for multithreaded colored lighting!
What exactly do the seperate threads do?
It computes the lighting on a separate thread, obviously.

Basically the way it works is the main thread sends a request for light computation and then goes on to draw other stuff. Once it's done drawing other stuff, it waits until the other thread is finished, finishes the lighting up and renders it.

This way if the rendering process of other stuff takes longer than the light computation, there is virtually no framerate impact from the light compute, since by the time it's done rendering other stuff, it'll just finalize the lighting (without waiting) and render it.
And how do you serialize the world/map across threads? The "flat" table limitation still keeps me from doing multi-threading.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: What's everyone working on? (tigsource inspired)

Post by Whatthefuck »

S0lll0s wrote:And how do you serialize the world/map across threads? The "flat" table limitation still keeps me from doing multi-threading.
I write the lighting which I want computed into a ImageData object, since it's userdata, it's shared between threads, and no duplicates are required. So upon initialization I send a reference of the LightData object to a separate thread, read it's size and set up various variables accordingly.

For the actual lighting compute - I write the color of the light to the RGB channels, and then other data into the alpha channel, for example whether the current pixel is a light source, whether light can pass through the current pixel, etc, which the lighting computation thread interprets as necessary and begins it's work from there.

Finally, on the main thread I call :demand on the channel and once the channel sends the confirmation that it's done (a simple bool), it calls :refresh on the Image object that's created from the same old ImageData, finalizes the lighting using a shader and finally draws it on the screen.

Couple that with the FFI ImageData implementation that one of the devs has made and you get crazy fast multithreaded lighting compute.

I've actually had the lighting compute this way for several months now, I simply implemented colored lighting recently. (~2 weeks ago)
Last edited by Whatthefuck on Tue Mar 31, 2015 9:09 pm, edited 4 times in total.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by s-ol »

Thanks for the insight - I suppose by LightData you mean ImageData for a light image? I can't find anything called LightData.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: What's everyone working on? (tigsource inspired)

Post by Whatthefuck »

S0lll0s wrote:Thanks for the insight - I suppose by LightData you mean ImageData for a light image? I can't find anything called LightData.
Yeah, whoops, typo, meant ImageData.

Also, just to give you an idea of how fast it is, on a 1080p monitor, an i5 4670 + R9 290 and a 25x25 pixel over-compute (where each pixel is a separate world block):

60 updates/sec:
stock @ 3.4 GHZ - 900-930 FPS
downclocked @ 800 MHZ - ~170 FPS

15 updates/sec (Terraria's rate):
stock @ 3.4GHZ - ~970 FPS
downclocked @ 800 MHZ - ~230 FPS
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by Ulydev »

Image
User avatar
Skeiks
Citizen
Posts: 51
Joined: Wed Jan 28, 2015 1:51 pm

Re: What's everyone working on? (tigsource inspired)

Post by Skeiks »

I made this water surface simulator thingy for my game. It doesn't look very natural at the moment, I'm hoping once I add particles it'll look better. It's pretty simple at the moment, I think I might try to release it as a library later on if I have the time. I'm using assets from some of my older games so I'm not just working with squares anymore.

Image
Justin_C
Prole
Posts: 8
Joined: Wed Oct 08, 2014 2:23 am

Re: What's everyone working on? (tigsource inspired)

Post by Justin_C »

I'm working on a rogue-lite dungeon crawler/top-down shooter. All of the art is just placeholder and it's just barely starting to resemble a playable game, but I think it's coming along nicely.

(best viewed at 60FPS in Chrome)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests