Page 2 of 12

Re: Löve "Light vs. Shadow" Engine [Project Page]

Posted: Sat Mar 08, 2014 3:54 pm
by Ranguna259
Maybe AMD is a no go, PriorBlue is there any way you can modifie the code so that it won't load this specific shader or part of the shader, maybe with a flag or something alike ?

Re: Löve "Light vs. Shadow" Engine [Project Page]

Posted: Sat Mar 08, 2014 6:20 pm
by Jeeper
https://love2d.org/imgmirrur/TjrmVoB.png

Here is the error one of friends with AMD sent me.

Re: Löve "Light vs. Shadow" Engine [Project Page]

Posted: Sat Mar 08, 2014 7:42 pm
by slime
'smooth' is a keyword in later GLSL versions. It sounds like the AMD compiler has a bug where it can't handle a variable named 'smooth' even in GLSL versions where it's not a keyword (and it's not a reserved keyword either.)

An easy fix would be to rename the variable.

Re: Löve "Light vs. Shadow" Engine [Project Page]

Posted: Sat Mar 08, 2014 8:06 pm
by szensk
slime wrote:'smooth' is a keyword in later GLSL versions. It sounds like the AMD compiler has a bug where it can't handle a variable named 'smooth' even in GLSL versions where it's not a keyword (and it's not a reserved keyword either.)

An easy fix would be to rename the variable.
this works, thanks slime.

Re: Löve "Light vs. Shadow" Engine [0.2.0]

Posted: Sat Mar 08, 2014 9:41 pm
by PriorBlue
Ok, at first a few answers:
Ranguna259 wrote:...could you add rotation...
Yes, its on my TODO list.
WetDesertRock wrote:Is it possible to have a segment be a game object? ... Also, are you going to do directional light sometime?
The light engine is completely separated from the physics and "drawing stuff" part, so you just have to synchronize the shadow bodys and lights with your game. When you update the light engine, all light/shadow information's will be generated in different canvases, which you can draw over or under your scene.

Yes, directional light will be included, soon.
Error
Cannot compile pixel shader code:
Line 2: error: Syntax error: "smooth" parse error
Yes, smooth is a keyword for ATI shaders. I have changed it to "lightSmooth".

So, here are the new things, i worked on:

My first normal shader calculation wasn't that good, so i watched a few other examples and rewrote him (I hope you can see the differences :awesome: ).

Image

I have finally integrated some options to generate normal maps. So you don't need to pixel them (this options will be extended in the future). It's for now possible to generate flat/gradient normal maps, convert height maps to normal maps and use(convert) the image itself as normal map (usually gives poor results).

Normal map gradient generation:
Image

Height map to normal map generation:
Image

Here some code examples:

Code: Select all

-- generate a simple normal map, which can be only lighted from the front
lightWorldImage.generateNormalMapFlat("front")
-- generate a cone like normal map
lightWorldImage.generateNormalMapGradient("gradient", "none")
-- generate a circle like normal map
lightWorldImage.generateNormalMapGradient("gradient", "gradient")
-- Set the height map of the object. The normal map will be automatically generated with the given strength.
lightWorldImage.setHeightMap(imgHeight, 2.0)
-- The normal map will be automatically generated from the image.
lightWorldImage.generateNormalMap(2.0)
Shadow color and alpha (glass):
Image

Code example:

Code: Select all

-- set the object half transparent
shadowObject.setAlpha(0.5)
-- give the shadow body a color
shadowObject.setColor(255, 0, 0)
More informations can be found on the Wiki.

Re: Löve "Light vs. Shadow" Engine [0.2.1]

Posted: Sun Mar 09, 2014 6:41 am
by Davidobot
This is just so goood. Thank you so much for making this :awesome:

Re: Löve "Light vs. Shadow" Engine [0.2.1]

Posted: Sun Mar 09, 2014 7:09 am
by WetDesertRock
What I found is that the shapes don't go into total darkness when cast into shadow. If you move the mouse away, things will get darker, but not when they are in shadow.

https://love2d.org/imgmirrur/yXBlRk5.png

Re: Löve "Light vs. Shadow" Engine [0.2.1]

Posted: Sun Mar 09, 2014 10:06 am
by Jeeper
WetDesertRock wrote:What I found is that the shapes don't go into total darkness when cast into shadow. If you move the mouse away, things will get darker, but not when they are in shadow.

https://love2d.org/imgmirrur/yXBlRk5.png
In order to make the "shadows" darker, you need to lower your values in the "yourVariableName.setAmbientColor(90,90,90)". If you want the shadow to make your boxes darker, you need to draw the boxes FIRST and then draw the shadow.

Re: Löve "Light vs. Shadow" Engine [0.2.1]

Posted: Sun Mar 09, 2014 6:18 pm
by PriorBlue
WetDesertRock wrote:What I found is that the shapes don't go into total darkness when cast into shadow. If you move the mouse away, things will get darker, but not when they are in shadow.
I know, the shadows are working with a stencil system at the moment, so i can't separate which object is over or under the shadow of another object. I hope i can change this in the future.

So and i polished the glow system, its now a little bit sharper:
Image

And i added a glow functionality to standard circle/poly objects (Press "8" and "9" in the demo):
Image

Here the code for the glow effects:

Code: Select all

-- set the global blur of the glow effect (default: 1)
lightWorld.setGlowStrength(4)
-- add glow to the shadow body
shadowBody.setGlowStrength(1.0)
-- set glow color of the shadow body
shadowBody.setGlowColor(255, 0, 0)

Re: Löve "Light vs. Shadow" Engine [0.2.2]

Posted: Sun Mar 09, 2014 8:37 pm
by Snuux
It's fantastic! Really wery awesome! Please, give me some advice about better way, to learn shaders?)