Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a shader compiler to support various OpenGL / Direct3D versions with a single source #52

Open
fasterthanlime opened this issue Jun 18, 2017 · 1 comment

Comments

@fasterthanlime
Copy link
Collaborator

See #49 (comment)

There's mostly hlsl-to-glsl compilers out there. Apparently Vulkan has its own thing, but it's always meant to be transpiled too? Input welcome.

@quyse
Copy link

quyse commented Jun 18, 2017

I use an C++ EDSL for shaders in my Inanity engine: I write a shader once in C++, and then it gets transformed at runtime to HLSL or GLSL text, taking into account whether various language features supported or not supported by graphics backend, including uniform buffers, attribute/draw instancing and so on. As an added benefit shaders can be constructed dynamically from pieces at runtime (i.e. ubershaders). See text rendering shaders for a simple example: link . This system worked very well so far for us in the Insatia game on Windows, Linux, macOS and even web (using OpenGL ES 2.0 aka WebGL with Emscripten).

Not sure if you'd really want to dive into my code though, but if you will I can help :) it's rather radical approach, the tech is quite experimental and there's no support for DX9 and Vulkan yet. Mentioning it here because as far as I know the majority of all serious engines use CG/HLSL->GLSL compiler or don't use any compiler at all, so I don't know any other widely used alternative to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants