Ambient Occlusion?

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Purchase Ambient Guitars 2 and Ambient Guitars 3 to complete your collection of guitar loops!
  • There's an instruction limit? O.o Wow, I didn't know.. Anyway thanks for your work

    Edit: Construct needs multi-pass shaders

  • Couldn't you just use a regular off the shelf method for SSAO (screen space Ambient Occlusion), using copies of objects with depth maps on them (which basically look and behave like height maps), which would effectively make up for the lack of any genuine depth in a 2D world. Since SSAO in 3D games uses a depth map in the same way, which is why it's so much faster than real Ambient Occlusion.

    I dunno, in theory it would work, because it's not doing anything that can't already be done.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm hitting arithmetic instruction limits for PS2 when blurring the shadow with a 5x5 kernel.

    You can use PS 2.0a, which raises the instruction limit from, I think, 64 to 512. Just change this line:

    PixelShader = compile ps_2_0 EffectProcess();[/code:31y9cqxr]
    to:
    
    [code:31y9cqxr]PixelShader = compile ps_2_a EffectProcess();[/code:31y9cqxr]
    Although, this has downsides, because not all PS 2.0 capable cards support 2.0a.
  • 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)

  • 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)

    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.

    And now you've got me thinking, how cool a remake of Shadow of the Beast would look, with all the above. Oooooh.

  • Hm. I have a tendency to not explain too clearly, so I'll elaborate.

    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.

    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.

    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

  • 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..

    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!

    [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.

    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.

    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

    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

  • What I'd like to see is construct drop the whole 3D box thing

  • > What I'd like to see is construct drop the whole 3D box thing

    >

    I don't get it..

  • all those objects have different depth maps, which all make up one full screen depth map.

    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.

    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 )

    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

  • > all those objects have different depth maps, which all make up one full screen depth map.

    > 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.

    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 )

    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

    Yes an example would shut me u.. I mean convince me..

  • I don't get it..

    3d box is extremely useful. It should never be dropped.

  • > I don't get it..

    >

    3d box is extremely useful. It should never be dropped.

    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.

  • yeah that shader does create a drop shadow for each object. The complex thing would be to get the right interaction for a complex background.

    Construct's effects apply only to a single layer, and are single pass, so it can't be done exactly like the one there.

    The offsetting by color makes me thing of that distort object that was posted here. You'd need a copy of the layout with color indicating height, then distort according to that height with the existing effect, then compare to the color in that location previous to the distort (that'd be a custom effect) to deduce shading... then.....

    okay, maybe an effect would make that part simpler. You'd still need to manually generate a layer with the proper colored sprites, though... and that's probably a mess too.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)