HLSL2GLSL
My plan from the start was to use a converter to get my HLSL shaders to GLSL on the OpenGL version of Gateway…
I was going to achieve this by using hlsl2glsl, but after fumbling around it for a bit, I don’t think I can use it without breaking much more stuff than it’s worth:
The image above is a very simple HLSL shader converted to HLSL… It works fine, but the image was supposed to be colored and textured…
This particular problem seems to stem from the fact that DirectX/HLSL has very rigid rules regarding input registers (vertex declaration), but OpenGL doesn’t seem to have that, so HLSL ends up lacking the expression power require for it… I could circumvent this by after building the shader seeing where I have to bind the stuff, but in my current system that would be very inefficient…
Another issue is the fact that HLSL2GLSL only goes up to OpenGL 3.0 shaders (and even that seems a bit broken)… Although I’m not using more sophisticated stuff than SM 3.0, I don’t want to create something that will have to be replaced in the future for something more powerful…
So I have 3 options: try out Unknown World’s hlslparser, build my own or just write the shaders in GLSL, and build a preprocessor to suit my needs (on Cantrip that would be simple, but on Spellbook I have quite complex syntax that gets pre-parsed to make runtime shaders), and run it through GLSL Optimizer (especially to remove dead code, since I generate a lot of it on my über-shaders). GLSL Optimizer might have the same problem as HLSL2GLSL, though…
It’s weird for me that the GLSL compiler seems to be so “weak”, compared to the HLSL one, especially considering the importance that shaders have nowadays and the evolution of compiler technology in the last 10 to 15 years.
Anyway, need to decide which of these approaches is the best, not only for Gateway and Cantrip, but also for Grey and Spellbook (since the OpenGL path will be used there as well).
Writing the shaders on GLSL doesn’t seem to be terrible, considering that when I have this code path, I’ll probably will use it more often than the DirectX 9.0 one (it’s becoming too old, it’s not cross-platform), although I’ll miss stuff like Pix (I think there’s equivalent tools for OpenGL though), and the fact that the API is (for me) better…
Now listening to “Illumination” by “Tristania”
Comment
You must be logged in to post a comment.