Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex Hulls #3

Open
bernardoGM opened this issue Apr 25, 2016 · 8 comments
Open

Complex Hulls #3

bernardoGM opened this issue Apr 25, 2016 · 8 comments

Comments

@bernardoGM
Copy link

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.

@discosultan
Copy link
Owner

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

@bernardoGM
Copy link
Author

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]

@InfiniteProductions
Copy link

Maybe Farseer (see Convex decomposition) contains some clue and good algorithms to do something closer.

@captkirk88
Copy link

@bernardoGM you used a outdated link, he created a monogame compatible version here http://www.funhazard.com/xna-resources.html

@BlizzCrafter
Copy link
Contributor

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

@captkirk88
Copy link

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

@BlizzCrafter
Copy link
Contributor

BlizzCrafter commented Dec 20, 2017

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

@captkirk88
Copy link

Could do that using OpenCL instead. I'll look into it. Just started wrapping my head around OpenCL kernels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants