I am currently writing a raycaster based on this article, here, however when implemented in OpenFL, I get horrendous performance, or a crash. The code is available in this gist, here. I understand that software rendering is slow, pixel manipulation more-so, but how can I optimize this to achieve a playable performance?
I have implemented the same code in Kha as well, with “better” performance, I guess.
It’s done by using a similar method; getting and setting pixels of an Image which is then drawn. Performance is not terrible, when run on HTML5. How could I speed this up, or what’s the hardware accelerated alternative?
The best solution would be to directly apply your bitmap rectangle texture to a polygon mesh (composed of 2 triangles for each of your walls) by directly accessing openGL. That way all the computation would be performed by your GPU.
Using lime.graphics.opengl and lime.graphics.GLRenderContext you can probably achieve what you want but you probably would have to write your own ‘DisplayObject’ class as I don’t think the openfl Sprite or Bitmap class directly expose their GL context object…
Perhaps there is a way to adapt the code into something that would use OpenGL 3D acceleration for the rendering, rather than software. I found this online, which looks similar, although the draw calls are desktop GL, and not GLES-style calls like we use in Lime or OpenGLView