Page 4 of 5

Re: Lighting and Shadow System

Posted: Tue Mar 04, 2014 1:37 pm
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.

Re: Lighting and Shadow System

Posted: Tue Mar 04, 2014 1:40 pm
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

Re: Lighting and Shadow System

Posted: Tue Mar 04, 2014 5:06 pm
by Ranguna259
Cool, I'm currently looking into normal mapping, maybe we can do some cool stuff with it.

Re: Lighting and Shadow System

Posted: Tue Mar 04, 2014 5:55 pm
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.

Re: Lighting and Shadow System

Posted: Tue Mar 04, 2014 8:57 pm
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.

Re: Lighting and Shadow System

Posted: Wed Mar 05, 2014 7:03 am
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!

Re: Lighting and Shadow System

Posted: Wed Mar 05, 2014 9:35 am
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!

Re: Lighting and Shadow System

Posted: Wed Mar 05, 2014 10:07 am
by kikito
:o much respect.

Re: Lighting and Shadow System

Posted: Wed Mar 05, 2014 2:05 pm
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

Re: Lighting and Shadow System

Posted: Thu Mar 06, 2014 12:09 am
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!