This project is read-only.

How to use Krypton engine

Feb 17, 2012 at 2:20 PM

Are there any tutorials on how to implement the Krypton engine?

I am quite new to using game engines. So far I have build almost everything that is in my game myself. However I found creating a lighting engine too complicated and went to research. From what I've seen Krypton does a good job :D. 

Thank you,

Feb 17, 2012 at 3:35 PM

Okay I got it, you just not have to look at it as if it's fucking complicated :D It looks nice :D

Feb 17, 2012 at 10:59 PM
Edited Feb 17, 2012 at 11:01 PM

I can't get my light to stick to a location on a 2D tile-based map. It sticks to a location on the screen and stays there wherever I scroll to.

Draw Method:


protected override void Draw(GameTime gameTime)
            // Matrix worldMatrix = Matrix.Identity;
            Matrix view = camera.ViewMatrix;

            // Assign the matrix and pre-render the lightmap.
            // Make sure not to change the position of any lights or shadow hulls after this call, as it won't take effect till the next frame!
            this.krypton.Matrix = view;
            this.krypton.Bluriness = 3;

            krypton.SpriteBatchCompatablityEnabled = true;
            krypton.CullMode = CullMode.CullClockwiseFace;




 Matrix ViewMatrix
            get { return _viewMatrix; }

        private void UpdateViewTransform()
             Matrix proj = Matrix.CreateTranslation(new Vector3(_viewport.Width * 0.5f, _viewport.Height * 0.5f, 0)) * 
                           Matrix.CreateScale(new Vector3(1f, 1f, 1f));

             _viewMatrix = Matrix.CreateRotationZ(_rotation) *
 Vector3(_zoom, _zoom, 1.0f)) *
                          Matrix.CreateTranslation(_position.X, _position.Y, 0.0f);

             _viewMatrix = proj * _viewMatrix;
// This is how I draw a sprite:
groundRectangle = new Rectangle(spriteXPosition - (int)camera.cameraPosition.X, spriteYPosition - (int)camera.cameraPosition.Y, squareDimension, squareDimension);
spriteBatch.Draw(groundSprite, groundRectangle, Color.White);


You can see that I subtract the cameraposition from the spriteposition in order to make the sprite appear where it actually is. If I can change how light is drawn to how I draw a sprite I think I can manage to let it appear where it should be.

I just want to know if anyone has already fixed this. I searched the discussionboard and found 1 possible fix, which didn't fix my problem.

Feb 18, 2012 at 10:13 AM

I know how to fix this, in a lightUpdate void make sure that the location of the light is adjusted to sth like: 

// Where you want the light to be
Vector2 lightPosition;

light.X = lightPosition.X - camera.cameraPosition.X; 
light.Y = lightPosition.Y - camera.cameraPosition.Y; 

Feb 21, 2012 at 6:34 PM

Welcome! I hope you're enjoying your dive into Krypton :)

I tried to start working on some implementation documents, but eventually lost track of time and haven't touched it since. As you're going through here, feel free to let us know what was simple and what was too hard to figure out!

Feb 21, 2012 at 8:58 PM


I figured it all out myself and looking back to it; Krypton is awesomely simple. :)
It would be good if there was just something like:

  1. How to add Krypton to your own project (I for one never added something external to my projects)
  2. Some explanation of what a matrix actually is ( I found this site usefull so linking or crtl-v should do the trick)
  3. How to draw a light
  4. What all the options on a light mean
  5. How to draw a box 
  6. What all the options on a box mean
  7. Optional: Some tricks you can use for specific effects.
    1. For instance: I needed a sun in a realistic world and I build one, problem was that I wanted the blocks in the 'floor' absolutely black. Got it black, night was absoletly black.
    2. Solution was to add a real vague light a mile up in the sky with a huge range and really weak intensity and set the ambientcolor to black.
    3. With this I don't mean that you have to think out every possible trick, but just to include a little more on the settings and what you can do with them to achieve specific effects.

I am willing to write these things for you as I now understand it, I just think you know your engine better than I do.

Thank you for your time and work, it is greatly appreciated by me.
When I finish my game I'll put your logo in the start screen "Lighting powered by Krypton" Of course you will be shown 3 million times a day xD
Seriously though, thank you. :)