discosultan / penumbra

2D lighting with soft shadows for MonoGame
MIT License
315 stars 32 forks source link

Transforming Penumbra with Camera? #36

Closed Aternix12 closed 2 years ago

Aternix12 commented 2 years ago

Apologies if this a newbie-ish question, but I'm wondering how to apply Penumbra within spriteBatch so the _cam.transform makes the lighting attach to the viewport. Currently I have Penumbra drawn statically to the screen.

image

Unfortunately all the samples have static screens without any viewporting so I wasn't able to work from those, is there a way to convert the shader to a XNA.Graphics.Effect to be past as a param to _spriteBatch.Begin?

Cheers heaps!

discosultan commented 2 years ago

The PenumbraComponent has a Transform property. See if setting that works for you. https://github.com/discosultan/penumbra/blob/5729589c1ba05d4c8f68a64fce16b0892a941734/Source/PenumbraComponent.cs#L58-L65

Aternix12 commented 2 years ago

That's got it, just applied it to the transform the camera uses on update. Thank's for the help! image