GL Shader Working in the Editor!

Hey Folks! Those of you following my Twitter account (@dcfedor) may have already seen hints of this, but it appears I've got the OpenGL lighting shader working in the ship editor!

IMAGE(http://bluebottlegames.com/img/screenshots/screenshot-2015-11-26.jpg) "Working"

Above, I've split the screenshot down the middle with flat-shaded HaxeFlixel sprites on the left, and the OpenGL normal-mapped shader sprites on the right. Essentially, the right side is a 3D scene with a dynamic light near the mouse and ambient light everywhere else.

I can place and remove prefabs, and both the HaxeFlixel and OpenGL sprites will add/remove to the scene accordingly. And I've even hooked up the OpenGL view matrix to the WASD scrolling in the editor, so both will scroll the same amounts, keeping things lined-up. Looks pretty neat so far!

For anyone interested, a simple HaxeFlixel project source code to do this can be found here.

However, it's not without its flaws.

For one thing, you can see that the z-sorting is wrong, so some sub-structure stuff appears above the floor, and walls are hidden by sub-structure, etc. Weird that this is an issue in the 3D scene, but I think I may have the depth-sorting feature turned-off. So this may be solvable via a simple switch (since each prefab has a z-value already for layer-hiding purposes, and I can just use this).

Secondly, performance is a bit rough. I'm getting maybe 21fps with debug code on Windows in this scene. And this scene is probably a bit simpler than the final scene complexity I'm picturing. Now, performance is usually slow at first in a project, and I have a lot to learn about optimization. But this was the best I could get with quick optimizations to the code. "Release" mode in windows is 60fps, so that's encouraging. But it'll dip down into the 40s with just a few dozen more parts on-screen. I might have to learn a lot more about OpenGL to make this work, or else explore the OpenFL implementation of GL to see if I can leverage that instead. (My code kind of bypasses the "right" way to do things in OpenFL.)

Thirdly, this nice-looking lighting ignores shadows. Nothing is in place yet for walls blocking light. There are ways to do this, and with this shader framework in place, it might be doable. But again, not there yet.

Finally, while it looks nice, I'm not sure if it looks that nice. The subtle shading is pretty, but I was expecting more highlights on the walls. This could be down to the way I hand-drew the normal maps, since they have razor-thin "edges" drawn-in.

It's progress, but it'll warrant some careful consideration of the pros vs. cons.

Oh, and Happy Thanksgiving, all!