Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Member
EdP  Offline 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: EdP] #17286
09/20/03 20:21
09/20/03 20:21
Joined: Mar 2002
Posts: 801
Switzerland, Zürich
napo Offline
Developer
napo  Offline
Developer

Joined: Mar 2002
Posts: 801
Switzerland, Zürich
matWorld is a matrix not a vector
matView defines the angle where you look at
matProj defines how 4D x,y,z,w Vertices are transformed to the screen
matWorldView = inverted World * View Matrix
matWorldViewProj = inverted World* View * Proj Matrix

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 Offline OP
Member
EdP  Offline 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: napo] #17288
09/20/03 20:46
09/20/03 20:46
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
thanks napo! but could you explain this a bit more in-depth? how do these matrices exactly look like? why is the 3rd row of the worldview matrix the camera position for example?

Re: DirectX equivalents of A6 shader keywords? [Re: ventilator] #17289
09/20/03 21:41
09/20/03 21:41
Joined: Mar 2002
Posts: 801
Switzerland, Zürich
napo Offline
Developer
napo  Offline
Developer

Joined: Mar 2002
Posts: 801
Switzerland, Zürich
All D3D Matrices are 4x4.

Projection contains the top,bottom,left,right ( that means the fov, and the height / width proportion) ,the far and near clipping plane.
View contains the look (x), up(y) and right(z) rotation vectors.


Re: DirectX equivalents of A6 shader keywords? [Re: napo] #17290
09/20/03 22:00
09/20/03 22:00
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i basically know what the matrices do and what they contain. but i don't know how some of them exactly look like? please explain it like that:
Code:
| 1 0 0 0 |

| 0 1 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |



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 Offline
Developer
napo  Offline
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: napo] #17292
09/21/03 00:03
09/21/03 00:03
Joined: Aug 2003
Posts: 105
Burgess Hill, United Kingdom
EdP Offline OP
Member
EdP  Offline OP
Member

Joined: Aug 2003
Posts: 105
Burgess Hill, United Kingdom
Thanks napo - nice explainations. Could you give a link to where you found these data structures? I've been all through the SDK chm, and Google searched, but I've not found anything as clearly set out as you did.

I did find one nice link on HLSL http://www.ati.com/developer/ShaderX2_IntroductionToHLSL.pdf which talks about matworld etc.


Ed
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 Offline

Chief Engineer
jcl  Offline

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 Offline OP
Member
EdP  Offline 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

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1