Split screen...

Apr 11, 2011 at 12:11 AM
Edited Apr 11, 2011 at 12:14 AM


First, thank you for your great engine!

Second, I was wondering how one would go using your engine in a split screen game. The shadows rendered correctly without the split screen, but when I render the two separate screens, with two separate viewports, I can't get it to cast shadows correctly and apparently it renders only the second viewport...

Here's an image of the split screens rendering correctly without shadows (one player is the center of the left screen, the other is the center of the right screen):


Here's an image of the split screens with shadows (the screen no longer centers correctly and apparently there's only one viewport).

Here's my rendering code:

        public int renderIndex;
        public override void Render(GameTime gameTime)
            PlayerSceneObject playerSceneObject;

            for(renderIndex = 0; renderIndex < playerSceneObjects.Count; renderIndex++)
                playerSceneObject = playerSceneObjects[renderIndex];

                cameraTranslation = ConvertUnits.ToDisplayUnits(playerSceneObject.Body.Position);
                cameraTranslation -= new Vector2(playerSceneObject.viewport.Width, playerSceneObject.viewport.Height) / 2.0f;

                SetCameraMatrix(ref playerSceneObject.viewport);

                Game.GraphicsDevice.Viewport = playerSceneObject.viewport;

                krypton.Matrix = cameraMatrix;



        protected virtual void RenderBackSprites(GameTime gameTime)
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied,
                                  null, null, null, backEffect,

            // Render my sprites



        protected void SetCameraMatrix(ref Viewport viewport)
            cameraMatrix = Matrix.CreateTranslation(new Vector3(-viewport.Width / 2.0f, -viewport.Height / 2.0f, 0.0f)) *
                           Matrix.CreateTranslation(-cameraTranslation.X, -cameraTranslation.Y, 0.0f) *
                           Matrix.CreateScale(zoom) *
                           Matrix.CreateTranslation(new Vector3(viewport.Width / 2.0f, viewport.Height / 2.0f, 0.0f));


Thank you for your time,

Ricardo Moura

Apr 11, 2011 at 2:28 PM

Thanks for your post, Ricardo.

This reveals a pretty serious design flaw within krypton. I'll have to investigate a way to fix this. I never design krypton to be used with multiple viewports.

Correct my if I'm wrong, but in the second screenshot it seems as though krypton has undone your vieweport settings?

Apr 11, 2011 at 2:46 PM

It looks that way... I think it's only rendering the second viewport but using the whole screen.

If you would like to take a look at other parts of the source code I'll be more than happy to supply.


Apr 21, 2011 at 12:23 AM

Is there any way I can help? I tried looking into krypton's code but apparently just changing the render target, which is essential to the rest of Krypton, interferes with the rest of the code... :(

This is a great engine otherwise... Btw here's a video of the game if you're interested:



Thanks for your time!

Aug 6, 2011 at 7:56 PM


Hopefully we can get this sorted out soon. I apologize for the lack of update.

Aug 11, 2011 at 12:55 AM

I like the transition that you did from day to night! Nice work!

I'll try to look into your issue as well.

Aug 26, 2011 at 9:36 AM

Hello, I actually dropped the split screen, now the players share the same screen.

I've been working on the crypts, which use a separate krypton engine. Here's a video:


Here's a link to my dev blog:


And our twitter page if you want to be aware of further updates: