what does 'w' mean in shader assembler
The thing about homogeneous coordinates and other things is that yes, you should know them. But knowing about them really only applies to a very small part of your experience in writing a 3D framework; once you've written your projection matrix generation code and, possibly, a few other things you can mostly forget about them. In fact, if you use certain modern 3D frameworks that handle that stuff for you, you really don't need to know about them at all. Similarly with things such as quaternions. I wrote my first 3D game using quaternion and projection matrix code garnered from elsewhere, didn't have a clue how those things really worked, and managed to get by okay until I did know. The gritty internals of homogeneous coordinates, quaternions, projection matrices, transformations and so on can be safely abstracted away so that the end user doesn't need to mess with them.
If you're writing a 3D framework/engine, yes you should spend the time to know the details. If you are just using a 3D framework to build a game, maybe you can get away with a rough, basic familiarity. If you strive for mastery of every little detail, you just won't get anywhere.
I was using GL/D3D for years (and building games/toy-engines with them), just with the knowledge that "'w' is some kind of magic", and that "matricies are some kind of magic" before I got around to learning linear algebra and the theory behind all the computer graphics magic
...
I had some doubts before, but now i know that you are human after all.
Unfortunately i am still in world of magic, but i am striving to learn.
A person can't use a graphics api if they don't know what homogenous coordinates are??? I guess I should have told myself that before I did this.
You divide the x, y, z values by the w component to get the position in 3D space which is embedded in the 4D projective homogeneous space.
So (x, y, z, w) = (1, 1, 1, 1) and (x, y, z, w) = (2, 2, 2, 2) both refer to the same point in 3D space, (1, 1, 1).
For direction vectors, w is 0, which would cause division by zero. These correspond to points at infinity in 3D space in the direction of the x, y, z components.
That's basically it in a nutshell.
4D coordinates are used because you can represent any affine transform in 3D space with a (4x4) matrix. You can't do that in 3D space because the origin of 3D space (0, 0, 0) always maps to the origin after being transformed by a matrix (so translations are impossible in 3D space using just a matrix).
That doesn't happen in homogeneous 4D space since the origin of 3D space is represented by (0, 0, 0, 1) [or (0, 0, 0, w) for w != 0].
(0, 0, 0, 0) doesn't correspond to to any point or direction in 3D space, and is not a valid value for 4D homogeneous projective space.
So 4D vectors (x, y, z, w) with w != 0 corresponds to all points in 3D space and all directions ("points at infinity") in 3D space as well.
Hope that helps.
Yes, if you only scale the w component and not the x, y and z components.
(EDIT: HULK SPEAK IN CAPITAL LETTERS ONLY TOO!)
For the longest time I was content to think that 'w' was just added to vector processors to fill in the extra value in the set of four to match the four values neccessary for color. From all this I've gathered that 'w' is neccessary to make the perspective matrix work. So if I were to carry this logic further I would surmise that 'w' is scaled down by the projection matrix math for vertices that are further back and scaled up for objects that are closer to give the illusion of depth. Thus we have perspective on the matter!
For the longest time I was content to think that 'w' was just added to vector processors to fill in the extra value in the set of four to match the four values neccessary for color. From all this I've gathered that 'w' is neccessary to make the perspective matrix work. So if I were to carry this logic further I would surmise that 'w' is scaled down by the projection matrix math for vertices that are further back and scaled up for objects that are closer to give the illusion of depth. Thus we have perspective on the matter!
It's actually more general than this. Homogenous coordinates are used for transformations done by matrix multiplication. For example even simple translation would not be possible with just x,y,z vectors and a 3x3 matrix.
Btw, to the discussion - IMHO you really don't need to understand homogenous coordinates to be able to work with 3D graphics. You can be fine for a looooong time with just remembering that direction vectors have w = 0 and points have w = 1. That's what you'll eventually may need to code manually in a shader or something, when you have just a x,y,z vector and want to make matrix transformations with it.
But of course it's always better if you do understand it.
Out of all of the conjecture and philosophical discussion (which is also important...) nobody answered the original question from the OP. He wants to know why his w value is initialized to 1 when he only has a XYZ format for his vertex information. Its been really long since I worked with D3D9, so I couldn't say off the top of my head why that is. Can you describe how you managed to determine that the value is 1?
Regarding the debate, I can also confirm that I ran for a long time without really understanding what w really was doing. However, I agree with JTippets that the steering wheel analogy doesn't quite fit. Without knowing w, but still knowing how to use matrix functions roughly, you can get a bunch of work done. It is like being able to drive without understanding how an engine works. Sooner or later, when your engine breaks down, you better know the ins and outs of how it should work, or you won't have any chance to fix it. But until then, you can drive pretty far.
Out of all of the conjecture and philosophical discussion (which is also important...) nobody answered the original question from the OP. He wants to know why his w value is initialized to 1 when he only has a XYZ format for his vertex information. Its been really long since I worked with D3D9, so I couldn't say off the top of my head why that is. Can you describe how you managed to determine that the value is 1?
The original question isn't really very clear.
I would guess that it may be about this: If you have a vertex declaration entry for vertex position (D3DDECLUSAGE_POSITION) with the type D3DDECLTYPE_FLOAT3 and your vertex shader input parameter for position is float4, then w is automatically filled with w = 1, because that's what points need. I don't know whether for normal it would put 0 there, but I guess it would.
Anyway, I personaly have always been consistent in this and with D3DDECLTYPE_FLOAT3 I use float3 in shaders. And I add w manually.