it seems to be the fourth component of input register, and D3DDECLTYPE_FLOAT3 sets it to 1

**3**

###
#2
Crossbones+ - Reputation: **5728**

Posted 30 May 2013 - 04:05 AM

It's the homogeneous coordinate. I would strongly suggest reading more graphics theory before proceeding.

###
#3
Members - Reputation: **206**

Posted 30 May 2013 - 05:07 AM

It's the homogeneous coordinate. I would strongly suggest reading more graphics theory before proceeding.

thanks a lot

but i do not agree with your opinion, i am using api, not designing api

###
#4
Members - Reputation: **1162**

Posted 30 May 2013 - 05:22 AM

but i do not agree with your opinion, i am using api, not designing api

I do not agree with your opinion. Even if you are just using the API, you will have to deal with matrix transformations at some point in your game and you will have to understand what are homogeneous coordinates to do it right.

Even if your API provides a complete math framework, you will have to know how to use it. To know how to use it you will have to learn maths and linear algebra.

**Edited by renega_666, 30 May 2013 - 05:24 AM.**

###
#5
Crossbones+ - Reputation: **5728**

Posted 30 May 2013 - 05:32 AM

Just to reinforce what renega_666 already said: in the context of any graphics programming (and if you have to touch shaders, you are way in), not knowing about homogeneous coordinates is like taking a job as a driver, then get into the car, point at the steering wheel and ask 'What's that?'.

###
#6
Members - Reputation: **206**

Posted 30 May 2013 - 05:55 AM

Just to reinforce what renega_666 already said: in the context of any graphics programming (and if you have to touch shaders, you are way in), not knowing about homogeneous coordinates is like taking a job as a driver, then get into the car, point at the steering wheel and ask 'What's that?'.

thanks for the info about 'homogeneous', i only see it in 'D3DFVF_XYZRHW', is there some concrete context 'homogeneous' applies

you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

###
#7
Crossbones+ - Reputation: **3829**

Posted 30 May 2013 - 06:27 AM

you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

Maybe you can get some result from it, encrypt some strings, but to be able to actually write a secure application, you also need to know some crypto theory to use it properly (know when its actually meaningful to use, make your keys secure, use the right algorithms for setting up sessions, verify they work as intended, etc etc)

Similarly, you need to know a subset of linear algebra, dealing with transformations and projections, to be able to write and debug 3D graphics code.

###
#8
Crossbones+ - Reputation: **5728**

Posted 30 May 2013 - 06:28 AM

And here you misunderstand what we mean. Homogeneous coordinates are not some arcane detail of graphics programming - they are central to it and no one can seriously use a graphics API without knowing about them.you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

###
#9
Members - Reputation: **1162**

Posted 30 May 2013 - 07:17 AM

is there some concrete context 'homogeneous' applies

Yes it applies to transforms (translation, projection,...) which are used extensively in every game.

If you don't understand homogeneous coordinate how can you understand perspective projection? If you don't understand perspective projection, how do you setup a camera for your 3D game? Of course you can follow a tutorial/manual without understanding what's happening and have a working 3D camera but whenever you will have to debug or adapt the code you'll be lost.

Linear algebra is something that every game developer should know!

###
#10
Moderators - Reputation: **40094**

Posted 30 May 2013 - 07:40 AM

no one can seriously use a graphics API without knowing about [Homogeneous coordinates].

You just answered thatIf you don't understand perspective projection, how do you setup a camera for your 3D game? Of course you can follow a tutorial/manual without understanding what's happening...

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 an intuitive understanding of how to use vectors/matrices/euler-angles/quaternions/dot-products/cross-products/etc, without knowing anything about how they really worked. In the case of dot and cross, I didn't even know the right terminology, but knew them by their function names in the Half-Life code base, which was something cryptic like vecfma, etc (

*or "that function that returns 1.0 when two normals are aligned" and "that function that gives you right angles"*).As long as I had an API, or some code I could copy-paste, I was set

Magic.

**Edited by Hodgman, 30 May 2013 - 07:42 AM.**

###
#11
Moderators - Reputation: **10067**

Posted 30 May 2013 - 07:41 AM

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.

###
#12
Crossbones+ - Reputation: **2788**

Posted 30 May 2013 - 08:50 AM

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.

###
#13
Members - Reputation: **431**

Posted 12 June 2013 - 04:47 PM

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. I feel I should point out that I've built this from scratch without using any pre-made game engine and I've got it working on both Windows and iOS, so far, and I don't have a clue what homogenous means, not even when talking about milk.

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, ^{3 }because you know that the testing of your faith produces perseverance. ^{4 }Let perseverance finish its work so that you may be mature and complete, not lacking anything.

###
#14
Crossbones+ - Reputation: **5602**

Posted 12 June 2013 - 05:00 PM

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.

**Edited by Paradigm Shifter, 12 June 2013 - 05:01 PM.**

###
#15
Members - Reputation: **431**

Posted 12 June 2013 - 06:23 PM

ummmmm, Hulk says "Scaling 'w' makes things bigger and smaller."

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, ^{3 }because you know that the testing of your faith produces perseverance. ^{4 }Let perseverance finish its work so that you may be mature and complete, not lacking anything.

###
#16
Crossbones+ - Reputation: **5602**

Posted 12 June 2013 - 06:29 PM

Yes, if you only scale the w component and not the x, y and z components.

(EDIT: HULK SPEAK IN CAPITAL LETTERS ONLY TOO!)

**Edited by Paradigm Shifter, 12 June 2013 - 06:31 PM.**

###
#17
Members - Reputation: **431**

Posted 13 June 2013 - 10:58 AM

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!

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, ^{3 }because you know that the testing of your faith produces perseverance. ^{4 }Let perseverance finish its work so that you may be mature and complete, not lacking anything.

###
#18
Members - Reputation: **1647**

Posted 13 June 2013 - 10:45 PM

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.

**Edited by Tom KQT, 13 June 2013 - 11:59 PM.**

###
#19
Crossbones+ - Reputation: **6110**

Posted 14 June 2013 - 05:09 AM

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.

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Direct3D Books: Practical Rendering and Computation with Direct3D 11, Programming Vertex, Geometry, and Pixel Shaders

Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article

Games: Lunar Rift

###
#20
Members - Reputation: **1647**

Posted 14 June 2013 - 05:52 AM

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.

**Edited by Tom KQT, 14 June 2013 - 05:52 AM.**