Need some good resources for teaching myself GLSL shaders?

I’ve been browsing around trying to find some good tutorials/intros on GLSL shaders (both fragment and vertex) and although there is plenty of material around, it is also somewhat… lackluster?`

The tutorials/intros I find are either:
-Too short/simple, ending after you’ve created a simple gradient in a fragment shader
or.
-Way too complex for me, packed with OpenGL/C++ gibberish without explaining much about the stuff they write about. I don’t know how long it took before I finally found a site that explained that Uniforms are outside variables sent to the shader - to name one example.

I’ve also looked at online shader tools, such as shdr.bkcore.com, glslsandbox.com, shadertoy.com and maybe I’m picky here but these seem lackluster as well? The latter two only supports pixel shaders for example - and the former has no support for textures. Maybe I’m not giving these a fair chance - I have after all only scratched the surface of this.

I’ve also looked at node-based editors, such as ShaderFX in Maya. Problem there is that the code output is dirty/bloated, as a colleague and other TA explained to me. He basicly opened up the code in a text editor and removed big chunks of code saying: this is all you “actually” need - the things I removed is just crap.

I need a good, pedagogic approach here where I get to try out shader programming myself. I need some sources that are thourough yet not overly complicated because I’m still learning the lingo. Suggestions?

1 Like

this is an excellent resource

Shader Production: Writing Custom Shaders with CGFX
http://eat3d.com/shaders_intro

Even though it’s CGFX, you can pretty much apply the examples to HLSL and GLSL.

You can explore OpenGL through the Python OpenGL module and Pyqt. Qt actually comes with a few useful shortcuts and resources for OpenGL. I’ve had success with it, but it’s far more complicated than using say Maya’s shaderFX or Unity’s surface shaders to explore what you need to. I would only recommend starting from OpenGL/Python(or C++) if you had a need to write a custom 3D viewer or wanted to get a better understanding of how it all works on a technical level. It requires implement everything from the camera to loading textures and models from scratch, so shaders are just one part of it.

Hey guys, sry for the late reply.
That eat3d tutorial looks awesome - I think that looks like a solid starting point.
Also, exploring OpenGL through Python sounds awesome. The reason I want to understand shaders on a more fundamental lever are the fact that all those node-based editors (like Maya’s shaderFX) creates a lot of garbage code that really isn’t needed. But maybe it’s a bad idea to jump into that right away.

i don’t advise using node-based editors to learn code - because yes, they produce a lot of boilerplate code that is just obscuring what you really need to know.
node based editors are good for fast prototyping, and then translating the network into code - but the code that is generated itself is not really helpful IMO.

[QUOTE=rgkovach123;29680]i don’t advise using node-based editors to learn code - because yes, they produce a lot of boilerplate code that is just obscuring what you really need to know.[/QUOTE]

This is also why Unity’s surface shaders would be one of the easier starting points; the boilerplate code for all the engine hooks is very small. A lot of the complexity is out of sight. Need to be aware though that some of the syntax and shortcuts will not carry over outside of Unity.

[QUOTE=Nightshade;29679]Also, exploring OpenGL through Python sounds awesome. The reason I want to understand shaders on a more fundamental level are the fact that all those node-based editors (like Maya’s shaderFX) creates a lot of garbage code that really isn’t needed.[/QUOTE]
That really depends on what you’re trying to acomplish with the shader. A lot of that so-called garbage is in there to mantain support for Maya’s specfic rendering features and UI conventions. There’s no reason you have to keep it though; try gutting the Hw Material Base Autodesk provides or better yet, create your own lightweight shader pass. Do that and you can output some pretty lite code. Not Unity lite, but still fairly basic as far as Maya’s requirements go.

ShaderFX is never going generate clean or concise code, but if you intend to pre-compile it (and you should), the final result will not be human readable anyways. I’ve found it to be a pretty invaluable tool, but it’s probably not going to teach you how to read shader code or write in glsl, hlsl, cgfx, etc.

Even if is totally code-based… I would suggest you “rendermonkey”.
It’s a great tool to start coding GLSL plus the basic samples that come with it helped me A LOT! :D:

Unity was (back in the day) a great tool for learning GLSL too…
but nowadays they’re putting a lot of effor in order to get rid of it and keep the CG only…
:_(

[QUOTE=Marc;29771]Even if is totally code-based… I would suggest you “rendermonkey”.
It’s a great tool to start coding GLSL plus the basic samples that come with it helped me A LOT! :D:

Unity was (back in the day) a great tool for learning GLSL too…
but nowadays they’re putting a lot of effor in order to get rid of it and keep the CG only…
:_([/QUOTE]

That looks really cool.
Another TA at my job also recommende ShaderTool on Steam: ShaderTool on Steam
Have you tried that one?

this site is pretty badass…

Thanks for the plug! I’m always up on slack if you have any questions. The video was done before the PBR math was standard, but all of the principles still work. The only addition is the energy conservation stuff that PBR adds.

[QUOTE=Nightshade;29835]That looks really cool.
Another TA at my job also recommende ShaderTool on Steam: ShaderTool on Steam
Have you tried that one?[/QUOTE]

Nope, sorry :stuck_out_tongue:

I’m currently helping another technical artist with his firsts steps with shaders. Due his programming background is not solid enough I suggested him to start with GLSL (instead of HLSL or CG).
For that purpose we’re using indeed rendermonkey. It’s the most straight forward IMO.

cheers!

hehe yeah… Shadertoy is simply superb!

But I would avoid using it to teach GLSL because it’s using some custom built-in functions.
Besides, If I’m not mistaking… you can program only the fragment part of the shader