Ambient Occlusion?

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Wed Dec 09, 2009 4:21 am

[quote="Madster":2fkr9f0o]I'd like to insist on how SSAO is pointless in 2D.
Allow me to explain:

SSAO is occlusion, independent from light sources, based on the depth difference between each pixel.

Construct is 2D (mostly). What's the depth difference within a sprite? Zero. Always. What if you want to have a heightmap with heights? well, then the depth difference will be always the same, since the normal never changes..... so, the occlusion will always look the same and you're better off baking it, EVEN IF YOU USE NORMAL MAPPING.

And if you layer one sprite on top of another? well that's why I suggest drop shadow.

I'll try upping the pixel shader version and see if it's enough. I'm bumping into a lot of limits there (registers too)[/quote:2fkr9f0o]

Wall of text warning ;)

SSAO is a 2D effect using a depth map, it's faster but less accurate than full Ambient Occlusion.

AO is a 3D effect and wont be seen in games for some time. It's faster than global illumination etc. But still too slow to be used in realtime.

Nothing displayed on the screen has depth, doesn't matter what your using, the end result is always going to be 2D. Internally it's 3D. AO is calculated internally and takes into account all the fun light beams and so on and so forth. SSAO doesn't because it can't, it doesn't have access to any of that information. But it does have access to depth maps (I only used height maps as an example of how they look, they're inverted in most programs but the principal is the same). A depth map is the Z-Buffer, it's used to decide what's in front of something and what's behind, and it's very, very useful.

A good use of depth maps is in post production. At that point all your resources are completed and the end results are nothing more than images. Often it's a good idea in post, to do certain effects such as fog, depth of field, or even placing elements in the correct positions in relation to the image. Now if you've just got the single stock image, you're kind of boned unless your elements were against a single color (like green/bluescreen) or using alphas to allow them to be cut out. But even then, to do things properly, a depth map helps. It can then tell the 2D program that a particular effect, lets say fog, should appear heavier where the depth map is pure white, and then falloff as it gets darker. You've just put fog perfectly into an otherwise flat image.

SSAO works the same, and there's a number of plugins available in post production applications which do just that. After Effects and Shake come to mind as two that have them.

-

As for depth within a sprite. Your right, a default sprite in a default 2D world has no depth, being two dimensional.

But what's stopping you from having depth? Consider a parallax effect, 10 layers all scrolling at a different speed. It's 2D, it has no depth. But what if the artwork on each of those layers were given a depth. The artwork in the background layers would be further away than those closer. You couldn't see the difference to look at it. But what if you then applied a DoF shader that takes depth maps into account? You've got visible depth.

Now say you were to create a sprite of a lil guy running, viewed from the side. Shade him however you want, he's just a 2D image. But give him a depth map, where his arm is closer, like an inverted height map. Add an SSAO shader on that, you've got realtime ambient occlusion. You could do this in the same way normal maps are applied at the moment, so effectively doubling everything, or tripling it if you add the normal map required copies too.

Now while this is entirely possible. I'm not saying it's easy. To accurately setup a scene in 2D to make best use of depth maps and SSAO or a DOF shader. You have to plan ahead, either build the scene in pre-rendered 3D, output the required images and depth maps. Or be very good at deciding where things should be in relation to the imagined depth.


So I wouldn't say it's pointless, or impossible. But to set it up without forward planning can break the illusion entirely, and it wouldn't be very useful for everything (retro looking pixely games would have no use for it for example).

Incidentally, you can do Parallax Occlusion Mapping the same way, with a shader coded to change the parallax effect based off of distance and angle from a center point, and using a standard height map for it's input rather than a depth map. Yes that would work just fine in a 2D game as well. But considering you'd be then having four clones of everything, to take into account a depth map for SSAO and DOF (and more accurate motion blur), a normal map, and then a height map for the parallax occlusion effect. You're going to be needing a decent machine just to run it at a sensible framerate. :D

And now you've got me thinking, how cool a remake of Shadow of the Beast would look, with all the above. Oooooh. :)
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Thu Dec 10, 2009 1:39 am

Hm. I have a tendency to not explain too clearly, so I'll elaborate.
[quote="Lost my Keys":1b9vt8q2]As for depth within a sprite. Your right, a default sprite in a default 2D world has no depth, being two dimensional.

But what's stopping you from having depth? Consider a parallax effect, 10 layers all scrolling at a different speed. It's 2D, it has no depth. But what if the artwork on each of those layers were given a depth. The artwork in the background layers would be further away than those closer. You couldn't see the difference to look at it. But what if you then applied a DoF shader that takes depth maps into account? You've got visible depth.[/quote:1b9vt8q2]

