Jump to content

Recommended Posts

Posted

Light cone angles not saves:

1. Create spot light

2. Set 60 : 90 cone angles

3. Open map file or reload in the editor - 60 : 60

 

Brightness does not matches with in game bright in same cases, but can't reproduce it yet

 

Strange stripes from light on surfaces:

image.thumb.png.33bed6b9496c73085dd9e478bec8fcb3.png

Example map:Start.zip

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

Posted
1 hour ago, Dreikblack said:

Strange stripes from light on surfaces:

This is shadow acne, and can always happen with texture-based lighting. Increasing the shadow map size and avoiding lights that are very close to a surface is the easiest way to avoid it.

  • Like 1

Let's build cool stuff and have fun. :)

Posted
2 hours ago, Josh said:

This is shadow acne, and can always happen with texture-based lighting. Increasing the shadow map size and avoiding lights that are very close to a surface is the easiest way to avoid it.

Shadow map size increase helped. Also had to set 0 for near range. Working on flashlight for characters so had to be close to surfaces in any case.

Also noticed similar issue from sun light and no option to change shadow map for it in the Editor? Can do it via code ig, but extra field for in world settings would be convenient for people.

  • Like 2

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

Posted

I think I created something pretty close to the magic formula that will make shadows close to objects that are casting them, but prevent most shadow acne.

At line 196 of Shaders/PBR/Lighting.glsl, try replacing this:

			shadowCoord.z *= 0.98f;
			shadowCoord.z = PositionToDepth(shadowCoord.z, shadowrange);

With this:

			//shadowCoord.z *= 0.98f;
			float tscale = (512.0f / float(textureSize(sampler2DShadow(shadowmap), 0).x));
			shadowCoord.z -= 0.005f * tscale;
			shadowCoord.z = PositionToDepth(shadowCoord.z, shadowrange);
			shadowCoord.z -= 0.001f * sin((1.0f - dp) * 1.5708f) * tscale;

An initial offset in linear space is used, and then a second offset is added AFTER conversion into non-linear space, and accounts for the angle between the surface normal and the photon direction. Most importantly, it treats the dot product as an angle, not a simple dot product, which I think is crucial for the accuracy. It also scales the offset by the texture resolution, so smaller shadow maps have a greater depth error.

image.thumb.png.764b299c7c8abcaca2c60813716a325f.png

It's a challenge because you want the tighest possible offsets without causing shadow acne, bit the depth values are stored in a strange non-linear way, and there is more precision near the camera than far away. I have made some attempts to store shadow maps in a linear depth value, but so far have been unable to find a way.

It is possible to modify gl_FragDepth in a fragment shader, but this comes at a performance cost because it eliminates the early-z discard. Does this cost apply to shadow rendering in any significant way? I think so but I don't know for sure.

  • Like 1

Let's build cool stuff and have fun. :)

Posted

I don't know, I just invented it ten minutes ago. We should probably test it out a bit more before making any big plans. :D

  • Like 2

Let's build cool stuff and have fun. :)

Posted

Zero is not a valid number of the near range, for any light that uses perspective projection (spot and point). The value must be greater than zero.

Let's build cool stuff and have fun. :)

Posted

That's shadow acne.

Why are the edges of the light perfectly sharp lines? The spot light is supposed to fade out near the edges.

Let's build cool stuff and have fun. :)

Posted

The edges don't even look like a round shape. What are these sharp straight lines?

The cone angles should be defined in the order outer, inner, and a 90 degree angle is impossible because that would form a flat plane.

image.png.3c35d966d34b8f8d99701312ab63c648.png

Let's build cool stuff and have fun. :)

Posted
9 minutes ago, Josh said:

The edges don't even look like a round shape. What are these sharp straight lines?

idk, it just works this way when created via code:

image.thumb.png.4ff2e9e69c5ee007164da964c6e30cd1.png

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char* argv[]) {
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->Move(0, 2, -2);
    auto ground = CreateBox(world, 20, 1, 20);
    ground->SetPosition(0, -0.5, 0);
    ground->SetColor(0, 1, 0);

    auto light = CreateSpotLight(world);
    light->SetPosition(0, 1, 0);
    light->SetColor(5, 5, 5);
    light->SetConeAngles(60, 90);
    light->SetShadowmapSize(4096);
    light->SetRange(1, 8 * 2);
    light->SetFalloff(LIGHTFALLOFF_INVERSESQUARE);

    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false) {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

Posted

Okay, I see.

You need to decrease the near range, and the inner cone angle should be less than the outer cone angle. Use values like maybe 60, 50.

Let's build cool stuff and have fun. :)

Posted

Near range needs to be 1.0f to avoid character shadow from his own flashlight. And i'm fine with that shape anyway.

I will experiment with angles a bit later, thought it's horizontal and vertical. Set 60:30 for now, looks better, but might be not sharp enough for gameplay purposes laterimage.thumb.png.1b68d15af469a5f1e85c1e6eb6a7b295.png

  • Like 1

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

Posted

This seems to provide a consistent offset:

			float tscale = (512.0f / float(textureSize(sampler2DShadow(shadowmap), 0).x));
			shadowCoord.z -= 0.005f * tscale;
			shadowCoord.z = PositionToDepth(shadowCoord.z, shadowrange);
			shadowCoord.z -= 0.001f * sin((1.0f - dp) * 1.5708f) * tscale * (shadowrange.x / 0.1f);

 

  • Like 1

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...