So a few days back, I started playing around with Krypton XNA for 2D lighting in my game.

I noticed in general, that spawning a light at (0,0) with Krypton causes the light to appear in, pretty much, the centre of the game screen. Is there any way to change this so a Krypton light's "starting point" at [0,0] would spawn at the top left of the screen, and thus follow the standard screen co-ordinates for position?

I ask because currently I'm busy working on my game where my spawn point is [512,512]. With hard code, the closest I've got to the light being "central" to this point is the vector position [12,-20], which makes no sense and is impossible to craft, mathematically, if I want the light to move with the camera (the position [480,512] maps roughly to [10,-20]).

So, is there any way to "normalise" the krypton lights to use standard screen co-ordinates?

If you guys can, play around with the demo from the site and please see if you can find anything out about it. Documentation on the engine is rather scarce, so it's difficult to find anything relevant to my "pixel-perfect" need. It might just also be something in the code with regards to the matrices that I'm not fully understanding.

Any help would be useful.


  • \$\begingroup\$ You can't simply take the width of your screen and subtract that from the starting point? ie spawn a light at [-450,-720] if your screen is 900x1440 and it will be in the top left corner. I'm not used to xna (hence im only commenting) but is there no way to get the screen's height and length? \$\endgroup\$ Jul 23, 2012 at 21:00
  • \$\begingroup\$ Alas, no luck there. Again, this all comes down to, I think, Krypton's non-pixel based vector co-ordinate system where, for example, 12 units along the X axis is actually around 512 pixels. Like I said, however, this measurement system feels fairly arbitrary and I can't figure out the math behind it. \$\endgroup\$ Jul 23, 2012 at 21:44
  • \$\begingroup\$ Oh I see, 12 units is equal to 512ish. I didnt get that from the question. Hmmm, seems like an unusual problem indeed. \$\endgroup\$ Jul 23, 2012 at 21:46

1 Answer 1


I am the creator of Krypton

SpriteBatch uses pixels as it's default unit. Krypton does not have a default unit. Imagine "1px" vs "1" vs "1km". Krypton's units would simply be "1".

You'll need to either adjust Krypton's matrix to compensate for the variation by enabling "SpriteBatch" mode on Krypton, or by adjusting SpriteBatch's matrix, which can be accomplished via an overload to the Begin call.

There has been some confusion about how to do this easily, and my attempts to make the framework easily usable with SpriteBatch have thus far been less than satisfactory. I will be making some improvements within the next month or two, as I will need this feature for a game I am currently working on.

  • \$\begingroup\$ by enabling "SpriteBatch" mode on Krypton by doing this: KryptonEngine.SpriteBatchCompatablityEnabled = true; ? \$\endgroup\$
    – Cypher
    Sep 21, 2012 at 0:00
  • \$\begingroup\$ Correct. That should compensate for the scaling / translation issues. However, you will also need to change the cull mode when you do this, as it reverses the direction triangles are rendered. You can set the cull mode to none for testing purposes. Let me know if you have any issues \$\endgroup\$
    – cwharris
    Sep 21, 2012 at 1:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .