• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

What can be done with GLSL extension directives?

Juju

Member
GameMaker's standard implementation of GLSL ES version 1.00rev17 leaves out some functionality that is commonly used in graphics programming. Fortunately, we can access some of these features by using GLSL's #extension directive.

Here're two examples that demonstrate how to enable two particularly useful extensions. (Bear in mind that I've tested these on Windows but not other platforms.)

GL_EXT_frag_depth, which enables per-pixel depth setting (gl_FragDepthEXT):
https://github.com/JujuAdams/gl_FragDepthEXT

GL_OES_standard_derivatives, which enables derivative functions (dFdx/dFdy/fwidth):
https://github.com/JujuAdams/GL_OES_standard_derivatives

I'm hardly the first person to demonstrate this extension directive functionality, but beyond these two extensions, I don't really know what other extensions are available and what they can do. There's an extension registry here and a GitHub repo for Angle (the OGL-to-DX transpiler GM uses) here but that's a lot of information to wade through. Anyone have any suggestions?
 
Last edited:

Juju

Member
Tried vertex texture fetch in HLSL and had no luck, I suspect because GM isn't binding the necessary sampler(s) to the vertex shader. I'll try again in GLSL ES, though I don't hold out much hope.

The EXT_multiview_draw_buffers spec says it's written against ES 2.x but we might get lucky there.
 
Last edited:

Xor

@XorDev
Has anybody been able to get any other GLSL ES extensions to work? GLSL ES MRTs would change a lot!
 

Bart

WiseBart
Not sure if it's possible to use that MRT extension just because of how everything works in the background.

For MRTs, gl_FragData is used instead of gl_FragColor and, according to the spec, it's initialized using the value of gl_MaxDrawBuffers:
Code:
mediump vec4 gl_FragData[gl_MaxDrawBuffers];
That gl_MaxDrawBuffers variable is a built-in constant:
Code:
const mediump int gl_MaxDrawBuffers = 1;
The value of gl_MaxDrawBuffers does appear to be equal to 1.
I tried redefining it in the vertex shader but it seems like every definition of a variable prefixed with gl_ throws a compiler error.

I do hope there is a way, though :)
 
  • Like
Reactions: Xor
Top