Live data from Hacker News

How to create 2D visibility/shadow effects for your game

ncase.github.io

21–30 of 47 posts

Re: How to create 2D visibility/shadow effects for your game

#21
post #5

He uses a nice trick to approximate the real thing, however this algorithm wouldn't be able to deal with curved objects.

Couldn't you do something like this for a hack?

http://i.imgur.com/G5U43ZU.png

Calculate the edge points of the circle, draw a line between them, and then your shadow is simply a rectangle. Overlay the circle over the shadow to hide the line.

This will work with circles and ovals, but not more complex curves.

Re: How to create 2D visibility/shadow effects for your game

#22
post #10

You, sir, must be from the future, what with the uncopyrighted, bitcoin-based crowdfunding campaign. Backing this effort is a no-brainer. https://back.nothingtohide.cc/

So it turns out you CAN earn money on non-copyrighted work. $40,000 is not a small amount for most people. Well-deserved for the developer, hats off for the idea, implementation, and Bitcoin as a payment option.

Re: How to create 2D visibility/shadow effects for your game

#25
post #10

You, sir, must be from the future, what with the uncopyrighted, bitcoin-based crowdfunding campaign. Backing this effort is a no-brainer. https://back.nothingtohide.cc/

A bit OT but what are some of the most successful open source game titles out there? I'm writing a game server backend right now and didn't find very many projects where I could read good quality game code. (I come from the JS web app world where everything is out in the open so I'm super biased)

Re: How to create 2D visibility/shadow effects for your game

#26
post #17

Earlier quoted context omitted.

I'm not too strong with trig. Would this also work with curves that have more than one bump? (sine, etc.)

Yes, with calculus you can find all the tangent lines from a point to any kind of curve. The exact equations vary based on what kind of curve it is (sine, parabola, cubic splines, Bezier curves, non-uniform rational B-splines, etc) and are kinda complicated.

At that point you're no longer dealing with rays and the math gets way more expensive for a goal of 1/60th of a second per render loop.

Re: How to create 2D visibility/shadow effects for your game

#27
Nice example, but ray casting like this is overkill for this effect and with a low number of rays it's pretty inaccurate.

I prefer using the technique shown in this classic article on 2D soft shadows: http://archive.gamedev.net/archive/reference/programming/fea...

The basic idea is to project the geometry, rather than ray cast. I've implemented this sort of technique in the past and it works well.

Re: How to create 2D visibility/shadow effects for your game

#28
I'm kinda tired of the "cone-of-vision" mechanic and associated visual effect common in modern 2D games. In traditional 2D games, being able to see things that are not visible to the player's avatar is, IMO, a significant part of the charm. Not being restricted to a realistic viewpoint lets you become the larger-than-life hero of cartoons and cheesy action movies that does impossible things like leaping into a room full of bad guys and shooting them all before they have a chance to react, or "sensing" someone behind him and dodging the arrow at the last second. When you make a 2D game that tries to "realistically" limit the player's view, you're getting the downsides of both 2D and 3D games. It says to me, "I really wanted to make an FPS but I don't know how."

No criticism is intended towards OP's game; the "un-stealth game" is a different and interesting idea. I'm just throwing it out there for those dreaming up yet another top-down cone-of-vision stealth shooter to chew on.

Re: How to create 2D visibility/shadow effects for your game

#29

I'm kinda tired of the "cone-of-vision" mechanic and associated visual effect common in modern 2D games. In traditional 2D games, being able to see things that are not visible to the player's avatar is, IMO, a significant part of the charm. Not being restricted to a realistic viewpoint lets you become the larger-than-life hero of cartoons and cheesy action movies that does impossible things like leaping into a room f…

Well, it's not like the unlit parts must be completely black.

Having some dynamic lighting does not mean that you must make it part of your game's mechanics. It's perfectly fine to do that kind of thing just for polish.

Post reply on HN