Updated GLSL shaders (markdown => mediawiki)

markwkidd 2017-09-12 02:03:45 -04:00
parent e8ff6ec1b3
commit 67f549c706
2 changed files with 1 additions and 35 deletions

@ -1,35 +0,0 @@
## Purpose
GLSL shader support exists to be compatible in case [[Cg shaders]] cannot be supported, which is the case for OpenGL ES, and EGL contexts ([[KMS mode]] in Linux for one).
Like Cg shaders, GLSL shaders represent a single pass, and requires a preset file to describe how multiple shaders are combined. The extension is .glsl. The internal format of the shaders are the same as modern [[XML shaders]].
As GLSL shaders are normally placed in two different files (vertex, fragment), making it very impractical to select in a menu. This is worked around by using compiler defines in order to be equivalent to Cg shaders.
### Example GLSL shader
varying vec2 tex_coord;
#if defined(VERTEX)
attribute vec2 TexCoord;
attribute vec2 VertexCoord;
uniform mat4 MVPMatrix;
void main()
{
gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);
tex_coord = TexCoord;
}
#elif defined(FRAGMENT)
uniform sampler2D Texture;
void main()
{
gl_FragColor = texture2D(Texture, tex_coord);
}
#endif
GLSL shaders must be modern style, and using `ruby` prefix is discouraged.
## Converting from Cg shaders
GLSL shaders are mostly considered a compatibility format. It is possible to compile Cg shaders into GLSL shaders automatically using our `cg2glsl` script found [here](https://github.com/Themaister/RetroArch/blob/master/tools/cg2glsl.py). It can convert single shaders as well as batch conversion.
It relies on nVidia's `cgc` tool found in `nvidia-cg-toolkit` package.
## GLSL preset
Like [[Cg shaders]], there is a preset format. Instead of .cgp extension, .glslp extension is used. The format is exactly the same, just replace .cg shaders with .glsl. To convert a .cgp preset, rename to .glslp and replace all references to .cg shaders with .glsl.

1
GLSL-shaders.mediawiki Normal file

@ -0,0 +1 @@
This doc is now part of [https://github.com/libretro/docs libretro-docs] and can be viewed here: https://github.com/libretro/docs