1 Replies - 693 Views - Last Post: 06 July 2015 - 12:10 PM Rate Topic: -----

#1 BBeck   User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

HLSL Tutorial Videos Posted

Posted 06 July 2015 - 10:49 AM

So, I have begun publishing my HLSL tutorial videos on my YouTube channel. A couple people had requested these on the forum here, so you will be glad to know I've started putting them out there.

This HLSL video series takes an in-depth look at the basics of using HLSL to write 3D shaders.

I used XNA to demonstrate the topics, but this series applies equally to DirectX (and probably any platform that uses HLSL - not to mention that the core concepts here apply to GLSL and any other shader language). I've written these exact same shaders in DX11 and I can tell you that the differences between the two are miniscule. However, in the Part I video - which I have skipped publishing for now - I actually cover the differences and explain the XNA code that calls the HLSL line by line. This is obviously a bit different than the calling code in C++ and DirectX and so I'm going to make a button to skip that part for the DX people and I made the decision to publish this video last since I think it's the one the fewest people will be interested in.

Probably the biggest difference between DX11 and XNA is with flat shading. The Gouraud/Smooth shading video that I've already published on YouTube touches on Flat Shading by showing an example but does not show the code for it. This is largely because the way it has to be done in XNA is significantly different than the way it is done in DX11. XNA was built on DX9 and Shader Model 3. DX11 and now MonoGame which is built on DX11 uses Shader Model 5 and flat shading is super easy in Shader Model 5. The code for flat shading in Shader Model 5 is exactly the same as any of these shaders except you declare the vertex normals with the "nointerpolation" modifier. (I probably should have covered this in more depth in the video but didn't. Maybe I'll link this in the video description.) But, it's one line of code that gets modified to do flat shading in Shader Model 5 for DX11 or MonoGame (I presume since I've tried it in DX but not in MonoGame). But XNA, being written on top of DX9, doesn't understand the "nointerpolation" modifier. So, in XNA you have to kind of jump through hoops backwards and it takes quite a bit of code that by today's standards is mostly obsolete (which is what I did for the XNA example but didn't want to talk about it much since it is obsolete code). I haven't tried it in MonoGame but I'm pretty sure you don't even have to do this with MonoGame and can just use the "nointerpolation" modifier. So, flat shading is not covered other than showing what it is and briefly touching on this. I mostly show it as a contrast to smooth shading to show what it is the Gouraud shading actually did to modify the flat shading that came before it.

It's been months I've spent on these videos. The whole series has been recorded, but I spent the last two weeks just working on getting the 3 HLSL videos published so far. They are over 2 hours of video instruction on HLSL already published. I think the whole series is going to be about 4 hours of video tutorial.

The videos published so far cover the basic concepts of 3D programming in HLSL, Ambient lighting, and Gouraud/Smooth shading. The videos that I have not published cover Phong shading, Blinn shading, and Texturing (from the HLSL code perspective - not from the modeler's persepective). These have already been recorded, but the Phong video is the most important and longest of the 3 and after reviewing it I decided I need to re-record about half of it because I can do a better job explaining the math of the Phong algorithm than I did in the recorded video.

Anyway, the next 3 videos should be published in the not too distant future, although I'm guessing it will be at least 2 weeks before I can publish any of the others at a minimum. I have a wedding to attend out of town next weekend and a million things I need to do to get ready to leave town. So we're probably looking at weekend after next before I can even look at working on this stuff.

Anyway, in some ways what these videos teach doesn't seem to be "much". If you're not already doing HLSL, it may seem like this is just a small part of HLSL and nothing but "outdated" graphics. We are in fact largely going through the history of 3D graphics with these shaders with flat shading being all they had in the early days, then Gouraud shading improving on that, then Phong specular and eventually Blinn specular coming along. Somewhere in there they figured out texturing. So, this may seem like nothing but old "worthless" stuff and not "flashy cutting edge" HLSL. There's some truth to that. But what that viewpoint misses is that the later more "cutting edge" stuff like normal mapping builds on this. I haven't done normal mapping yet, but I'm pretty sure I have figured out how to code it and it basically just takes the last technique I explain in the videos with Textured shading and expands on it by adding a second texture for the pixel normals and uses those normals instead of the normals. It's only a couple lines of code changed compared to what's covered in these videos and uses 100% of what's taught in these videos. So, this is really the foundation for most of the "cutting edge" graphics stuff you want to do in 3D.

However, a lot of what is considered "cutting edge" graphics is stuff like bloom shading, deferred shading, glow effects, and High Dynamic Range lighting which is an entirely different type of HLSL known as "post processing effects" that get applied to the entire image rather than being used to draw like what is shown in these videos. Hopefully I'll eventually do something on post processing effects at some point. But first you have to learn to put stuff on the screen, which is what this video series is all about.

I hope to cover normal mapping very soon after I get all the current code published as videos.

Anyway, if you're interested in beginning to learn to do HLSL for 3D graphics, you'll definitely want to watch these videos because they cover the foundations for all techniques for drawing 3D models. Everything after this, just builds on top of this.

If you're not familiar with matrices and vectors, I highly recommend watching my videos on those subjects because the HLSL series is pretty much mostly applied matrices and vectors. Those subjects leave the realm of theoretical and become practice in these videos.

Also, I made an intro video segment for my YouTube videos starting with the HLSL series, so you may want to just stop by and watch that for a laugh even if you have no interest in HLSL. ;-)

And as always, if you have questions regarding what's taught in these videos, please post your questions in the Game Programming forum on Dream In Code. I love answering your questions and there are lots of other highly qualified people here waiting to answer your questions as well.

Oh. Also. I don't have the menus setup for these videos yet. I'm trying a different menuing technique than what i used in the math videos, but have not had time to finish setting up those menus yet. Hopefully, I'll get those menus working pretty soon, but really you probably should be watching the entire videos and not just parts of it if you don't know this stuff already. Still, I'll try and get those menus working soon.

This post has been edited by BBeck: 06 July 2015 - 11:12 AM


Is This A Good Question/Topic? 0
  • +

Replies To: HLSL Tutorial Videos Posted

#2 BBeck   User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: HLSL Tutorial Videos Posted

Posted 06 July 2015 - 12:10 PM

I thought you might be a little interested in what it took to make these videos.

The tutorial stuff is pretty straight forward although I edit things out like the motorcycle that came roaring down my street so loudly that you could literally hear it as if I was riding the motorcycle through my headset microphone! I also try to edit out any long pauses and such. I'm using Camtasia for the video recording.

The intro video that I just completed was quite a bit of work. I left space for intro music in the math videos and then got busy and never wrote the music. So now it's just a long boring pause which is why I made buttons to skip to the video start.

Knowing that I was about to crank out 6 new videos in a row, I decided I probably needed to get serious and make an intro video to make the videos seem a little more professional and "polished". It's really kind of a tough decision because any time I spend on this production stuff is time that I don't have to make tutorials which I feel like I'm not making enough progress on in the first place. (Getting these videos published will be a good start towards progress however.) On the other hand, the production stuff probably makes people more likely to tune in and makes it feel like I know what I'm talking about whether I actually do or not. ;-)

So, I've spent I think the last 3 weekends working mostly on that intro video segment. I had an original concept for it similar to what I ended up actually doing. But then I got this idea of doing something with "swirling binary numbers" that felt like "you're entering the Matrix" and morphing between normal instruments and electronic instruments in the music. I spent probably an actual 20 hours over 3 weekends auditioning sounds.

I sat down in my recording studio. I have a bedroom setup as a dedicated recording studio although I have admittedly not done much of anything with music in years. But it's all setup and ready to go for those times where I get inspired to do something like this.

So, I went through probably thousands of sound patches on most of my synthesizers auditioning sounds to try and find things that would work for my intro music concept. I wrote down the ones that seemed to have some potential. And I literally did this for a couple of days. Eventually, I realized how much time I had spent on this and basically not gotten anything actually accomplished. Furthermore, I had gone through most of the tools I had available and nothing was what I wanted for the concept. I had nothing that "sounded like swirling binary numbers".

This weekend was a 3 day weekend in the US for the Independence Day holiday. So, I had a long weekend to work on this and spent the better part of the first of those 3 days just auditioning sounds. I knew I wanted to get this project wrapped up by the end of the weekend because I wanted to get these videos published. Maybe I could have eventually brought my musical concept to life if I had of spent the next 6 months on it. Maybe. But it just wasn't happening and, again, this was time taken away from me doing tutorials and actually teaching stuff not to mention it was holding up getting the videos I had already shot edited and published.

So, I had to make a decision on how important this video intro actually is. And I figured writing tutorials is more important than having the "perfect" video intro. So, I largely abandoned my concept and went with what I could do with the tools available to me.

And so, I went back to the patch that I had discovered early on, which is the one you hear at the beginning of the video with the "Oh-Be-Yahbe-Yahbe" and the drum beat behind it.

I'm a musician although I'm more of an academic musician than an artistic musician. But film and video game scoring is a very different "animal" than the "pop rock" I'm used to composing. I'm trained to write pop songs (and I'm calling anything from "the Rolling Stones" to "Maroon 5" to "John Mayer" "pop rock" here). But this is probably the very first time I've done music and sound effects for a video before. I produced a friend's wedding video complete with copyright infringed music (shh!... don't tell anyone... no one got a copy of that video except family and close friends). But I don't think I've ever written music for a video intro before.

Film and game scoring is very different than writing pop music and I think this intro theme is somewhere between the two. But I knew I should probably keep it limited to roughly 8 seconds of music since people were going to have to wade through it for every video I do and if they watch 100 videos back to back (you were planning on taking a week off from work to watch all my videos I'll be doing in the next 2 years back to back, weren't you?) that could be a lot of times to watch this video intro and get sick of the music.

