Only one light is showing

Jan 27, 2011 at 5:48 PM

Oops, I think I broke something. Anyway, only one light is showing. I add all the lights (ktypton.Lights.Add(myLight)), but it seems that it renders only the first light I added.

I mean, I do:


And only myLight1 is rendered. In the testbed works ok though, but in my game is where lies the problem. I'm looking at the graphicsdevice settings to see if I broke something but I can't find anything strange. Any idea what could it be?

Jan 27, 2011 at 8:14 PM

Hi, me again. In the testbed I added an additional light, and something weird is happening. Only one light casts shadows (the one at the left), the other one doesn't.

I don't know if it's related with the issue I described above, anyway. I'm using the changeset 2380.

Jan 27, 2011 at 9:15 PM

Hi Pnikosis!

Check out the Light Opacity Discussion thread that I just posted to. Your issue may be related to the problem we just corrected. Try grabbing changeset 2450 (only the shader was updated) and let us know if you're still having problems. It might not fix the first problem you described, but the shadow problem should be fixed now.


Jan 27, 2011 at 9:35 PM

Thanks Dindak! That was fast! :)

In fact, the shadow problem is now solved, but the first problem is still there. I'm sure is something about my code, as the testbed seems to work well, so I'll try to look deeper to see where could be my error.

Jan 27, 2011 at 11:48 PM

No problem! Sorry I can't suggest anything initially with what could be wrong with your graphics device. If you could open a ticket under the Issue Tracker with some more info (and code snippets) then xixonia and I can troubleshoot this for you :)



Jan 28, 2011 at 2:07 AM


It seems like you have two lights in your example, so I may be misunderstanding your problem, but if you are still having trouble with adding lights, let me know...

Jan 28, 2011 at 2:40 AM

His second example is inside the testbed, which was the shadow alpha issue seen in zombiecow's last thread. Pnikosis is having trouble adding multiple lights inside his own game with his graphics device. Obvious checks would be light position/properties (but assuming all those are within screen bounds, etc), could he be setting a blend state incorrectly with his graphics device?

Jan 28, 2011 at 7:52 AM

@Xixonia, as Dindak said, the second example was related to the zombiecow's last thread. This one is solved :) The other one (only one light rendering) is still there :(

@Dindak. I checked the light positions and properties, in fact if I don't add the first light, then the second light is displayed then. Now I'm suspecting about the blend state, but I'm not sure how to check that, I'm restoring the blend modes* each step to be sure if the error isn't there, but nope :/


* Using this:

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Jan 28, 2011 at 7:56 AM

Hey, Pnikosis!

Which lighting technique are you using? Because I just found a bug for the PointLight_ShadowWithOcclusion technique where only the first light will draw (totally weird, but I fixed it).

Is that the issue you were seeing?

Jan 28, 2011 at 8:14 AM


We're working on making Krypton as stateless as possible, so no-one will need to worry about blend blend modes in the future.

Jan 28, 2011 at 8:37 AM
Edited Jan 28, 2011 at 8:54 AM

I'm using PointLight_Shadow :/

I'll download the latest changeset anyway, just in case.

Edit: Nope, still not rendering. This is really weird.

Edit2: I also debugged just to check if the three lights are in the Krypton's Lights list (just to check if I'm not adding the lights the right way). And all the 3 of them are there.

Jan 28, 2011 at 9:16 AM

I'm still confused. Clearly you have two lights in the picture above, but you're claiming to only see one now. What changed since then?

If we're going to be able to help you, we need to know how to reproduce the error. See if you can provide some guidance on how to reproduce the error for us, and we'll be glad to help out.

Until then, I have no idea either where to look for a bug, or help you fix things on your end. :)

Jan 28, 2011 at 9:21 AM

Are you sure you've re-imported a fresh KryptonEffect.fx into your project? That'd explain it working on the Testbed and not yours.

That caught me out once ;)

Jan 28, 2011 at 9:51 AM

@Xixonia. The picture above is not the error I'm having now :P The picture above is from the testbed when I found that only one light was casting shadows (this is already solved from the Light Opacity Discussion thread that Dindak mentioned before). Don't take into account this image. One minute, I'll upload an image of my current problem (I feel terrible, because I suspect the problem lies in my code, not in the engine) to show it better.

@thezombiecow Yes, I double checked, also caught me once :S

Jan 28, 2011 at 11:35 AM

Hi there :)

Here's an example. In my game, the main character casts a white light. Also there are two elevators, each one of them cast a yellow light. But only the main character's light is rendered:

If I don't add the main character's light to the engine, then only the light of the first elevator is rendered (the same happens if I change the main character's light isOn property to false):

I have no idea why. But as I said before, the testbed works well, so I think I'm missing something in my code.

Jan 28, 2011 at 2:37 PM

I solved it! I'm so happy :P

I was setting the rasterize state to CullNone before preparing the light map, but for some reason after the first light was drawn, the rasterize state went to null. So inside the LightMapPrepare() method, for each light I added the following line:

this.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

And now all the lights are correctly rendered :)

It's beautiful... I'm filled with love and happiness right now.

Jan 28, 2011 at 3:44 PM

This may have something to do with my design, after all...

It's quite possible that my cull modes in krypton are out of whack... I'll look into this, as I see this being a big problem. Thanks for the repro' info, and for diagnosing the problem :)

Jan 28, 2011 at 3:58 PM

No, no... thanks to you for the engine  :)

Jan 28, 2011 at 11:12 PM

Thanks for explaining your fix Pnikosis! Thankfully I read this before I had the issue today!

Jan 29, 2011 at 12:42 AM

Yeah, it's definitely a bug in the engine.

I believe the rasterizer state was unset because I'm setting the rasterizer state in the effect file. I'll be fixing that as soon as possible.

Jan 29, 2011 at 12:43 AM

what changeset are you guys using? which effect file?

Jan 29, 2011 at 8:05 PM

I was using the 2463, the effect file is the Krypton Effect one from that changeset :)

Jan 30, 2011 at 8:09 AM

Unfortunately , it went unmentioned in the change set notes, but I believe change set 2497 fixes the problem you've been having with the rasterizer state. Basically, you can tell Krypton which rasterizer state to use. It's essentially the same solution you came up with :)