Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Penumbra - Matrix

$
0
0

@Oyyou wrote:

I've recently starting trying to implement the Penumbra library for some lighting.

A problem has occurred trying to get Penumbra to work with my camera.

Looking at this sample, I see that there really isn't much going on in terms of matrices. Every update call, the penumbra matrix is set for the camera and projection

_penumbra.Transform = _camera.Transform * _projection;

but I can't for the life of me figure out how this is then applied to the spriteBatch transform.

I've been hacking my code apart to try and figure it out, and have gotten nowhere. Below is my version of the code, and then from the sample:

Mine -

  var pp = _graphicsDevice.PresentationParameters;
  var projection = Matrix.CreateOrthographicOffCenter(
      -pp.BackBufferWidth / 2.0f,
      pp.BackBufferWidth / 2.0f,
      -pp.BackBufferHeight / 2.0f,
      pp.BackBufferHeight / 2.0f,
      0.0f, 1.0f);

  penumbra.SpriteBatchTransformEnabled = false;
  penumbra.Transform = _camera.Transform * projection;

  penumbra.BeginDraw();

  _graphicsDevice.Clear(Color.Black);

  _spriteBatch.Begin(
    SpriteSortMode.FrontToBack,
    BlendState.AlphaBlend,
    SamplerState.PointWrap,
    null, null, null, null);

  foreach (var component in GameComponents)
    component.Draw(gameTime, _spriteBatch);

  penumbra.Draw(gameTime);

  _spriteBatch.End();

Sample -

        _penumbra.BeginDraw();

        GraphicsDevice.Clear(BackgroundColor);

        base.Draw(gameTime);

I'm going to keep looking through the code on GitHub, but if somebody has already come across this, that'd be great.

Does anybody have any knowledge with this library that can help me out?

My full project is here, but is a bit of a mess (don't plan on cleaning for a while) and won't compile if downloaded (merge error :smile:)

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles