Page 1 of 1

Using GLSL instead of LÖVEs shading language?

Posted: Mon Aug 18, 2014 7:20 pm
by Eamonn
I hate LÖVEs shading language with a passion. Yes, I know underneath it's GLSL, but GLSL:

• Makes much more sense
• Is more beginner friendly
• Is standard
• Is easier to use
• Is fun

Is it possible for me to just use GLSL and save myself the pain of using the LÖVE shading language? I really hate it. GLSL is fun, LÖVE is fun, this shading language... not so much. Why does LÖVE use it's own shading language, anyway? Is there a special reason?

Thanks! :D

Re: Using GLSL instead of LÖVEs shading language?

Posted: Mon Aug 18, 2014 7:26 pm
by bartbes
Underneath it's glsl? It is glsl, it only has a different entry point. I'm not sure what you're complaining about here.
Nevertheless, it's easy, but undocumented, though found on the forums (here): override love.graphics._shaderCodeToGLSL.

Re: Using GLSL instead of LÖVEs shading language?

Posted: Mon Aug 18, 2014 7:51 pm
by Eamonn
It has different names, too. I just really don't like it, and I'd much prefer use GLSL. Thanks! :D

Re: Using GLSL instead of LÖVEs shading language?

Posted: Mon Aug 18, 2014 8:02 pm
by slime
The different names are aliases, they don't replace/remove GLSL's names. You can write "pure GLSL" in LÖVE natively, as long as you use the 'effect' entry point for pixel shaders (and the 'position' entry point for vertex shaders.)

For example, this function will compile in WebGL, GLSL 1.10, GLSL 1.20, GLSL ES 1.00, and LÖVE 0.8 - 0.10 (although if you use WebGL or raw OpenGL/OpenGL ES then you will need to call the function from 'main'):

Code: Select all

vec4 effect(vec4 vcolor, sampler2D tex, vec2 tex_coords, vec2 pixel_coords)
{
    float alpha = texture2D(tex, tex_coords).a;
    vcolor.a *= alpha;
    return vcolor;
}
However I do recommend using the 'Texel' function instead of 'texture2D' for future portability to different versions of GLSL, since 'texture2D' doesn't exist in GLSL 1.40+ or GLSL ES 3.00+, whereas 'Texel' can always be aliased to the correct function automatically by LÖVE.

If you try to use third-party GLSL code which uses built in fixed-function compatibility variables from old versions of GLSL (for example gl_Vertex or gl_ModelViewProjectionMatrix) it may not work, because LÖVE doesn't necessarily use the deprecated OpenGL codepaths necessary for those things to work. They only existed to make it easier for programs transitioning from OpenGL 1 to OpenGL 2 to use shaders, and they don't exist at all in later versions of OpenGL / GLSL, or in any version of OpenGL ES.

Re: Using GLSL instead of LÖVEs shading language?

Posted: Tue Aug 26, 2014 9:00 am
by Zilarrezko
Frankly I can't get either to work. I've even just copy and pasted code and that still shoots out nothing.

Re: Using GLSL instead of LÖVEs shading language?

Posted: Tue Aug 26, 2014 10:28 am
by Jeeper
Zilarrezko wrote:Frankly I can't get either to work. I've even just copy and pasted code and that still shoots out nothing.
A tip would be to provide us with a .love, then we will be able to do more for you than just say "ok". ^^

I have used shaders in almost every game I have made and so far not had any issue.