Skip to main content

Shader Programming

Submitted by FireFrog on

Hey guys,

I'm looking at trying my hand at some shader programming and was wondering if anyone has some resources they could point me to that are fairly current. I've checked out some articles on gamedev.net but they were written in 2002 (like http://www.gamedev.net/reference/articles/article1496.asp) and I'm not sure how relevant they still are?

I'm currently a pretty confident programmer and I've done a bit of assembler so I'm not totally inexperienced, just looking for some resources people can recommend.

Thanks!

Submitted by richard on Sat, 02/12/06 - 8:15 AMPermalink

I've been messing around with OpenGL shaders (GLSL) for a few months now. It's fun :)

For references I've been using online tutorials and the orange "OpenGL Shading Language" book by Rost.

I do all my coding in Python* which makes the turn-around from editing source to testing really quick. There's also tools that will let you develop shaders in a GUI but I've not used them (I'm more of a text-mode kinda guy ;)

*: there's recipes in the pygame cookbook if you need examples

Submitted by redwyre on Sat, 02/12/06 - 6:14 PMPermalink

Well, this partly depends on if you want to use DirectX (HLSL) or OpenGL (GLSL or Cg). Personally I use HLSL and I created a small engine using XNA (C#) for the main purpose of playing with shaders :) There are a good amount of docs in the DirectX SDK on HLSL shaders and a few tutorials there as well. Unfortunately, it seems they've removed Effect Edit which allowed you to edit a shader and have it recompile on the fly, but it's not that difficult to write an app that does that for you :)

Submitted by Swiftless on Sun, 11/02/07 - 7:07 AMPermalink

I like to use GLSL because it goes with the whole syntax flow of OpenGL, which I find alot easier to code than Direct3D. I have started some GLSL tutorials on my site, but they are only basic ones and have been covered on many other sites. If you need a hand, give me a shout, I have done alot more than is on my website...

Submitted by axon on Wed, 30/05/07 - 10:51 AMPermalink

[QUOTE=redwyre]Personally I use HLSL and I created a small engine using XNA (C#) for the main purpose of playing with shaders :) There are a good amount of docs in the DirectX SDK on HLSL shaders and a few tutorials there as well.[/QUOTE]

ditto.

Grab yourself the DirectX SDK and the NVIDIA SDK (and the ATI SDK while you're at it). There are tons of examples (e.g. NVSDK10 has 20 DirectX samples and 13 OpenGL samples).

Have a look at the available shader development IDE's available from ATI and NVidia:
- Render Monkey from ATI
- FX Composer from NVidia

FX Composer 2 is about to be released (currently Beta 2 is available to registered developers and those fortunate enough to have made it to GDC2007 would already have had a play).

There's also a more visual tool you might find easier going which can export/import to FX Composer: Mental Mill

[EDIT]
Some links to shader related goodies:
http://developer.nvidia.com/page/opengl.html
http://developer.nvidia.com/page/directx.html
http://ati.amd.com/developer/index.html
http://ati.amd.com/developer/rendermonkey/index.html
[/EDIT]axon2007-05-30 00:53:58

Submitted by yosh64 on Sun, 04/01/09 - 3:48 PMPermalink

hey

If ya into GLSL ya might wanna checkout the OpenGL.org SDK, just a word of warning, although the Lighthouse3D tutorials are pretty cool, there are a couple of errors in the Lighting Tutorials that I seen.

I once tried to email them about it, but their inbox was full, to quote part of my email:


[quote]
The first issue came to my attention after I tried your point light shader, and found there was hardly any light on the walls when I was in a large corridor made of only a single box. I found that you seem only to compute the distance from the vertex to the light position, rather than from the fragment to the light position, used for calculating the light attenuation. So this eliminates one of the (what I think to be) great advantages of per fragment lighting, where the amount of vertices doesn't affect the appearance of light.

The other issue that came to my attention afting finding my point lights didn't seem right, is that you seem to make use of the gl_LightSource[i].halfVector built-in uniform varible in your point/spot light shader.

To be clear, I will just quote Chapter 9.2.2 Point Lights (page 237) of the Orange Book Second Edition, "There are two main differences between point lights and directional lights. First, with a point light source, the direction of maximum highlights must be computed at each vertex rather than with the precomputed value from gl_LightSource[i].halfVector.".

Thus, obviously the gl_LightSource[i].halfVector built-in uniform variable only stores the half vector of a directional light source, and not for a positional point/spot light where it would differ for each vertex. The fact that it's a uniform variable should ring a few alarm bells, hehe :).
[/quote]

Something else I found pretty cool is the parallax and relief bump mapping user submitted examples on codesampler.com, they are much more simple than ya would think, hehe. Hmm, ya might find the other samples handy also, but generally I only like to use these to learn and code things from scratch myself ;).

Also, the GLSL orange book is pretty handy, especially for picking up errors as I done with the LightHouse3D tutorials :).

cyas

Posted by FireFrog on

Hey guys,

I'm looking at trying my hand at some shader programming and was wondering if anyone has some resources they could point me to that are fairly current. I've checked out some articles on gamedev.net but they were written in 2002 (like http://www.gamedev.net/reference/articles/article1496.asp) and I'm not sure how relevant they still are?

I'm currently a pretty confident programmer and I've done a bit of assembler so I'm not totally inexperienced, just looking for some resources people can recommend.

Thanks!


Submitted by richard on Sat, 02/12/06 - 8:15 AMPermalink

I've been messing around with OpenGL shaders (GLSL) for a few months now. It's fun :)

For references I've been using online tutorials and the orange "OpenGL Shading Language" book by Rost.

I do all my coding in Python* which makes the turn-around from editing source to testing really quick. There's also tools that will let you develop shaders in a GUI but I've not used them (I'm more of a text-mode kinda guy ;)

*: there's recipes in the pygame cookbook if you need examples

Submitted by redwyre on Sat, 02/12/06 - 6:14 PMPermalink

Well, this partly depends on if you want to use DirectX (HLSL) or OpenGL (GLSL or Cg). Personally I use HLSL and I created a small engine using XNA (C#) for the main purpose of playing with shaders :) There are a good amount of docs in the DirectX SDK on HLSL shaders and a few tutorials there as well. Unfortunately, it seems they've removed Effect Edit which allowed you to edit a shader and have it recompile on the fly, but it's not that difficult to write an app that does that for you :)

Submitted by Swiftless on Sun, 11/02/07 - 7:07 AMPermalink

I like to use GLSL because it goes with the whole syntax flow of OpenGL, which I find alot easier to code than Direct3D. I have started some GLSL tutorials on my site, but they are only basic ones and have been covered on many other sites. If you need a hand, give me a shout, I have done alot more than is on my website...

Submitted by axon on Wed, 30/05/07 - 10:51 AMPermalink

[QUOTE=redwyre]Personally I use HLSL and I created a small engine using XNA (C#) for the main purpose of playing with shaders :) There are a good amount of docs in the DirectX SDK on HLSL shaders and a few tutorials there as well.[/QUOTE]

ditto.

Grab yourself the DirectX SDK and the NVIDIA SDK (and the ATI SDK while you're at it). There are tons of examples (e.g. NVSDK10 has 20 DirectX samples and 13 OpenGL samples).

Have a look at the available shader development IDE's available from ATI and NVidia:
- Render Monkey from ATI
- FX Composer from NVidia

FX Composer 2 is about to be released (currently Beta 2 is available to registered developers and those fortunate enough to have made it to GDC2007 would already have had a play).

There's also a more visual tool you might find easier going which can export/import to FX Composer: Mental Mill

[EDIT]
Some links to shader related goodies:
http://developer.nvidia.com/page/opengl.html
http://developer.nvidia.com/page/directx.html
http://ati.amd.com/developer/index.html
http://ati.amd.com/developer/rendermonkey/index.html
[/EDIT]axon2007-05-30 00:53:58

Submitted by yosh64 on Sun, 04/01/09 - 3:48 PMPermalink

hey

If ya into GLSL ya might wanna checkout the OpenGL.org SDK, just a word of warning, although the Lighthouse3D tutorials are pretty cool, there are a couple of errors in the Lighting Tutorials that I seen.

I once tried to email them about it, but their inbox was full, to quote part of my email:


[quote]
The first issue came to my attention after I tried your point light shader, and found there was hardly any light on the walls when I was in a large corridor made of only a single box. I found that you seem only to compute the distance from the vertex to the light position, rather than from the fragment to the light position, used for calculating the light attenuation. So this eliminates one of the (what I think to be) great advantages of per fragment lighting, where the amount of vertices doesn't affect the appearance of light.

The other issue that came to my attention afting finding my point lights didn't seem right, is that you seem to make use of the gl_LightSource[i].halfVector built-in uniform varible in your point/spot light shader.

To be clear, I will just quote Chapter 9.2.2 Point Lights (page 237) of the Orange Book Second Edition, "There are two main differences between point lights and directional lights. First, with a point light source, the direction of maximum highlights must be computed at each vertex rather than with the precomputed value from gl_LightSource[i].halfVector.".

Thus, obviously the gl_LightSource[i].halfVector built-in uniform variable only stores the half vector of a directional light source, and not for a positional point/spot light where it would differ for each vertex. The fact that it's a uniform variable should ring a few alarm bells, hehe :).
[/quote]

Something else I found pretty cool is the parallax and relief bump mapping user submitted examples on codesampler.com, they are much more simple than ya would think, hehe. Hmm, ya might find the other samples handy also, but generally I only like to use these to learn and code things from scratch myself ;).

Also, the GLSL orange book is pretty handy, especially for picking up errors as I done with the LightHouse3D tutorials :).

cyas