0
\$\begingroup\$

I am trying to create a 2D lighting map.

For each light source I have an Color[,] with size less than whole map and a coordinate of center. There can be many light sources and they can intersect (2 or more, so I can't just sum it).

I need to blend all light colors for every map pixel, not override.

Is there a better approach other than to loop over every light for each map pixel, get colors and mix them?

\$\endgroup\$
  • \$\begingroup\$ Is that needed for offline computation, or directly rendered each frame? \$\endgroup\$ – Vlad Nov 24 at 9:45
  • \$\begingroup\$ @Vlad Almost every frame. Only when light source moves. And I draw it on texture, not render it. \$\endgroup\$ – ArtyGrand Nov 24 at 10:00
  • \$\begingroup\$ This sounds ripe for parallelizing on the GPU if you're able: using a RenderTexture the size of your map, and rendering quads onto it for each region of light. Typically light combines additively, so I'm not sure what you have in mind for the combination if not a sum. Can you show us an example? \$\endgroup\$ – DMGregory Nov 24 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.