okay, say you have depth per object. This depth is..... PER OBJECT. So, any light occlusion effects will happen PER OBJECT.... thus doing them PER PIXEL is overkill. Just fake it with another object, as it will essentially be a drop shadow. DoF also doesn't make any sense in 2D. I did post a variable blur shader, that when applied to a whole layer accomplishes what you'd probably call DoF... but it's way simpler and doesn't rely on depth.

[quote:1b9vt8q2]But give him a depth map, where his arm is closer, like an inverted height map. Add an SSAO shader on that, you've got realtime ambient occlusion.[/quote:1b9vt8q2]

So you have a frame-based animation. This animation has a depth animation, where each frame has a corresponding depth map. This depth map has a SSAO shader. Notice that since SSAO is calculated on the depthmap that only changes with each animation frame, the results will also only change with each animation frame...
Now, consider baked ambient occlusion. You only have animation, no depth... you have REAL AO, since you'd get it from your renderer of choice. No shader. Results also change with each animation frame.
Same effect, half the texture memory, much faster, much simpler.
Thus, SSAO in 2D is pointless.

I only say this because I see a lot of people go and play Crysis or whatever and then come back and excitedly ask for something they saw there to be in Construct.... but VERY FEW 3D effects make sense in 2D.

All that said, I'm still onto that blurred drop shadow effect. I've realised, though, that it's much easier and faster to have a smaller, stretched shadow object that follows the real one... why? well, it allows for some other effects that I'll attempt soon :)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Dec 10, 2009 2:16 am

[quote="Madster":28g4a6t8]okay, say you have depth per object. This depth is..... PER OBJECT. So, any light occlusion effects will happen PER OBJECT.... thus doing them PER PIXEL is overkill. Just fake it with another object, as it will essentially be a drop shadow. DoF also doesn't make any sense in 2D. I did post a variable blur shader, that when applied to a whole layer accomplishes what you'd probably call DoF... but it's way simpler and doesn't rely on depth..[/quote:28g4a6t8]

True, but the way I'm looking at it, is all those objects have different depth maps, which all make up one full screen depth map. Now if you apply the SSAO shader to the full screen, it grabs the depth map of everything there, rather than individual objects only (which I agree would be kinda pointless and wasteful), so you've got faked AO across the entire gamescreen regardless what's going on in the game. To bake all that into your artwork and take into account objects passing other objects is out of the question.

As for DOF, yeah I can agree with you there. A DOF shader would just serve to simplify the effect, but in the end results in practically the same look. I think I have played around with your blur shader btw, it's the one that can be used to create a motion blur effect without the painful overhead of using the built in motion blur, right? At least that's how I planned on using one along those lines, and in tests it didn't kill framerate! :D

[quote:28g4a6t8]So you have a frame-based animation. This animation has a depth animation, where each frame has a corresponding depth map. This depth map has a SSAO shader. Notice that since SSAO is calculated on the depthmap that only changes with each animation frame, the results will also only change with each animation frame...
Now, consider baked ambient occlusion. You only have animation, no depth... you have REAL AO, since you'd get it from your renderer of choice. No shader. Results also change with each animation frame.
Same effect, half the texture memory, much faster, much simpler.
Thus, SSAO in 2D is pointless.[/quote:28g4a6t8]

But like I say, you're then stuck with what you've got baked into your artwork. Which is perfectly fine for static objects or certain situations and it's a well used trick of the trade. But interactive area's and objects could benefit, BUT only if it's done right. Flat drop shadows are ok to a point, but they show up the 2Dness of things, unless they can make use of a depth map (or height map) to shape the shadow in realtime across something behind them. The option to use either would be the best bet, as there's lots of uses for drop shadows and SSAO.

Parallax Occlusion Maps would have their uses though. Here's a quick example It would help to bring a little more depth to a game, a subtle but useful effect.

Course, end of the day, it's all down to how a game is made. They didn't have none of these things in the old days and got around them all via various tricks.

[quote:28g4a6t8]I only say this because I see a lot of people go and play Crysis or whatever and then come back and excitedly ask for something they saw there to be in Construct.... but VERY FEW 3D effects make sense in 2D.[/quote:28g4a6t8]

Heh yeah, we were using all these things for years then video games started using similar things and suddenly every gamer in the world was an "expert" on them and had to use them in EVERYTHING, lol. Was like with Babylon 5 making lens flares popular, suddenly everything had to have a bloody awful lens flare stuck on it, or Poser, spawning countless thousands of badly made Poser "art".

