Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The last time I tried learning HLSL, I made a few shaders and mostly understood what I was doing, but I still felt like I was stumbling in the dark. Most of what I learned I got from various blog posts that didn't explain things very well.

Also, the documentation on MSDN seems to be more of a function reference.

Where can I learn to not only write HLSL, but learn techniques for writing shaders?

share|improve this question
add comment

12 Answers

Those two noted, I consistently come back to the following article almost every time I write a generic shader:

share|improve this answer
    
And I should specify that by "API reference" I mean more the "Programming Guide" section. –  Sean James Jul 19 '10 at 17:16
add comment

If what you are after is "shader technique", rather than mere language reference (read the question, people), I recommend (from easy to advanced):

And basically either: Try things out and practice, all while absorbing how the "pros" do things. Or pick and choose things that are similar to what you're trying to achieve and work from there.

share|improve this answer
add comment

Cg is not technically HLSL, but syntactically they are virtually identical.

Having said that, it's an older book, but NVIDIA has made "The Cg Tutorial" free to read online. It covers the basics of the programmable pipeline in a very comprehensive fashion, and it should all translate to HLSL with minimal effort.

share|improve this answer
    
nVidia and Microsoft co-authored Cg/HLSL back in the day. They gave it different names due to branding, but the language is the same. Now, there's probably a slight difference, but it's truly minimal. –  jacmoe Aug 4 '10 at 0:20
    
That is a phenomenal book. Basically anything by Kilgard was really good in terms of tutorials. –  bobobobo Jul 20 '12 at 20:43
add comment

If you want to edit and see the results real-time you can use this simple Silverlight tool

http://shazzam-tool.com/
Shazamm 1.3 - Editor & Previwer of HSLS Shaders


As for tutorials +1 for Riemers.net but I also found this series of XNA/HLSL tutorials even better.

Here's the list, you'll find them all here: http://digitalerr0r.wordpress.com/tutorials/

  • 1 – Intro to HSLS, ambient light
  • 2 – Diffuse light
  • 3 – Specular light
  • 4 – Normal mapping
  • 5 – Deform vertex shader
  • 6 – Shader demo: Simple ocean/island scenery
  • 7 – Toon shading
  • 8 – Gloss map
  • 9 – Wiggle post process
  • 10 – Invert post process
  • 11 – Grayscale shader
  • 12 – Pixel distortion shader
  • 13 – Alpha mapping
  • 14 – Transmittance/depth buffers
  • 15 – Dynamic Environment mapping
  • 16 – Refraction
  • 17 – Point light + Self-Shadowing
  • 18 – Multiple Point Lights
  • 19 – Hemispheric ambient light
  • 20 – Depth of Field
  • 21 – Transition: Fade
  • 22 – Transition: Cross
  • 23 – Blur
  • 24 – Bloom
  • 25 – Perlin Noise on the GPU
  • 26 – Bump Mapping Perlin Noise
share|improve this answer
add comment

A few things come to mind

  1. Introduction to 3D Game Programming With DirectX 9.0 (awesome)
  2. NVIDIA FX Composer (good for examples)
  3. There was a Shader X2 intro paper on ATI's website, but it's been removed... Ah! Found it here!
share|improve this answer
add comment

I found Riemers.net has a very good introductory tutorial on HLSL as part of its XNA tutorials. The author, Riemer Grootjans, also wrote the recommendable book XNA 3.0 Game Programming Recipes - if You like the recipe approach.

share|improve this answer
add comment

I would suggest you check the HLSL Development Cookbook , I found it to be really helpful. Especially chapter 3.

share|improve this answer
add comment

When I was reading about HLSL I found this tutorial back in the day. I liked it since it tried to explain every part of what it was doing.

share|improve this answer
add comment

I found a series of tutorials that goes from a basic ambient light shader all the way to reflections and toon shaders. Each goes through and explains every line and even explains some of the math a bit:

http://rbwhitaker.wikidot.com/hlsl-tutorials

share|improve this answer
add comment

Not sure what shader model and DirectX version you are targeting but I highly recommend Practical Rendering and Computation with Direct3D11. The book walks you through all the nitty gritty details of DirectX11, it's resources, all the different pipeline shaders, HLSL (an entire chapter dedicated to this), and how to start implementing things like particle system simulations, tessellation, image processing, deferred rendering, and DirectCompute!

share|improve this answer
add comment

for me its easier to learn GLSL first, and since HLSL and GLSL is similar. once you understand the whole concept, the pipeline, the hardware and how the inner shader language work it's easy for you to use another language such as HLSL or even Cg.

I propose GLSL because it has a very good book such as the orange and red book of openGL and its easy to learn for beginner.

share|improve this answer
1  
This doesn't answer the question. –  PhillC Jul 20 '10 at 13:13
    
It's not a bad response though - much of what underlies GLSL is very similar to HLSL and if the OP can find resources for GLSL then it's valid to make use of them. Many of the major differences between the shader code itself are just a matter of mental conversion once you know what you're looking at. The idea of learning GLSL first fails because one would also have to learn OpenGL (not bad in itself; useful to know both) and rewrite one's program (bad), but there's absolutely nothing wrong with using GLSL material to supplement one's HLSL learning (and vice-versa, where relevant). –  Jimmy Shelter Jul 24 '12 at 2:55
add comment

For graphics programming in general I would also look at Real-Time Rendering. It is an excellent book an touches on almost any subject in this area. It also gives you a list of resources for further details and has a great website that is regularly updated: http://realtimerendering.com/

If you want to learn about creating new shaders and feel you know enough to write your own, I would try to take some concept art and recreate the visuals in this art. This is what you'll do mostly as a graphics programmer in the industry, creating in a shader what the concept artist envisioned.

share|improve this answer
    
Real-Time Rendering is an excellent survey of computer graphics in general -- one of my favorites! However, the question was specifically asking about the HLSL shading language, which RTR does not cover. –  postgoodism Nov 2 '12 at 19:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.