Defining your own functions in shader languages can be very useful. They allow you to reuse code to minimize code duplication, and make it easier to organize your code! For example, if you're writing a lighting shader, you could put the lighting code in a function and call the function multiple times to support more than one light. Bonus content: how to create a color inversion shader.
I did this demo in GLSL ES, but shader functions work the same way in HLSL. In general, both languages are very C-like.
A similar video on shader macros:
https://youtu.be/yp0EhCdITo4
The code:
https://github.com/DragoniteSpam-GameMaker-Tutorials/TutorialShaderFunctions
Shader playlist:
https://www.youtube.com/playlist?list=PL_hT--4HOvrdkihto8Xu7hhp1-5Gj8zsa
GameMaker 3D playlist:
https://www.youtube.com/playlist?list=PL_hT--4HOvrcML9uqHe4fwBVTm650Vy3V
GameMaker Studio 2 playlist:
https://www.youtube.com/playlist?list=PL_hT--4HOvrdAGC6YHCqn_VR69GlR_rQw
#GameMaker
#GameMakerShaders
#GameMakerShaderFunctions
- - - - -
I've now made that Patreon:
https://www.patreon.com/wizardragon
That promised social media link spam.
https://twitter.com/DragoniteSpam
Transition / idle music is by my old friend Kamex:
https://www.youtube.com/user/GreatGabite/about
Rate, comment, subscribe, watch more, enjoy!