Issue #1241 wontfix
created an issue

LÖVE has its own shader language which is basically GLSL.

We must give effect(...) and position(...) to create a shader.

Why not just use the exact same syntax of GLSL with "void main()"? I found that gl_Position can be set in position(...).

Developers with former GLSL programming experience can easily use this feature.

We can leave the original API untouched.

Comments (4)

  1. Alex Szpakowski

    void main()

    I already plan to allow something like this, partly for issue #1111 (and for a few other things). However there are a few things that are calculated inside the shader or use an alternative to built-in GLSL functionality. LÖVE also uses several of its own vertex attribute inputs and uniform variables. Therefore telling people that they can just "write GLSL" and have them expect it to work both in LÖVE and outside of LÖVE is just not something that will happen (other frameworks and engines behave the same way as LÖVE in this respect).

    For example, the coordinate of the current pixel on-screen (the last parameter to effect()) is partially calculated in the shader code by LÖVE just before effect() is called. This is because gl_FragCoord is inverted depending on whether you're rendering to a canvas or not, due to the way LÖVE works around OpenGL's coordinates being y-up compared to its own y-down coordinate system.

    Similarly, the color available in the pixel and vertex shaders (first parameter in effect()) is also partially calculated in the vertex shader code – it's the result of ConstantColor * gammaCorrectColor(VertexColor) – two color vertex attributes that contain different colors in different sRGB encodings.

    Additionally, there are some features that require some abstraction in order to work the same in both older GLSL (e.g. 1.20, which LÖVE currently uses on desktops) and newer GLSL (e.g. 3.30, which LÖVE will in the future use when available on desktops). The Texel function and the love_Canvases array in pixel shaders are some examples of those abstractions that will become more important once modern GLSL versions are available in LÖVE.

  2. Bart van Strien

    I think it's just providing people an invitation to shoot themselves in the foot. As slime said, the "user glsl" does not run in a vacuum. The sometimes-inverted y coordinate is one of the issues you could easily run into.

    Since it's (imo) fairly easy to convert a shader, there's only a small downside to our extensions, and a much larger upside.

  3. Log in to comment