3 registered members (AndrewAMD, VoroneTZ, dpn),
1,346
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
DirectX equivalents of A6 shader keywords?
#17285
09/20/03 19:44
09/20/03 19:44
|
Joined: Aug 2003
Posts: 105 Burgess Hill, United Kingdom
EdP
OP
Member
|
OP
Member
Joined: Aug 2003
Posts: 105
Burgess Hill, United Kingdom
|
I'm struggling to translate the A6 shader keywords into DirectX T&L terms. What I've come up with is as follows:
matworld : Entities' position and angles. Associated through entity_ptr.material. Equivalent(?) to D3DvERTEX, for untransformed, unlit vertices.
matView : View transformation 4x4 matrix, set by the view position and angles. Equivalent(?) to view transformation: == (view position - camera position) crossproduct(matworld). i.e D3DUtil_SetViewMatrix(....);
matworldview : Gives transformed scene camera position matrix. Equivalent(?) to 3DGS camera. Camera.clip_near == front clipping plane of viewing frustrum camera.clip_far == back clipping plane of viewing frustrum
matproj : View projection as set by camera.clip_near/far. Equivalent to setting lens parameters on camera for scene visibility through clip instructions.
matworldviewProj: 3DGS viewing window(?). i.e the D3DVIEWPORT, updated after every scene change.
I'd appreciate if someone more familiar with DirectX could comment/correct my interpretation.
Thanks.
Ed
|
|
|
Re: DirectX equivalents of A6 shader keywords?
[Re: napo]
#17287
09/20/03 20:41
09/20/03 20:41
|
Joined: Aug 2003
Posts: 105 Burgess Hill, United Kingdom
EdP
OP
Member
|
OP
Member
Joined: Aug 2003
Posts: 105
Burgess Hill, United Kingdom
|
Thanks!
OK one final dumb question. I assume that the vertex structure in the A6 engine is hard-wired into A6 code via a DrawindexPrimitive or somesuch, hence:
v0 - always contains the position v3 - always contains the normal v7 - always contains a texture1 coordinate v8 - always contains a texture2 coordinate
what are the missing registers used for? Typical MS associations are: blendweight, blendindices,psize,pdiffuse,specular,tangent,binormal etc. However I don't see how to either find these, or if possible, alter them.
Ed
|
|
|
Re: DirectX equivalents of A6 shader keywords?
[Re: ventilator]
#17291
09/20/03 22:33
09/20/03 22:33
|
Joined: Mar 2002
Posts: 801 Switzerland, Zürich
napo
Developer
|
Developer
Joined: Mar 2002
Posts: 801
Switzerland, Zürich
|
Code:
sx 0 0 0 0 sy 0 0 0 0 sz 0 x y z 1
x,y,z = World coordinate sx,sy,sz = Coordinate scaling Rotation: X Rotation modifies fields 22 (sy),23,32,33 (sz) : Code:
sx 0 0 0 0 cos(angle) sin(angle) 0 0 -sing(angle) cos(angle) 0 x y z 1
|
|
|
Re: DirectX equivalents of A6 shader keywords?
[Re: EdP]
#17293
09/21/03 02:26
09/21/03 02:26
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
Basically, the first three rows of a transformation matrix contain vectors for projecting the source vector onto the x,y,z axis (by a dot product), while the forth row is just added to the resulting vector. Thus a transformation matrix must contain 4 rows for covering rotation and translation, even if the vectors have only 3 dimensions. For doing this in a mathematical elegant way, vectors get a forth component that is normally 1.
The matrices and vectors used by the shaders are DirectX matrices and vectors. The DirectX coordinate system differs from the GameStudio system: Y and Z is swapped. If you have the DirectX SDK, you can find a description of the DirectX matrices in the help file under Programmers Guide->Using Direct3D->Transforms.
The A6 vertex structure is indeed 'hardwired' for models and terrain:
Code:
struct VERTEX_TLSHADED {
D3DXVECTOR3 v;
D3DXVECTOR3 n;
float texu0,texv0;
float texu1,texv1;
};
|
|
|
Re: DirectX equivalents of A6 shader keywords?
[Re: jcl]
#17294
09/23/03 21:41
09/23/03 21:41
|
Joined: Aug 2003
Posts: 105 Burgess Hill, United Kingdom
EdP
OP
Member
|
OP
Member
Joined: Aug 2003
Posts: 105
Burgess Hill, United Kingdom
|
For anyone else struggling to build up the DirectX concepts necessary to start building shaders, I recommend finding ..\Documentation\DirectX7\Word\d3dim.doc in your DirectX SDK directory. It builds on the concepts that napo outlined in this thread. I wish I'd found it earlier!
Ed
|
|
|
|