Personally I'm more a fan of putting as much detail into something than relying on realtime effects than I might seem. But I can't help but be very, very curious how some of these effects could be used in a 2D only situation. Same with physics, everyone said it could never work in 2D, then someone went and did it, and well, now we've got 2D physics and it's pretty useful :D

Besides it's no secret how I feel about the whole "oh oh lets make construct 3D!!!!1111oneoneoneeleven", it's a 2D app and should remain a 2D app. It has a good chance of being a very popular one, but if it tries to be 3D or a jack of all trades, it's doomed. But things like parallax occlusion, SSAO, normal maps, realtime lighting/shadows (that use an objects shape not it's bounding box plzkthx lol) or even a behavior along the lines of the apparantly abandoned #6 challenge, for getting certain shadow effects easily. They all have their uses in 2D too. Not as immediately obvious as they would be in 3D. But uses all the same.

What I'd like to see is construct drop the whole 3D box thing, but focus on allowing things to have internal depth, using the grayscale maps, and soft shadow casting. Imagine a top down game in a haunted house, shadows flickering across the floor, rooms in darkness, pushing open a physics enabled door that lets some light in just as something jumps out of the shadows and and and.. lol yeah :D
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Thu Dec 10, 2009 2:26 pm

[quote="Lost my Keys":12zooca0]What I'd like to see is construct drop the whole 3D box thing[/quote:12zooca0]
[url:12zooca0]http://www.youtube.com/watch?v=z_trSIBCgF0#t=01m47s[/url:12zooca0]
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Thu Dec 10, 2009 5:46 pm

[quote="Davioware":1zhsejmq][quote="Lost my Keys":1zhsejmq]What I'd like to see is construct drop the whole 3D box thing[/quote:1zhsejmq]
[url:1zhsejmq]http://www.youtube.com/watch?v=z_trSIBCgF0#t=01m47s[/url:1zhsejmq][/quote:1zhsejmq]

I don't get it..
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Thu Dec 10, 2009 7:21 pm

[quote="Lost my Keys":15j2r144]all those objects have different depth maps, which all make up one full screen depth map.[/quote:15j2r144] Which is made up of individual, static depth maps...

[quote:15j2r144]Flat drop shadows are ok to a point, but they show up the 2Dness of things, unless they can make use of a depth map (or height map) to shape the shadow in realtime across something behind them. The option to use either would be the best bet, as there's lots of uses for drop shadows and SSAO.[/quote:15j2r144]
SSAO doesn't change with light direction or occlusion, as it is AMBIENT light (the A in SSAO). The occlusion term would only change if depths change, which you can fake convincingly enough with a soft drop shadow object (in case I fail to produce an effect :P )

So anyways. Seems I can't convince you that 2D SSAO doesn't make any sense (just as I failed in an old DoF thread).... perhaps an example showing nice shadowing would do :D
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Dec 10, 2009 7:34 pm

[quote="Madster":24hiditd][quote="Lost my Keys":24hiditd]all those objects have different depth maps, which all make up one full screen depth map.[/quote:24hiditd] Which is made up of individual, static depth maps...

[quote:24hiditd]Flat drop shadows are ok to a point, but they show up the 2Dness of things, unless they can make use of a depth map (or height map) to shape the shadow in realtime across something behind them. The option to use either would be the best bet, as there's lots of uses for drop shadows and SSAO.[/quote:24hiditd]
SSAO doesn't change with light direction or occlusion, as it is AMBIENT light (the A in SSAO). The occlusion term would only change if depths change, which you can fake convincingly enough with a soft drop shadow object (in case I fail to produce an effect :P )

So anyways. Seems I can't convince you that 2D SSAO doesn't make any sense (just as I failed in an old DoF thread).... perhaps an example showing nice shadowing would do :D[/quote:24hiditd]

Yes an example would shut me u.. I mean convince me.. :D
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Thu Dec 10, 2009 7:36 pm

[quote="Lost my Keys":1nqmve4e]I don't get it..[/quote:1nqmve4e]
3d box is extremely useful. It should never be dropped.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Thu Dec 10, 2009 7:45 pm

[quote="Davioware":n62tczib][quote="Lost my Keys":n62tczib]I don't get it..[/quote:n62tczib]
3d box is extremely useful. It should never be dropped.[/quote:n62tczib]

Guess I just see it as something of a Pandora's box (box, geddit? ha, anyways). I suppose I don't quite see the usefulness to it right now. But I'm sure I'll change my mind once I start seeing real world examples of what it's capable of.

Though I would be the first to jump on 2.5D build engine style support. So I'm not totally opposed to some kind of 3D.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Mon Dec 14, 2009 5:49 am

B
3
S
2
G
3
Posts: 628
Reputation: 2,531

PreviousNext

Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests