• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Default vertex & fragment shader when lighting is used?

Hi. I'm wondering what default glsl scripts are used when you are drawing things in 3d and are using lights.

I've been trying to make my own but I cannot for the life of me figure out how to use any of the gl_* variables provided (bar a few such as gl_Fragcoord and gl_Position), as most of my suspected uses of them throw shader compile errors, and there is no good information online about this or in the documentation, apart from the one breadcrumb of MAX_VS_LIGHTS, and if I do find any information, it still throws an error (like with gl_LightSource[0] or gl_FrontColor).

It would be great if in the future we got more documentation of how all the variables that are available in-editor are used.
 
So that helps somewhat, however the results I get from the linked scripts (as well as just copy-pasting the code from the common shaders I found) resulted in incorrect results, most notably that the object normals needed to be inverted for directional lights (technically inverted for point lights actually, since they're inverted when they're set??). While my small fixes ""work"", there are some things that are off, like point light intensity having differences.
That post (and others linked to it) still don't really answer my questions of "Why have all these gl_* variables highlighted if you can't use them?", as well as "Why is none of this properly documented and usable?", as well as my new question of "Why have these functions and variables squirreled away and not highlighted by the code editor if they are integral to making lighting work with shaders?"
 

icuurd12b42

TMC Founder
GMC Elder
that inversion of normals is covered in one of the code, like the last one... when we were done with the topic the only thing left was to pass your own uniform mirroring the d3d_set_lighting setting which would not propagate to the shader, forcing me to pass my own... the uniform also had to be a float because gm would not pass a bool as uniform (inf act only float types seem to pass through).
 
What? I don't understand what you're saying.

The code provided in those posts do not work correctly, the shading created is completely off to how GMS2 generates it when a shader is not set. In fact, the lighting created from using the default DoLighting function isn't even accurate or correct to how the lighting looks shaderless either, despite the fact that it should be running the same code, shader or no.

This is around the time I'd just write my own system and shader for lights rather than using the one that Gamemaker Studio 2 provides but I can't really do that since almost all of the gl_ variables throw out unhelpful assignment errors when used in pretty much any context anyway, and I can't seem to pass any of the gm_Lights arrays through a varying (throws another unhelpful assignment error).
 
Top