|
|
|
Help!
by VoroneTZ. 10/14/25 05:04
|
|
|
|
|
|
2 registered members (Grant, joenxxx),
9,921
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
gerstner wave function
#131352
05/23/07 21:34
05/23/07 21:34
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
well, even though it's not really a shader, do you gurus know what is meant here when they speak of a "gerstner wave function"? http://www.futuremark.com/products/3dmark06/tests/i'm currently learning hlsl (proceeding well so far) but this is a thing which i've never heard before. i can only find essays and papers about physics and fluid simulation but nothing that tells me wether it is a shader or applies just to geometry transformations. thanks in advance, joey.
|
|
|
Re: float3 and float4
[Re: Joey]
#131357
05/24/07 00:36
05/24/07 00:36
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
Quote:
can anyone tell me when it's wise to use float3 and when float4? .... why a 4-dimensional vector for space?
Position is calculated in four dimensions because some technical reasons...essentially, the 3d position vector has to be transformed to homogenous perspective space, and a fourth component, w, is needed..
from Dr. Math: "For technical reasons, you need a fourth coordinate to do this efficiently, but the idea is this: The 3D point you would call (x, y, z) is represented by any 4D "homogeneous" vector like this: (ax, ay, az, a), where a is non-zero. We usually pick a to be 1, so it is represented by (x, y, z, 1). But if after multiplying your input 4D vector by the matrix you get something like this: (2, 11, 18, 2), the a is 2, so this corresponds to (2/2, 11/2, 18/2) in 3 dimensions."
In any case, normally you dont need to worry about it, just output a float4 vector for you final transform ... you just cast the positon input as a 4d vector and do all the mul using that, and there you go.. mul(inpos,matWorldViewproj); where inpos is a 4d vector..
As far as other uses of vectors, always be aware of what components you really need.. if all you care about in a vector is the xyz or rgb values, you should use a float3, unless you need to use these vectors to operate on a different float4.
For instance, this operation is illegal: c1.xyzw*=c2.xyz; ...where c1 is a float4 and c2 is float3)
to properly do this operation do this instead: c1.xyz*=c2.xyz; or you can do it in a dumber way like this c1.xyzw*=float4(c2.xyz,1); ..we just recast the float3 c2 into a float 4, adding a one to the w component, meaning it will unchanged by the multiplication.. if you wanted an addition, just 0 instead of 1...
There is an exception to this rule however, you can always multiply a vector by a scalar.. therefore: c1.xyzw*=2.0f; ...is legal..this just mulitplies each component of the vector by the scalar value...
Interestingly, in shaders, scalars can be subsituted for vectors in any case.. such that: float value=c1.rgb; is legal.. this is the easy way to get a monotone value from a color vector.. which is very useful in many shaders.
The basic rule is to be aware of what the numbers your vectors represent actually mean, and use the appropriate dimensions.
|
|
|
Re: float3 and float4
[Re: Matt_Aufderheide]
#131358
05/24/07 11:28
05/24/07 11:28
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Quote:
Interestingly, in shaders, scalars can be subsituted for vectors in any case.. such that: float value=c1.rgb; is legal.. this is the easy way to get a monotone value from a color vector.. which is very useful in many shaders.
Interesting indeed. Does it take the average of the elements or the max(), or some other algorithm?
|
|
|
Re: float3 and float4
[Re: Joey]
#131359
05/26/07 09:01
05/26/07 09:01
|
Joined: Nov 2004
Posts: 7,121 Potsdam, Brandenburg, Germany
Machinery_Frank
Senior Expert
|
Senior Expert
Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
|
Quote:
can anyone tell me when it's wise to use float3 and when float4?
Sometimes a matrix contains r,g,b,a where a contains the alpha channel of your image. This can be helpful e.g. for carrying informations for specularity.
Models, Textures and Games from Dexsoft
|
|
|
|