Fast 2D illumination algorithm?

筅森魡賤 提交于 2019-12-05 09:22:49

Just a stab in the dark: have you looked into (GPU-accelerated) photon mapping?

You can reduce the running time of a similar algorithm quadratically (eg. skip every 2nd x and y) by losing quality linearly (image gets half diameter and resample back to same size).

Use a bitmap to store luminosity, and render on a lower size bitmap (divide by aproximation factor) all your points lines atc (but divide all point by the aproximation factor too) then use gaussian blur and resample back to desired size. Then extract luminosity from pixels.

I uploaded a video on youtube showing the run of a test i did code to try if that could work. It seems omething similar to what you require (doing it with 'almost real time' on a single thread):

Link to Video

Of course here walls are lines with transparency properties, and light does not diffuse as you would expect but linearly, but the "approximation" should be usable by your algorithm, or you can adapt this one if speed is enough. And beware code is written very badly because I was merely experimenting.

Here luminosity is normalized, you would probably go with embedding luminosity in a logarithmic scale into pixels, so you can fit a greater range, to preserve original values.

Is you can use it for something: Here is the project:

Link to project

If you optimize and thread it, probably 100ms for a 1000x1000 image with 100 lights with diameter 300 and like 20 walls of lenght 200, with aproximation of 5 is achievable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!