Page 2 of 3

Re: Shadow converter

PostPosted: 03 Jan 2012, 17:33
by kocsis1david
Thank You

Re: Shadow converter

PostPosted: 11 Jan 2012, 11:58
by Krom
Would it be possible to make shadow opacity and fuzziness to depend on distance from bottom of the sprite?
So that like in real-life sunlight, shadow near the object was darker and with sharp edges, but farther from object it became fuzzy and lighter.

Re: Shadow converter

PostPosted: 11 Jan 2012, 13:05
by GreatWhiteBear
Very good idea.
But wouldn't that call for more bytes? And thus longer loading time?

Re: Shadow converter

PostPosted: 11 Jan 2012, 13:05
by FeyBart
Will the new shadows be implemented in the next update?

EDIT:
Very good idea.
But wouldn't that call for more bytes? And thus longer loading time?
I thought I read Lewin say something about 3x faster loading times for the next update? Not sure though. Anyway, in that case it would mean there's hardly any problem with it.

Re: Shadow converter

PostPosted: 11 Jan 2012, 13:16
by kocsis1david
Would it be possible to make shadow opacity and fuzziness to depend on distance from bottom of the sprite?
So that like in real-life sunlight, shadow near the object was darker and with sharp edges, but farther from object it became fuzzy and lighter.
Yes, but I think distance from bottom is not equivalent to the real distance, so it may not look as natural. I'll make it soon amd we'll see it.
But wouldn't that call for more bytes? And thus longer loading time?
I don't think so, but even if it would, it wouldn't be significant.

Re: Shadow converter

PostPosted: 11 Jan 2012, 13:29
by Lewin
Would it be possible to make shadow opacity and fuzziness to depend on distance from bottom of the sprite?
So that like in real-life sunlight, shadow near the object was darker and with sharp edges, but farther from object it became fuzzy and lighter.
I think that's hard to implement without 3D information about the sprites. Take the storehouse image. The shadow is cast from the right edge of the building, so it should be darkest along the left edge of the shadow, and faintest at the top right. If we did that sprite top to bottom, it would look like the shadow is being cast from the wrong place. If anything it should be bottom-left to top-right as that is the direction of the shadows, but I still think it might look odd on some sprites. I'd have to see a sample :)
EDIT: I mean the same thing as kocsis1david, he wrote it more concisely.
Very good idea.
But wouldn't that call for more bytes? And thus longer loading time?
Did you mean these shadows in general, or Krom's last post?
In general the shadows will use more RAM, but I'm not sure how much. Most of the loading time is currently spent on loading PNGs inefficiently. ("additional sprites") Loading zipped RGBA sprites is slightly slower than loading the original palleted files, but overall loading is still ~3x faster because loading RGBA is much faster than loading PNGs.
Krom's suggestion won't use more bytes or take longer to load than shadows without it.
Will the new shadows be implemented in the next update?
Probably, unless we encounter issues or something.

Re: Shadow converter

PostPosted: 11 Jan 2012, 13:31
by FeyBart
(...)
Probably, unless we encounter issues or something.
Nice. :-)

Re: Shadow converter

PostPosted: 11 Jan 2012, 15:31
by Krom
Right, but trying that out could be interesting and maybe it will look OK.

Re: Shadow converter

PostPosted: 11 Jan 2012, 16:08
by kocsis1david
Yeah, but we'll probably need a better algorithm to estimate the distance.

EDIT:
I have an idea: Max(X / Width, 1 - Y / Height). I think this would be almost good if we consider house as a cube. What do you think?

Re: Shadow converter

PostPosted: 12 Jan 2012, 06:07
by Krom
As Lewin said - there are many sprites and each one is special in a way. Algo looks good, but without seeing actual result it's hard to tell ;)

Re: Shadow converter

PostPosted: 12 Jan 2012, 13:53
by Lewin
Today I was looking at real shadows of buildings and trees, and I found they are about the same darkness at the top and bottom of the shadow, unless it's REALLY high (like a 4+ level building, and even then the difference is barely noticeable, just the edges are fuzzier) For 1-2 level houses in KaM and average size trees, I don't think the shadows would be any different at the top or bottom, or if they are, it should be VERY subtle. From the distance we view KaM the fuzzy edges won't be a noticeable difference IMO.

When simulating sunlight, you treat the light source as infinity far away. (meaning every ray of light is parallel to every other ray, unless you are on a REALLY big scale) This means that any part of the ground which does not have a line of sight to the sun will be in full shadow, and only illuminated by ambient light bouncing off other objects. That means all parts of the ground have the same darkness.

So having considered it I don't think this is necessary, or if it is, it should be very subtle.

Take a look when you next outside, you'll hardly notice a difference between areas of shadows. (unless it's partial shadow through foliage, but that's a different story) Mind you, I don't know whether there's much sun in Europe at the moment, it's the middle of summer here ;)

Re: Shadow converter

PostPosted: 12 Jan 2012, 14:04
by Siegfried
Well, the color of shadows is the same all over the shadow. The only thing that changes is the fuzziness of the edges. The more you go away from the light blocker, the fuzzier the shadow edge becomes. That's the effect of diffraction. But the lightness stays the same all over the shadow.

But I don't see any necessity to implement this into KaM. This only becomes important for narrow objects which KaM doesn't have apart from flagpole.

Re: Shadow converter

PostPosted: 12 Jan 2012, 14:25
by The Dark Lord
Mind you, I don't know whether there's much sun in Europe at the moment, it's the middle of summer here ;)
Sun?

What's that? :P

Re: Shadow converter

PostPosted: 12 Jan 2012, 14:34
by GreatWhiteBear
*derp*
We have "Winter".
Meaning it is about 10 degrees Celsius warmer than any winter I have seen.

Re: Shadow converter

PostPosted: 12 Jan 2012, 16:30
by FeyBart
Well, the color of shadows is the same all over the shadow. The only thing that changes is the fuzziness of the edges. The more you go away from the light blocker, the fuzzier the shadow edge becomes. That's the effect of diffraction. But the lightness stays the same all over the shadow.

But I don't see any necessity to implement this into KaM. This only becomes important for narrow objects which KaM doesn't have apart from flagpole.
I think fuzziness of shadows wouldn't be necessary to implement.

A real shadow of a 5 meters high object would have a blurry edge of about two centimeters (doing this in centimeters and meters because I have no idea how big a foot or inch is :P). So assuming the buildings in KaM are about 5 meters high, and the scale would be something like 250:1, the fuzzy edge would be around 0,8 millimeters wide.
*derp*
We have "Winter".
Meaning it is about 10 degrees Celsius warmer than any winter I have seen.
Haha, I think the overall difference between our summer and the winter we have right now, is around 5 degrees Celsius. :P