Lighting and Shadow System

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post by PriorBlue »

ArchAngel075 wrote:Regarding the latest polyshadow :

I seemed to be unable to change the strength of the light (mouse wheel) after fiddling around, All i could achieve was scrolling alot to make it suddenly jump from no light intensity to maximum and then scrolling in the opposite direction just made it jump to 0 light intensity again instead of the smooth/gradual declining intensity.

Not sure how to replicate the issue though.
hm, this is strange, maybe the shader don't work correctly for you. I added a "smoothstep" function, so maybe this is not compatible. Which OS are you using?

try to change line 14 in the light.glsl from
pixel.rgb = lightColor * pow(att, smooth) + pow(smoothstep(glow.x, 1.0, att), smooth) * glow.y;

to

pixel.rgb = lightColor * pow(att, smooth) + pow(att, smooth) * glow.y;

Hope this works.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post by PriorBlue »

Ranguna259 wrote:PriorBlue, do you have a git for this ?
Not at the moment, but its a good idea. I will create one later...

Ok, done -> https://bitbucket.org/PriorBlue/love2d- ... /wiki/Home
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post by Ranguna259 »

Cool, I'm currently looking into normal mapping, maybe we can do some cool stuff with it.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post by PriorBlue »

Ranguna259 wrote:Cool, I'm currently looking into normal mapping, maybe we can do some cool stuff with it.
Yeah, this was my plan to. I like the work of GarbagePillow (viewtopic.php?f=5&t=11076), but i want to combine it with an auto normal map generator for default initialization, so the user don't necessarily need to create one by its own.
Attachments
creating_normalmaps.pdf
Tutorial to create a normal map from any picture.
(249.82 KiB) Downloaded 111 times
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post by Ranguna259 »

I already looked into gbPillow's code but I had no look, I'm gonna look into it again, I'm having a good feeling this time ;)
Let's do it like this, look into that auto normal map generator and I'll look into the normal map shader.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post by PriorBlue »

Ok, i finally added self shadowing on images, the normal maps are not generated at the moment, but this feature is coming soon.

@Ranguna259: sry for the rush, but it was a little bit more complicated to put this system in the existing engine, so i think i protected you from a lot of stress. :)

Here is the new status image:
Image

This code insert the new pixel shadows:

Code: Select all

-- create a new image (dimension and offset is optional for adjusting the shadow)
newImage = lightWorld.newImage(img, x, y, width, height, offsetX, offsetY)
newImage.setNormal(img_normal) -- add a self created normal map for the calculation

-- Draw your image here (example)
love.light.draw(img, newImage.getX(), newImage.getY())

-- draw pixellight
lightWorld.drawPixelShadow()
Here are some examples, how to create a normal map for pixel art graphics:
Image

Have fun!
Attachments
polylight.love
Version 3
(23.32 KiB) Downloaded 113 times
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Lighting and Shadow System

Post by Germanunkol »

Wicked.

It looks very, very nice.

Performance seems pretty good as well, it would be interesting to see how it performs in a real-world scenario (scrolling map, maybe just two or 3 lights).

Keep it up!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Lighting and Shadow System

Post by kikito »

:o much respect.
When I write def I mean function.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Lighting and Shadow System

Post by Ranguna259 »

This is just too awesome, you are way better at GLSL than me :ultrahappy:
Awesome work, now back to the automatic normal map generator, I've found a few post that might help, Sobel Filter can also calculate Normal Maps.

EDIT: Wait a sec, pixel shadow ? Wouldn't that affect performance ?
EDIT2: Decreased by 200 FPS, an acceptable decrease :P
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Lighting and Shadow System

Post by PriorBlue »

So, the normal map generation is still in work, but i have included a glow effect for the images and i think it's worth an update.

@Germanunkol: scrolling is no problem, because you just have to move the light and shadow objects. I put it in the new tech demo, so you can just try it with the arrow keys. Btw. the lightmaps were only calculated, when they affect the screen, so in theory, you can place infinite lights and objects all over the map and the FPS were only decreased by the elements you see on the screen (thanks to 2D world space :awesome: ).

@Ranguna259: the pixel shadows are just on the images, so don't worry. Oh and thanks for your links!

Ok, here a screenshot of the new glow effect:
Image

You need a special glow image to get this effect, here my examples (color, normal, glow):
Image

Here the new code:

Code: Select all

-- load image and set glow map
glowImage = lightWorld.newImage(img, x, y) -- like before
glowImage.setGlowMap(img_glow)

-- draw your image + light shadow effects --

-- draw glow effect
lightWorld.drawGlow()
Have fun!
Attachments
polyshadow.love
Version 4
(27.17 KiB) Downloaded 119 times
Post Reply

Who is online

Users browsing this forum: No registered users and 62 guests