HLSL: What represents the 4th component in a float4/vector?

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
OnyxIdol
Posts: 10
Joined: Sat Jun 14, 2008 9:06 pm
Location: Germany

HLSL: What represents the 4th component in a float4/vector?

Post by OnyxIdol »

Ok, the internet didn't turn anything up on this, maybe its just too obvious. What, exactly, represents the 4th component in a float4/vector variable?

I am currently writing a shader, using Nvidia FxComposer(Great tool btw) and setting the 4th component of my global variables to zero produces some strange effects, such as stretching an object to infinity in case of a position vector. Setting it to 1 seems straightforward enough, yet I'd like to know what I'm dealing with.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Normally, in position vectors it is always 1. In fact float4() is a flexible object, and thus, the 4th component can be used in many ways. for example, in colors, the 4th component is the alpha channel. So, if you want to use position vectors, just stick to the 3 first, and ignore the 4th. It will work well in any case :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
OnyxIdol
Posts: 10
Joined: Sat Jun 14, 2008 9:06 pm
Location: Germany

Post by OnyxIdol »

Thx for the answer. But As I said, setting the 4th component in a position Vector creates really strange effects, i.e. it must have some meaning in a position vector as well.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

It has to do with perspective projection. It's called the W component. Read up on that.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
OnyxIdol
Posts: 10
Joined: Sat Jun 14, 2008 9:06 pm
Location: Germany

Post by OnyxIdol »

I will do that. Thank You.

Edit:
This thread can now be considered closed.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: HLSL: What represents the 4th component in a float4/vect

Post by Acki »

OnyxIdol wrote:some strange effects, such as stretching an object to infinity in case of a position vector. Setting it to 1 seems straightforward enough
I'm just guessing, but this sounds to me that in your case the 4th number could be a scale factor !?!?! :o
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply