Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Lights branch - complete!
1 2 3 Previous Next
- - By Newton [de] Date 2015-01-04 00:16
Today, Clonk-Karl merged the lights branch into master. That means, everyone can try out the new lights using the development snapshots now!

Even though the originally mentioned major issues have been solved, it does not mean that all issues are gone. Please, everyone, have a look at the bugtracker, especially the major ones of course. One bug that particularly bugs me:

Wanted


Dead or alive

Lights - Odd effects when having 2+ light sources
$ 10000 Clunker Reward

This has something to do with the blending of the light texture. The solution will probably involve using a shader to compose the light texture and is thus interconnected with two other issues:
* The fade-in of the light is too slow, especially when moving fast. It looks like not the clonk himself is the light source but some kind of invisible fairy that follows him. The slow fade might be the source of some other minor display oddities.
* the lights of 2+ light sources are added in a way that the light becomes very intense. Rather than light1+light2, it should perhaps be Max(light1,light2).

Who can do this?
Parent - - By Maikel Date 2015-01-04 08:33
Congratulations to all who have worked hard on this!

Related question: Should we merge the bugs from Roadmap 5.2 and Roadmap 6.0 into Roadmap 6.0 such that we have a single roadmap for the release?
Parent - - By Newton [de] Date 2015-01-04 12:22
It's fine how it is. There we see the requirements for 6.0 and 5.2 seperately. to release 6.0, both requirements need to be met.

But looking at it, there is quite a lot to do. You sure those are all necessary=blocking for a release?
Parent - By Maikel Date 2015-01-04 12:35
No they are not, I think some of them could go into a 6.1 release (for example with my new power system).
Parent - By Clonkonaut [de] Date 2015-01-04 14:07
Yaaay \o/
Reply
Parent - - By Pyrit Date 2015-01-04 16:22 Edited 2015-01-16 01:05
*missing material normal maps
I already made some of the still required normal maps. I'm continouig to make the rest these days, but the crazybump demo run out of time, so i'm stuck with the gimp Plugin.
Parent - By Newton [de] Date 2015-01-05 09:55
As long as the normal map quality isn't inferior, that's ok. Otherwise, someone could do this perhaps on a different computer where the trial did not run out?
Parent - - By Matthias [de] Date 2015-01-05 14:20
There seems to be a pretty newly launched (but in version 1.0) open source project AwesomeBump which looks promising at first glance. Perhaps give it a spin and compare the quality to your previous textures? the author also provides some videos which showcase the features: ( Okay so HOW does the vid-tag work in here? O_o ) https://www.youtube.com/watch?v=fKdCglwEacI
Reply
Parent - By Newton [de] Date 2015-01-05 16:46 Edited 2015-01-05 18:21

Like this
[vid=youtube]fKdCglwEacI[/vid]
Parent - - By Newton [de] Date 2015-01-05 16:49
That looks pretty awesome.

CrazyBump,
InsaneBump,
AwesomeBump,...
I detect a naming pattern there.
Parent - By Matthias [de] Date 2015-01-05 18:17
I seems InsaneBump was a Gimp-Plugin that tried to mimic CrazyBumps features. AwesomeBump is partially based on InsaneBump as InsaneBump seems to be frozen. In a forum thread, the AB-author mentions that his tool gives poor results when the source image has a strong directional light. I expect this restriction to apply to the gimp plugin as well, then, but the landscape textures don't have very strong lights, so that's probably not a problem, probably.
Reply
Parent - By Pyrit Date 2015-01-10 22:26
Looks gr8, I'll use that now! :)
Parent - - By Pyrit Date 2015-01-16 01:05
Done. :)
Parent - - By Maikel Date 2015-01-16 09:18
Screenshot of the improvement?
Parent - By Newton [de] Date 2015-01-16 13:40
Before-and-after!!
Parent - By Pyrit Date 2015-01-17 00:27
Why need of screenshot? Just play the game? :)
Parent - - By Pyrit Date 2015-01-11 20:34

>The fade-in of the light is too slow


Could this be the cause of the following glitch? When you are running around and the viewport moves to a formerly dark area, this area is lighted.  But it seems the light is only updated every few frames. Because the viewport moves faster than the light is updated, there occur stripes at these areas.
Also switching clonks causes some light artifacts until everything has faded to it's right state.
Parent - By Newton [de] Date 2015-01-11 20:53
I doubt it is the cause because if you run left, you don't have these artifacts. I think this is a different issue.
Parent - - By PeterW [de] Date 2015-01-14 21:48

> Lights - Odd effects when having 2+ light sources


Yeah, just saw this is the record for #1227. Fun how easily it is to see when normals aren't quite right. This is terrible, I might have a shot at it shortly.

And agree on the fade problem. It's actually quite bad that Clonk faces are always dark because of the trailing light source. For my local branch I already reduced the fade substantially, which makes it a bit better. Was also experimenting with having the light source "lead" moving objects a bit. That worked... less well.
Parent - - By Sven2 [de] Date 2015-01-14 21:53
I think the better solution would be to rewrite fading such that the combination with the previous surface also happens in the shader. At the moment, I think there even is a shader but it only create a surface that is then blit on top of the real light surface (which seems like an unnecessery fullscreen blit to me).

That way, we can do thinks like increasing light instantly but decreasing it only over some time. We could even add a nonlinearity to this to avoid trailing lights.
Parent - - By PeterW [de] Date 2015-01-15 12:37 Edited 2015-01-15 12:41
Trouble is that of all things, blending is still not something that you can control with a shader. All you can do is set a blend func and pack as much meaning as you can into the RGBA vector you return. To get the full functionality of blending you would have to render to a texture, then combine that surface with the background into *another* texture. See that whole situation in C4FoWDrawLightTextureStrategy (explanation in C4FoWLight::Render) - I would *love* to use a shader there, but I don't think it's possible.

Not saying that it's always impossible, just that shaders still have some very puzzling limitations.
Parent - - By Sven2 Date 2015-01-15 16:46
It makes a lot of sense to have your destination surface unreadable. Otherwise it would be impossible to parallelize operations. But you can always achieve the same effect by having a temporary surface - which we already have.

In other words, just pass a pointer to the last lights surface (for which a copy is already generated) into the lights calculation and do the blending manually in the end. Then, as the non-programmable blend op, the surface is just copied.
Parent - - By PeterW [de] Date 2015-01-15 18:07 Edited 2015-01-15 18:14
I can't see how this would hinder parallelisation - at least not more than the current blending does. And working around it isn't quite that easy either - after all, we are drawing a bunch of (potentially overlapping) triangles to the frame buffer. Every drawing operation will obviously only update their own region. This means that we need to manually keep track of what exactly was written where, culminating in different drawing plans for points that are blended over 0, 1, 2... times.

Or we copy the whole frame buffer for every triangle (strip?) we draw. Either way, it's madness.
Parent - - By Sven2 [de] Date 2015-01-15 20:24
Ah I see the problem now. It could still be prevented by switching between three surfaces instead of two.

One surface is always used for drawing the current light state. For the faded light state, the engine alternates between the other two surfaces so it can use the previous frame state as a source.

That would incur one extra frame buffer switch, one extra surface and the blit operation would have two sources instead of one. But the final blit would be simpler because it would be without alpha.
Parent - - By PeterW [de] Date 2015-01-15 23:33 Edited 2015-01-15 23:54
One extra frame buffer copy per triangle strip, as I said. Admittedly, we don't have to do it per triangle strip - as long as nothing overlaps (!) we would only have to do it once per light source. And if we know the lights bounds, we don't have to blend over the whole frame buffer either. On the other hand, if we overwrite the whole thing at least once, we could combine it with the fade-out shader.

So, yes, it's probably acceptable. What problem were we trying to solve exactly? Use max for setting light intensity, possibly?

[Edit XVIII] The problem with the "lagging" light is actually the normals, not the light intensity. Hm, maybe we could make normals adapt faster than intensity? I might actually give this a try. Might become messy though, that's nothing I'll hack together overnight.
Parent - - By Sven2 Date 2015-01-16 10:23
No, not one copy per strip. Just one frame buffer change. Like this:

* Three surfaces: a, b, c
1. Swap b,c
2. Select a as render target
3. Clear a
4. Draw all triangle strips to a
5. Select b as render target
6. Draw to b from a,c using our blending shader

-> b contains the current lights surface

I would guess that switching the render target is a pretty expensive operation since it needs to flush stuff in the rendering pipeline. But then, drawing the lights triangles is probably not an expensive operation anyway.
Parent - - By PeterW [de] Date 2015-01-16 11:05
Yes, I know what you meant - but that still only works as long as the triangle strips don't overlap. But as I said, that's the case as long as we only draw one light at a time, so it's not *too* bad.
Parent - - By Sven2 Date 2015-01-16 11:31 Edited 2015-01-16 11:33
Why? "4. Draw all triangle strips to a" is the same thing that is done now, isn't it? I meant all triangle strips of all lights of course.
Parent - - By PeterW [de] Date 2015-01-16 12:03
What would happen then when two lights overlap? Unless we want another piece of "blending" magic, the lights would just overwrite each other then, no?
Parent - - By Sven2 Date 2015-01-16 13:00
No, they would be merged by the same code that merges them now.
Parent - - By PeterW [de] Date 2015-01-16 14:38
Well, right now they *are* just blended over each other :)
Parent - - By Sven2 Date 2015-01-16 15:12
Ah, okay, now I understand the confusion. Sorry, my answer referred to the second part of the posting. It's not a solution for the blending of multiple light sources, but for the blending of the light sources with the previous frame buffer - i.e. the problem with the trailing lights.

For multiple light sources, I think standard blend ops should be sufficient. Can't we just push light intensity into the alpha channel, then blit alpha with blend equation of GL_MAX and do regular  alpha blending for the normal vectors in the color channels?
Parent - - By PeterW [de] Date 2015-01-16 20:40
Possibly. But blending over the old state is not the complicated part in the first place... Using glBlendFuncSeparate to get max on intensity is a nice idea, and I'll probably try it. But this is still adding extra complexity exactly where I'd like to get rid of it :/
Parent - - By Sven2 [de] Date 2015-01-16 23:19
Actually, we could then blit the previous frame buffer in the same way using GL_MAX for the intensity channel. It would ensure that light is lit up immediately (so no trailing lights) and fades out gradually.
Parent - By PeterW [de] Date 2015-01-17 01:39
As I said - the "trailing" effect comes from the normals, not the intensity (most textures happen to predominantly face forward). The light intensity is at max until it hits a solid material.
Parent - - By PeterW [de] Date 2015-02-23 10:56
Just FYI - the approach I mentioned here is now implemented, in the alternate-lights branch. It updates lights a lot faster. I don't like it, but if somebody wants to see this in action, that's now possible.
Parent - By Maikel Date 2015-02-23 11:25
I don't like it too much either, it flickers a lot somehow.
Parent - - By PeterW [de] Date 2015-01-15 12:54
Btw, there are still two light parameters that we might want to expose to script:

- Light intensity. Right now it's hard-coded at 0.5, which means that two lights will add up to maximum intensity.
- Light size. This decides how "soft" the light is. Higher values means soft shadows, but possibly less light shining through narrow passages. Right now hard-coded at 20.

Does that sound useful to anybody?
Parent - - By Maikel Date 2015-01-15 13:26
What is shining through narrow passages? I find it very strange that in a cave you can see infinitely far into a narrow passage (along the straight line).
Parent - - By PeterW [de] Date 2015-01-16 11:27 Edited 2015-01-16 11:32
Hm, the effect is less obvious than I would have thought... Reason is that I'm "capping" the light size for close distances - otherwise a single pixel right in front of the Clonk would cast a huge shadow.

Anyway, here's screenshots for sizes 5, 10, 15 and 20 (current default). It's probably easiest to see that the normals fall off at different speed, which leads to the middle becoming "brighter". But if you look closely, you will see that the shadows on the left and the upper-right also change shape a bit:

Parent - - By Zapper [de] Date 2015-01-16 12:06
I find 20 to look more appealing than 5 at least - but my main reason for that is not the general brightness or the shadows but that in the 20-picture, the Clonk itself has no noticable shadows.

In the 5-picture it does not look like the Clonk (or the player) is the source of the light but that there is a very tiny lightbulb in front of the Clonk, leading to hard shadows on the Clonk itself.

I guess that is an effect of capping close lights? In the 20-picture the area around the Clonk has full (or even more) brightness and the falloff only starts further away from the Clonk, right?
Parent - By PeterW [de] Date 2015-01-16 14:42
Well, 20 is the default for a reason :)

And yes, the normal fall-off is way more obvious than the effect on the shadows. Should probably have tried to de-couple it for the screenshots so it's more obvious.
Parent - - By Newton [de] Date 2015-01-15 23:24

> - Light intensity. Right now it's hard-coded at 0.5, which means that two lights will add up to maximum intensity.


Oh. Really, that little? I had the impression that ambient light and light from clonks are about the same brightness.  In my opinion, lights from clonks may not be any lighter than the ambient light (so ~any lighter than how they are currently). If two lights meet, it should not get any brighter. Instead, the light range is obviously larger (if the lights are not at the same point).
Let's say that the current light intensity for one clonk is 100%, then I think this could be exposed to C4Script together with when colored lights are introduced - as the alpha value. SetLightColor(RGBa(x,y,z,a))

> - Light size.


I think that shouldn't be exposed but rather be playtested to find an optimal value. I see no gain (= no use case) for making this definable in script (for possibly each light different).
Parent - - By PeterW [de] Date 2015-01-15 23:39 Edited 2015-01-15 23:43

> In my opinion, lights from clonks may not be any lighter than the ambient light


I actually thought about reducing the light intensity for Clonks... Wouldn't it be nice if you could really see everything being brighter in your well-lit cave?

> I see no gain (= no use case) for making this definable in script (for possibly each light different).


It actually governs how fast the normal shifts around the light source, too. It could make a lot of sense to make this bigger for "ambient" type lights.
Parent - - By Sven2 Date 2015-01-16 10:28

> I actually thought about reducing the light intensity for Clonks... Wouldn't it be nice if you could really see everything being brighter in your well-lit cave?


If everything being dark is the "normal" thing to happen during some rounds (i.e. those without torches and lit caves), then we just end up in a situation like the current night implementation using gamma: Your eyes adapt to the darker screen and you need to make everything excessively dark for the effect to be noticed at all (and then you can hardly see anything). But I guess it can be worked around by making clonks lights an easy-to-adjust scenario property.

Btw: An interesting way to implement night time now would be to just switch off the ambience light caused by sky material. The nice property of this method is that it automatically doesn't affect caves. If we have colored lights, we could also just reduce ambience and give it a blue-ish color.
Parent - - By PeterW [de] Date 2015-01-16 11:02
Well, I *was* talking about relative brightness (base vs. Clonk). Having the player's eyes adjust to the dim surroundings only to be blinded by their base? Well, let's not overdo it.

The problem Newton was talking about was actually that having a bunch of Clonks together would now also produce this effect. As I wrote above, *this* might be a reason to use max instead of addition for updating light intensity.

And yes, switching off (or fading out) sky ambience at night would probably work well. I really like the effect together with a non-black background (such as stars): The landscape becomes a silhouette then, just like in real life.
Parent - - By Clonk-Karl [us] Date 2015-01-16 15:57

> And yes, switching off (or fading out) sky ambience at night would probably work well.


By the way, there is already a script function to do that: http://docs.openclonk.org/en/sdk/script/fn/SetAmbientBrightness.html
Reply
Parent - - By Sven2 Date 2015-01-16 16:37
But that script function would also switch off lava :(
Parent - - By Newton [de] Date 2015-01-16 17:37
A valid point. Looks like lava-glow and global ambient light cannot be be killed with one stone.
Parent - - By Sven2 Date 2015-01-16 18:16
We could just have one int light_range[256] that defines a custom range per material/texture. Then there can be functions to set all sky background ranges or ranges of certain materials.

Altenatively just has_light[256] if multiple light ranges are hard to implement.
Up Topic Development / Developer's Corner / Lights branch - complete!
1 2 3 Previous Next

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill