PDA

View Full Version : Easy GLSL tutorial?



Darkhog
06-07-2013, 05:21 PM
I know literally NOTHING about writing shaders. I want to learn GLSL, but all tutorials I could find either assume some knowledge of it or are "beginner" tutorial that talks about pipelines and whatnot and in turn confuses me even more. Do you know any easy to understand tutorials that could help me learn it? Mainly graphic effects such as blur, dof, reflections, etc. but also I'm interested in OpenCL.

Rodrigo Robles
07-07-2013, 06:45 PM
I'm noobie about shaders too. I started reading the OpenGL Orange Book, it's focused in shaders and is really didatic.

User137
08-07-2013, 09:43 PM
Mainly graphic effects such as blur, dof, reflections, etc. but also I'm interested in OpenCL.
That is like as asking tutorials for multithreading and interfaces when you haven't done a simple "hello world" yet. Those effects are not from the easy end. There are many tutorials which give ready source code in them, and language shouldn't really matter. All you need to see in them is how and where OpenGL commands are called, and what shader code does. This is one of them:
http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_03
There is also some, bit outdated but mostly still valid guides and codes:
http://www.lighthouse3d.com/tutorials/glsl-tutorial/setup-for-glsl-example/

The way GL programs and shader sources are used and built, has not changed when going from OpenGL 2 to 3.

phibermon
08-07-2013, 10:56 PM
Some info that's not always apparent when learning how shaders sit in the rendering pipeline :

Shaders can work within the context of the geometry you're rendering, so they're acting upon 3D models for example. Perhaps rendering directly to the screen.

They can also used in a deferred manner, so you render your scene to a texture in the first pass, then you render a quad with that texture applied with pixel shaders acting upon that. it's still the same as the first example, you're rendering geometry (a quad) and shaders are applied, but this setup is intended for full-screen effects such as blur, being applied to what you rendered in the first pass.

Of course it doesn't matter what you texture the quad with, be it a normal texture or a 3D scene rendered to a texture. It's a very flexible setup and leads to much confusion to those learning about shaders. There are many ways to achieve a desired output, some fast, some slower. There's no 'right' way as such. Take this into account as you read tutorials that seem to be setup very differently from each other, whatever works for you / fits your coding style is fine. Don't worry about getting top performance to begin with.