Running commentary on Shader Production

5 replies [Last post]
Demno's picture
Posts: 6

This isn't a normal review as I haven't seen the whole DVD yet. I will try to update it when something comes to mind while watching it as it tends to give a more accurate opinion than a collected one at the end.


Right, so here goes. 

I have pretty much no knowledge of CGFX or HLSL code. However, I can wrangle out all kinds of shaders in both UDK and other nodebased systems. I know the theory behind how shaders work and so on. I have in the past done some mel scripting and studied some Java so I also know the basics of how programming works. The reason I bought this DVD is to learn to actually write the shaders from scratch. Learn the syntax, semantics and whatnot. After looking at the trailer for the DVD and reading the description it sounded like it was pretty much made for me.


I am currently at chapter 3 on the DVD and he is about to show how to add lighting to the shader. However, I still have no idea how to do the basic setup of it. There are files included with heavily commented shaders to read. I may be thick but it doesn't quite explain why something is written like it is.

Example from the first shader: 


Think of matrices as decoder rings. They can take a value and turn it into something useful, 
 in practice, you can take a world position and turn it into a screen position. Those are usually 
 refered to as "spaces", object space, world space, screen space. All that means is "This value is in relation to the world" or 
 this value is in relation to the screen. 
This doesn't explain to me why it's written like this:
float4x4 WorldViewProjection     : WorldViewProjection   < string UIWidget = "None"; >;
Why is there a second WorldviewProjection? What's with the comma? UIWTF?
Perhaps this gets explained later in the DVD but I would have liked to have that info up front.
Now, because of this I did some searching on the net and I have found some nice articles with this basic stuff explained. I am currently trawling through this before I go back to the DVD. I could share these articles if anyone wants them.
To be continued... Smiling
Demno's picture
Posts: 6

After spending a couple of hours looking through examples and reading articles I know almost understand what does what in the base shader. One of the things I want to warn future newbs like me is that the examples included on the DVD expect you have some prior knowledge. This is evident in the slightly confusing variable naming. It's efficient and convenient but it's not very clear if you are trying to  decipher what is going on.

An example would be in the supersimple.cgfx shader the position variables in the structs have the same name so I got confused as to which was used where. I found it easier if I gave them unique names so I could see exactly where my values went. 


Now that all that is cleared out for me I think it's time for me to go back to the DVD! Smiling

(Sorry to all the pros out there, but I am writing this from a beginners perspective.)

Demno's picture
Posts: 6

After a few busy days I have finally gotten some time for this again. 

When launching back into chapter 3 where I left off last time, I notice that the wrong shader example is included on the DVD!!! The base.cgfx is the Lambert! I compared them and they are the same. I guess the base is from the end of lesson 3 and the Lambert from the beginning of lesson 4. This means, there is no starting point for lesson 3. Some would say, well just go from what you had in the end of lesson 2. I would, unless the first thing he says in 3 is; Here is almost the same as what we left with. I have added a few matrices and altered a function. 


Of course, I can pause the video and read what the changes are, but without any explanation as to what they do it's rather useless.


So far, I must say I am not overly impressed with this production. I hope it gets better before I completely regret buying it.

Demno's picture
Posts: 6

I guess noone is actually reading this so I'll use it as open notes for future shader newbs like me Smiling (if this is not ok, feel free to remove my posts.)

In lesson 3 where he says that mayas widget for lights is backwards but it's a known mystery and perhaps someone out there might have a fix.

Well, the widget is correct. The math just isn't what you might expect at first glance. The dot product of two vectors pointing straight towards eachother is -1. (DotProduct = (x1*x2 + y1*y2 + z1*z2)).

This means that a poly facing the camera will have a value below 0. Since we are multiplying the dotproduct with the colour anything under 0 will be black, hence the easy inversion fix.

metalliandy's picture
Posts: 3188

Thanks for posting this...its always great to hear feedback!

We try to read as many posts as we can, but sometimes it can take a while to get stuck in Eye-wink

Demno's picture
Posts: 6

Cool! I just wanted to be sure I'm not breaking any rules by posting my notes on the lessons as it's not technically a review.

Oh, and I forgot to mention, that saturate() thing that suddenly popped in when he switched shaders towards the end of 3 (probably between recordings) just clamps the values between 0 and 1 which is why we get the behavior he describes.