To have better texture2D quality in my 2D game, I had to recreate every textures with 300% of their original size. But the lights have to bright 3 times more.

For lights, I'm using this : Catalin's blog

I have to render some lights, but with only 1 with 800 pixels of radius, my game works with around 15fps or less. And if I improve the light quality, I have an issue with the (gpu ?) memory.

How must I do to render a light with 800 pixels of radius without this gpu cost ?
Should I use another effect ? Do you have some to suggest ?
(example : Andrew Russell's game : "Dark" has a lots of big lights, and the game works perfectly)
Hope you can help.

  • 3
    \$\begingroup\$ You've inspired me to write an answer (which will probably become a blog post as well) describing the optimisations that I implemented in Dark. it is an interesting topic, because there are many optimisations involved, which (fair warning) took a lot of work. Even though I use a completely different shadow method to Catalin, most of the optimisation should still be helpful. But you'll have to wait for a short while, because it will take a few days before I can post it. \$\endgroup\$ Feb 19, 2013 at 13:52
  • \$\begingroup\$ @AndrewRussell I have to say it's thanks to you that I'm develloping my vidéo game for a year. You advised me to use C# + xna and inspired me a lot with your game "Dark". Thanks again Andrew. Hope I'll finish my project \$\endgroup\$
    – Sharpnel
    Feb 19, 2013 at 14:09
  • \$\begingroup\$ @AndrewRussell What I wanted to say is : I'm so affraid to fail after all I've done, I'm pretty sure that your light optimisations will be very usefull for a lot of people, including me, ofc. I'll be patient ^^ Thx for all your time and work. \$\endgroup\$
    – Sharpnel
    Feb 19, 2013 at 17:00

2 Answers 2


As promised, I have written a very long article about how I optimised the shadow renderer in my game "Dark".

(source: andrewrussell.net)

My article goes into a lot of detail, reaching a whopping 2500 words, plus illustrations, so I won't repost it here. But I will give a quick overview:

There are two major things that I had to optimise, for Dark: First of all, my fill-rate. Each light requires drawing over large areas of the screen. And second of all, the number of batches I was sending to the GPU - as every light must redraw the level geometry in order to cast shadows against it.

The major techniques I used were scissor rectangles, and culling respectively. Although merging static geometry would have been better, for the latter. More interesting, however, is the tricky ways that I made use of these techniques to squeeze out even more performance and get more lights into my levels.

But the he most vitally important thing that I describe in my article is the measuring that I did to assess the performance impact of particular things, determining what measurement constituted the "limit" for that thing, and then figuring out how to bring that thing in under that limit.

(Speaking of performance limits, I have an answer over here that lists many of the limits you will come up against when doing graphics programming and game development.)

I really hope that helps :)


Consider doing lighting with much lower resolution images instead of the ones you render in the scene. You can use a 32x32 version of a 128x128 image so long as it properly approximates the shapes in the larger source image. You don't need lighting to match rendered shapes exactly, just approximate it closely enough to look good. Same goes for physics and picking and so on.

You can also render the lighting into a small buffer even and "stretch" (magnify) the lighting texture when you render. It'll cause some artifacts, but very likely (if you pick a good size) it'll look fine.

  • \$\begingroup\$ if I want to generate the light and shadow layer in a smaller buffer (2 times smaller), I have to divide the lights position by 2, divide the objects position by 2, divide by 2 every textures am I right ? \$\endgroup\$
    – Sharpnel
    Feb 19, 2013 at 13:08
  • \$\begingroup\$ depends on how you do you rendering, but probably. This can be cheaply done on the GPU in the vertex shader. \$\endgroup\$ Feb 19, 2013 at 16:02
  • \$\begingroup\$ I'm waiting for Andrew Russell's answer because his lighting is exactly what I seek, hoping I'll find what I seek for optimisations. Thx for your participating Sean \$\endgroup\$
    – Sharpnel
    Feb 19, 2013 at 18:29

You must log in to answer this question.

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