penumbra
penumbra copied to clipboard
Complex Hulls
The library is great, but you can´t use as a Hull something that is not a polygon, For example, I would use as a Hull a character, that is using an sprite, and has a transparency. For that I will need to define all vertex that create the contour of the character, and it´s not efficient. It would be great if you could use an sprite as a hull.
Thanks for feedback!
This is quite a complex feature. In theory, you could use some edge detection algorithm on the sprite image and feed the output polygon into a hull. That might work for simpler sprites where edge contours are well defined. However, once the edges are no longer solid and transparency comes into play, these algorithms tend to produce a lot of noise and overly complex polygons which then would need to be simplified in order not to take up too much performance (mainly from casting shadows).
Thanks for the response. I feel that using complex polygons for a lot of sprites will perform really bad (havent tested it) I came across a different solution, that uses a Buffer where you draw your sprites in black and white, and this is combined with your lights, but I couldn´t make it work on monogame The XNA version works fine :(. [http://funhazardgames.blogspot.com.es/2012/10/2d-shadows-part-2-manual.html]
Maybe Farseer (see Convex decomposition) contains some clue and good algorithms to do something closer.
@bernardoGM you used a outdated link, he created a monogame compatible version here http://www.funhazard.com/xna-resources.html
@captkirk88 Even the updated MonoGame version will not work with higher MonoGame Framework versions.
I worked with this shadow system in the past and I needed to exchange it. I got the shadow sample working with MonoGame 3.6 though, but there were no lights or shadows in the scene and I didn't know why.
Several people tried to port it over to a newer MonoGame version, but so far no one was able to do it (as far as I know).
I still have the visual studio solution on my hard drive if someone is interested. At least the sample project will run and you can see what changes I did in the shaders so they become compile correctly. But you will need a good knowledge about shaders to make the last changes needed to make everything work I think.
Maybe it's even neccessary to create a complete new shadow system based on the approach of Catalin Zima / Funhazard.
@bernardoGM that is a pity. I was looking into it myself because I need a way to disable updates on entities that are completely engulfed in shadow. I have no way of detecting that with Penumbra. Unless I missed something.
@captkirk88
You could use the LightMap of the PenumbraComponent and use it for the "light detection".
Then draw all your entities on top of it (seperate RenderTarget) and check how much (percentual) light is on an entity. If it's around 0% or 5% -> deactivate the entity.
I think you need to wirte your own litle shader for this. Maybe a kind of a mask shader.
This is just a spontaneous thought. A built-in solution is not available I think.
Edit: A second thought on this: Maybe it's even simpler to use lights with the "Occluded" shadow type and then just check the brightness of an entity.
Could do that using OpenCL instead. I'll look into it. Just started wrapping my head around OpenCL kernels.