Hi there!
Is anyone using LightWorld implementation of Light vs Shadow library? ( https://github.com/tanema/light_world.lua )
I expected this effect:
Instead, I got
Which is exactly opposite result to what I expected... Does anyone knows how to fix it?
Thanks in advance!
Have a good one
[SOLVED] light_world.lua incorrect lighting direction
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] light_world.lua incorrect lighting direction
Last edited by 0x29a on Thu Oct 27, 2016 8:55 pm, edited 2 times in total.
Re: light_world.lua incorrect lighting direction
It doesn't look like the opposite to me at all. It looks like your light is a bit high and that makes the shadows stop at a short distance from the object that casts them. But then I haven't used that lib so I can't tell if the library works that way.
Re: light_world.lua incorrect lighting direction
Hi there!
No, shadows are not a problem. Problem is that textures are enlightened from the wrong side.
Look closer: With Light vs Shadow [upper screen] little blobs are brighter near the source of light and darker farther away. Also, blobs with Y-axis value lower than light source Y-axis value ("above" the light source) are bright from the "front" side and those with higher value ("beneath" the light source) are dark on the "front" side.
With Light_World implementation [lower screen] it's exactly opposite - blobs "beneath" the light source are bright on the "front" side and blobs "above" the light source are dark.
No, shadows are not a problem. Problem is that textures are enlightened from the wrong side.
Look closer: With Light vs Shadow [upper screen] little blobs are brighter near the source of light and darker farther away. Also, blobs with Y-axis value lower than light source Y-axis value ("above" the light source) are bright from the "front" side and those with higher value ("beneath" the light source) are dark on the "front" side.
With Light_World implementation [lower screen] it's exactly opposite - blobs "beneath" the light source are bright on the "front" side and blobs "above" the light source are dark.
Re: light_world.lua incorrect lighting direction
I see now. What LÖVE version is that library for, and what version is your program for? I ask because there was a swap of the shader's Y coordinate at some point, IIRC between 0.9.2 and 0.10.0, and I wonder if that's at play here.
Re: light_world.lua incorrect lighting direction
I'm using 10.x
light_world library is a re-write of light_vs_shadow library. It's for 10.x, but it's predecessor was for 9.x series.
Also, very good hint. It very well might be that issue.
light_world library is a re-write of light_vs_shadow library. It's for 10.x, but it's predecessor was for 9.x series.
Also, very good hint. It very well might be that issue.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: light_world.lua incorrect lighting direction
light_world seems to have an "invert normals" option - maybe that will help?
Re: light_world.lua incorrect lighting direction
Thanks, but I've tried it out already...
From what I get is that "invert normals" should give normal maps "concave' or "sunken" look instead of regular "convex" or "bulging" effect. I may be wrong, but I'm pretty much sure about that.
From what I get is that "invert normals" should give normal maps "concave' or "sunken" look instead of regular "convex" or "bulging" effect. I may be wrong, but I'm pretty much sure about that.
Re: light_world.lua incorrect lighting direction
Yeah, it's not what we're seeing. If it was that, the left-right direction would also be inverted. It's only the up-down one.
It should be easy to make a quick test that inverts the Y coordinate in the shader, to determine guilt. If that fixes the problem with the orientation, regardless of whether it causes other problems, then you can dig further for how to fix it.
It should be easy to make a quick test that inverts the Y coordinate in the shader, to determine guilt. If that fixes the problem with the orientation, regardless of whether it causes other problems, then you can dig further for how to fix it.
Re: light_world.lua incorrect lighting direction
Do you happen to know how to do it? I'd be forever in your debt.
I've tried reading shader's code, but it's very opaque to me...
https://github.com/tanema/light_world.l ... hadow.glsl << I believe it might be that thing.
I've tried reading shader's code, but it's very opaque to me...
https://github.com/tanema/light_world.l ... hadow.glsl << I believe it might be that thing.
Code: Select all
// if not on the normal map draw attenuated shadows
if(normalColor.a <= 0.0) {
//start with a dark color and add in the light color and shadow color
pixel = vec4(0.0, 0.0, 0.0, 1.0);
if (lightGlow.x < 1.0 && lightGlow.y > 0.0) {
pixel.rgb = clamp(lightColor * pow(att, lightSmooth) + pow(smoothstep(lightGlow.x, 1.0, att), lightSmooth) * lightGlow.y, 0.0, 1.0);
} else {
pixel.rgb = lightColor * pow(att, lightSmooth);
}
} else {
vec3 normal = normalize(vec3(normalColor.r,invert_normal ? 1 - normalColor.g : normalColor.g, normalColor.b) * 2.0 - 1.0);
//on the normal map, draw normal shadows
vec3 dir = vec3((lightPosition.xy - pixel_coords.xy) / love_ScreenSize.xy, lightPosition.z);
dir.x *= love_ScreenSize.x / love_ScreenSize.y;
vec3 diff = lightColor * max(dot(normalize(normal), normalize(dir)), 0.0);
//return the light that is effected by the normal and attenuation
pixel = vec4(diff * att, 1.0);
}
if(shadowColor.a > 0.0) {
pixel.rgb = pixel.rgb * shadowColor.rgb;
}
return pixel;
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: light_world.lua incorrect lighting direction
The invert normals option in this library only seems to invert the Y (green channel) coordinate.pgimeno wrote:Yeah, it's not what we're seeing. If it was that, the left-right direction would also be inverted. It's only the up-down one.
Who is online
Users browsing this forum: No registered users and 14 guests