Comments on: dynamic soft shadows in 2D http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/ Sat, 06 Jul 2013 19:02:18 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Max http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-8766 Max Sun, 19 Aug 2012 00:17:52 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-8766 Thanks for the answer! I will probably try something like what you suggested for the overbrightening before I look into floating point textures.
I will also release it in the future, but it is not finished yet. There are no comments and I still want to do some of the things I mentioned. Right now I want to look into how Box2D does its spatial partitioning. I found this, but understanding the code might take a while: http://gamedev.stackexchange.com/questions/15126/2d-spatial-partitioning-alternatives-to-spatial-hashes-and-quadtrees/15150#15150

]]>
By: Christian http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-8765 Christian Sat, 18 Aug 2012 13:51:06 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-8765 I’m glad to hear that you got it working. Looks great! :)

What I was thinking about when writing the statement about modern gpus was that the algorithm described here was mainly constrained by the limited number of blend modes available in the old fixed function pipeline. I haven’t thought about improving it in detail. Using vertex buffers and some sort of spacial tree data structure for the lights would definitely make sense though.

As for overbrightening: floating point textures would work. You can also continue to use ARGB32 and change the pixel shader used for blending the lights onto the scene to do a scaled multiplication (something like result_color = 2 * unlit_color * light_amount) . You’d lose some accuracy and would have a maximum amount of overbrightening, but that’s probably ok.

If you release your code somewhere, let me know! People have been asking for a C++ implementation quite a bit.

]]>
By: Max http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-8763 Max Thu, 16 Aug 2012 13:19:54 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-8763 Hi,
I implemented this in c++ and it works, but I am interested in learning what you mean by “a lot has changed in the last years. You could probably achieve the same effect much more efficiently on modern graphics cards.” Optimizations I can think of are:
- using a Quadtree to determine which lights/shadowblockers are visible
- use vertex buffers instead of immediate mode
- maybe put the shadow casting stuff in a geometry shader

Also I think there are two limitations right now with this method. First, you can’t get overbrighting effects as described in the original article. I solved this by rendering the whole scene in a seperate fbo and blend it over each light, but I think this is not the most optimal way of doing it. It would be ideal if you could somehow save color values greater than 1 in a fbo, but I don’t know how.(maybe floating point textures or something)
Second, this currently only works if the lights size is smaller than the shadowblockers. I think this can be solved by rendering both the penumbras and umbra in full darkness and then subtracting the areas of the penumbras appropriately.

Anyways, this helped me a lot, I am only interested in knowing what can be improved to make it even better. This is how my implementation looks right know, you can also see the mentioned overbrightening effects:
http://www.iamwhoiam.net/max/shadow-test2.ogv

]]>
By: Christian http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-8595 Christian Mon, 28 Nov 2011 06:26:59 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-8595 David: It’s equivalent to this C++ code:

for (size_t i = rightpenumbra.sections.size() - 1; i < blockerLine.size() - leftpenumbra.sections.size() + 1; ++i) {
    Vert &vert = blockerLine[i];
    umbra.sections.push_back(Umbra::Section(vert, extendDir(0.5 * (leftpenumbra.sections.last().direction + rightpenumbra.sections.last().direction)));
}

]]>
By: David Amador http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-8589 David Amador Fri, 25 Nov 2011 23:17:21 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-8589 Hi, great tutorial.
But I’m having some troubles converting it to C++.

Would you mind converting this line to me, I can’t understand the loop, begins where and finishes where?

foreach(ref vert; blockerLine[rightpenumbra.sections.length-1..$-leftpenumbra.sections.length+1])
umbra.sections ~= Umbra.Section(vert, extendDir(0.5 * (leftpenumbra.sections[$-1].direction + rightpenumbra.sections[$-1].direction)));

I’m also having some troubles on other parts but for now this would help a bunch. I’ve placed my email on the form.
Thanks

]]>
By: Jeff On Games » Posted Without (Too Much) Comment http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-6771 Jeff On Games » Posted Without (Too Much) Comment Fri, 30 Jul 2010 01:35:49 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-6771 [...] shadows working in XNA using the GameDev article in combination with Catalin's implementation and Christian's implementation in D. However, trying to write the post, I wasn't sure if I could make it any clearer, as I'm not [...]

]]>
By: Manuel Bua http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-6537 Manuel Bua Tue, 04 May 2010 13:25:00 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-6537 Cool stuff, any chance to download c++ code for it?

]]>
By: Jim http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-6154 Jim Sun, 20 Dec 2009 09:32:33 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-6154 Christian: Thx for the reply :). Dont worry, i got it working just enough to achieve what i want.

Thank you. Your sample codes really helped me in trying to achieve the effect. I would have no idea how/where to start by just reading orangy’s article.

Cheers :)

]]>
By: Christian http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-6148 Christian Fri, 18 Dec 2009 18:15:14 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-6148 Jim: While porting the prototype can be a fun exercise, a lot has changed in the last years. You could probably achieve the same effect much more efficiently on modern graphics cards.

Unfortunately I don’t have the time to help debug your problem. Start small, build things step by step and test everything along the way.

]]>
By: Jim http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/comment-page-1/#comment-6129 Jim Mon, 14 Dec 2009 20:17:28 +0000 http://www.incasoftware.de/~kamm/projects/index.static/2007/09/08/soft-shadows-2d/#comment-6129 Hi, Im just wondering if youre still active or not. I am currently in the process of porting the prototype to c++, but im having trouble in getting the blending to work, thus the shadows dont work.

Would be great if you can help.

FYI, great article. Helped me a lot :)

]]>