Learning HLSL for a non-coder
June 27, 2014 10:12 AM   Subscribe

My sweetie is trying to learn the programing language HLSL but she has zero- and I mean, Zero- coding knowledge. Help?

It's becoming super clear to both of us that most of the online tutorials for HLSL assume some amount of programing experience- which has been an enormous frustration for her. Is there a "HSLS For No Foolin' Real Dummies That The Other Dummies Make Fun Of For Being Such Dummies" tutorial out there? A slow tutorial with loads of handholding and expository would be ideal.
posted by cheap paper to Computers & Internet (11 answers total) 4 users marked this as a favorite
Best answer: So this isn't a tutorial, but I recommend Shadertoy both as an easy way to try out shaders and as a repository of examples. A lot of them are very complicated, but if you can find one with a small amount of code, you can tweak that code (changing the numbers, removing lines) to start getting an idea of what does what.

For example, this shader produces a fairly simple visual pattern that can be tweaked. For example, changing

float N = 5.0;


float N = 3.0;

changes the number of lobes in the pattern from 5 to 3.
posted by Zarkonnen at 10:26 AM on June 27, 2014

Is she positive that this is actually the best tool for whatever it is she's trying to do? I'm a hobby coder and I had to Google--and I'm not sure I'd just characterize HLSL as "a programming language". It's to program GPUs, and I'm a bit at a loss for how you could get any use out of GPU programming without being able to do something else, first. When I've run into problems like that previously, it's usually meant that what I've stumbled on is not actually the right tool for what I wanted to do.
posted by Sequence at 10:27 AM on June 27, 2014 [4 favorites]

What does your SO want to do, actually? Unless you're making 3d games in like a real games company or doing graphics research or taking an upper-level-undergrad+ class, this is probably not the best tool for you.
posted by curuinor at 11:19 AM on June 27, 2014

If she absolutely needs to use HLSL, I would strongly suggest that rather than look for a dumbed-down HLSL tutorial, she starts with learning some coding. There are a lot of online code schools where she can start with even something like javascript from scratch, and that might help give her the baseline she needs. Skipping that step seems like inviting future trouble.
posted by brainmouse at 11:26 AM on June 27, 2014

Yeah, nthing that HLSL + shaders knowledge is going to be pretty hard to apply without some other programming language to use it from.

I think that unless this is related to a really specific work requirement, there's an easier means to whatever end she's aiming toward.
posted by PMdixon at 11:52 AM on June 27, 2014

Response by poster: Well, she IS doing this for real-time shader development for 3D games so there's not exactly a way to avoid the language. She's used frontend GUI type things before but she's frustrated that she doesn't understand the basic nuts and bolts of the process.

The Shadertoy app sounds like right up her alley. Thanks!
posted by cheap paper at 12:04 PM on June 27, 2014

She's going from zero coding knowledge to writing game shaders? Ouch. That's going to be a learning curve and a half :)

How's her general 3D graphics background? Does she understand the stages in the graphics pipeline in a GPU for instance? There's a huge amount of background knowledge that most HLSL tutorials are simply going to assume because writing shaders is pretty much the pinnacle of graphics programming - it's where most of the hard stuff happens.

If she doesn't know this stuff, then she might find it really helpful to follow something like the NeHe graphics tutorials (or something equivalent for DirectX if that's the API she's using) in order to get a good grounding in the basic principles.
posted by pharm at 1:01 PM on June 27, 2014

Doing a real-time shader for 3D games is not a first coding project. Doing 2d games in C++, then 3D games in C++ and then the shaders is a better idea.

If this is a work requirement, I would give serious thought to communicating that she hasn't programmed before. If this is a self-directed project, I would pick a first project with fewer pre-requisites.
posted by curuinor at 5:01 PM on June 27, 2014 [2 favorites]

Shaders: A primer

Pixel Shaders, a work-in-progress interactive book

Depending on what you want to do with them, shaders are not necessarily out of reach for a beginning programmer. It's true that some programming fundamentals will be needed, but simple shaders could actually be a decent way to learn them, since you can get instant feedback. If you need to do really advanced effects though, you probably will to learn more about graphics programming from the ground up.
posted by mbrubeck at 5:24 PM on June 27, 2014

HLSL is based on C syntax, so the fastest way to get started with HLSL might be to learn the real basics of C then gradually move to HLSL as it starts to make sense. I'm an entirely amateur C programmer but I looked at some HLSL code and its structure makes sense even though I don't know what each of the individual pieces is doing. There are lots of C tutorials out there (avoid ones focused on C++, though).
posted by A Thousand Baited Hooks at 7:54 PM on June 27, 2014

It seems worth pointing out after the early "best answer" that ShaderToy doesn't use HLSL.

HLSL and Cg are very, very similar, such that a tutorial for one will be helpful for working with the other, but ShaderToy uses GLSL, which has its own, different syntax.

(ShaderToy also deals exclusively with fragment shaders, and there's a good chance that half of what you're looking to do needs to happen in the vertex shader, too?)

She's used frontend GUI type things before but she's frustrated that she doesn't understand the basic nuts and bolts of the process.

This sounds like you're working in a specific engine? Mentioning which might affect the answers here.
posted by nobody at 12:41 PM on June 28, 2014

« Older Child reading books in the summer   |   Mystery mark stains seat! Blue butt print upon the... Newer »
This thread is closed to new comments.