When I heard that patch with the "Oh-Be-Yahbe-Yahbe" I immediately knew it was a contender. But after days of searching through what my synths could do nothing was showing up to be any better. That patch is a step sequencer. It includes the drum groove in it. Basically, you can get the chord progressions just by pressing a key on the keyboard. So, I decided on the fairly simple chord progression to use and laid down the track. By itself it pretty much reminds me of Rave music and makes me want to get up and dance. I believe this patch came from the Native Instruments "Massive" synthesizer.

I eventually laid down a bass track using the keyboard and MIDI. That allowed me to audition quite a few bass instruments on the synths to figure out which worked the best with the track. This did not go so well as I'm not a very good keyboard player. I'm a vocalist and guitar player who's spent some time playing drums and thus was allowed to play bass in my last band. But keyboards I've mostly only toyed around with. My groove was horrible with the keyboard bass.

I think I'm much more solid with a bass guitar in my hands when laying down bass tracks. But I haven't had a bass guitar in years now. (Gave it away but that's a long story.) So, I had to make due with what I had. I edited some of the bass notes by hand to make them groove better. (Honestly, I'm still not super happy with how tight the groove is on this but more than likely I'm one of the few people who will ever notice. I needed to get this project wrapped up and not spend another 6 months on it.)

This sounds phenominal in my studio with the subwoofer going through $800 studio monitors (not including the cost of the subwoofer). And I usually try to monitor at low volume so as not to give myself permanent hearing damage.

I actually went to school for audio engineering (recording) by the way. I ended dropping out of school that semester, which is a long story but this is all stuff I've spent years studying. It's not like I went into this as a complete newbie. There's a reason I've got a recording studio in my back bedroom with a computer with Cubase installed on it ready to go. (Although, I admittedly stopped doing this several years ago and switched to making 3D game programming my primary hobby.)

Anyway, the robot voices were done with my Nord Modular G2 on its built in vocoder patches. This was not really what I had wanted, but they worked and I wanted to get this wrapped. The sound effects like the electronic glitch sounds and static were done with NI's Battery I believe. I think I had about 7 audio tracks with only 3 of them being music I think.

At some point I added the lead synth sound that comes in the second "verse" section of the music. That's pretty much me playing keys recorded as MIDI, but I think I pretty much left it as is. There was some pretty good pitch bending stuff I didn't want to mess up with that. I guess the lead is nothing phenomenal, but considering my keyboard ability, I was pretty happy with it. I found it to be kind of catchy too as it seems to be sticking in my head after listening to it so many times.

I'm practically walking around the house singing it "Wee due, Wee due, Wee due due". :-)

I mixed the whole thing down to a wave file. Sneaker netted it over to my main computer to take a listen on my computer monitor speakers (my Sony HDTV). It sounded horrible! It's those speakers on that TV. They emphasize the mid range frequencies that if the mix is not just exactly right sounds like nails on a chaulk board. I've heard this problem with numerous pieces of music including some custom music someone had done for Skyrim and a friend's musical album. Anything not mixed in a professional studio sounds atrocious on those speakers.

So, I went back to the studio and decided the music needed to be "mastered". I threw a multi-band compressor on the entire mix as this is about 80% of mastering in my experience. I then went in and played with the track volumes a bit although the drums and main "instrument" are all one patch and can't have their volumes altered individually. (Welcome to the world of step sequencers.) Then I added a parametric equalizer to filter out the drum frequency that was so offensive on my TV speakers. I think I hit it with about 12 db less gain. Then I mixed it down, sneaker netted it, and took another listen. It was much more tolerable and I figured if it sounded good in the studio and decent on this TV it was probably going to be good enough.

Then I needed to make a video to go with the music and sound effects. I mostly used Camtasia to do screen captures of some of my XNA projects as I've spent most of my time with DX so far just building up an "engine"/framework and haven't got around to doing this kind of graphics stuff with DX as much yet. This is what I'm working towards in my DX tutorials anyway. And it's all stuff I could pretty much easily do in DX at this point. So I figured that was good enough.

Then I took the individual videos shot as screen captures and edited them into the final video to match the music. I took a couple different screen captures for each and then picked the best.

Then I made it into an actual video so that I can just plop it straight into any future video projects I work on. So, it may lose a little video and audio quality being re-recorded like that but the loss there seems minimal. The vast majority of the quality loss seems to be when I publish to YouTube both the video resolution and the audio quality take a bit of a hit.

Then I was able to take the tutorial videos and edit them together with the new intro video which took most of the final day on Sunday. So, it was pretty much still auditioning sounds on Friday, recording the intro video on Saturday, and editing and publishing the 3 videos on Sunday.

All in all, I'm pretty happy with the intro video. It wasn't what I had hoped. I think it could be improved on a bit and I may redo some of the video in the intro at some point maybe once I get some actual DX samples. But all in all, I feel pretty good about it. I know I like listening to it. And it really does seem to make the video feel a lot more professional and exciting I think.

Tying this back to video game programming - if you were going to do a cut scene for an intro or something on a video game, the process would likely be pretty similar.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1