Shaders implementation
Created by: vlag
I open this issue to keep a trace of some informations, and because we should discuss some point before fully implement shaders. This is also the last part to let the display fully handled by the GPU.
Since shader filter for the SDL_Texture's GL_TEXTURE_RECTANGLE_ARB encapsulation is implemented, I discovered some very interesting features and projects.
So firstly, we still need to support GL_TEXTURE_2D on the engine side too (GL ES seems to not support GL_ARB). I opened this thread on the SDL forum to be able to get the encapsulated texture type by the current SDL way (and then be sure that the specific code will never be broken). I opened it on the bug tracker too.
This also means that there is a hope to have a reliable shader abstraction on the user side. Here is some interesting projects to cross-compile shaders :
- MojoShader , currently used in Unity (mercurial).
- hlsl2glsl (fork) , was used in Unity 3.0 (github page).
- HLSLCrossCompiler.
- Angle , a GLSL to HLSL Cross compiler, used in SDL2.
On another hand, some projects like the Love2D framework use a few language abstraction for driver and sampler-specific calls. I don't know if it's reliable, especially to handle HLSL shaders, but it should be enough to write GL and GLES shaders without manually handle the driver, sampler and language version in the script, and then avoid some technical issues.
To finish, here is a GLSL optimizer, used in Unity too (github page).
I know shader implementation is not prioritary, especially not the user abstraction, so I just open this issue to not forget ;)
Edit : Point to clarify before going further with the shader system :
- Implement GLES and HLSL, or discuss about implementing an abstraction shader feature (probably a third party lib).
- How to pass Textures to the renderer (one render by layer to allow a different shader by layer, one render for the whole frame, one render for the map and another for the HUD) ?
- Parameters to share between engine and shader scripts (or make the shader class exportable to lua to let the decision to quest makers ?).
- How to handle shader files and structure (keep one big lua file or separate into 3 files, make shader class exportable to lua, still list shader files dynamically ?).