Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / HLSL Global Matrices

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Dec 2014 03:54 Edited at: 29th Dec 2014 03:56
What are or how do you find all the definitions for the matrix hooks for DBP? I call them hooks cause I imagine there just a way to retrieve information from DBP and assign them to a float4x4 (matrix) variable. Example:

-----------(variable name)-----(internal matrix hook)
float4x4 mEpicWorldThing : World;

Cause other application don't assign them in this way it's hard to look up reference information in comparison to DBP, especially if you have variables like this from a source you're looking at:

g_mViewProj

What is that?... ViewProjection? WorldViewProjection?

I have no clue cause I don't know what all the possible hook names are so I can't identify what something is.

"Get in the Van!" - Van B
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Dec 2014 11:11 Edited at: 29th Dec 2014 11:22
I don't know much about DX but from my openGL stuff I can explain a little bit.

The Projection matrix is usually the final stage which defines either an ortho or perspective view. Everything from the next two matrix transformations is transformed to coordinates -1 to +1.

The View matrix (I may be wrong) defines the area displayed from the cameras point of view.

And the Model matrix is used on a single model within the scene.

MVP, or Model, View and Projection. Usually you will find shaders combine the View and Projection matrices into one and just pass the Model matrix to the shader.

EDIT: From where I got my understanding of it from: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Dec 2014 13:14
Quote: "g_mViewProj

What is that?... ViewProjection? WorldViewProjection?"

Following the naming conventions, that should be a global view projection matrix.

The g_ prefix is used to indicate it is a global variable (available to all shader functions), the m prefix is used to make it clear that the variable is a matrix. ViewProj is obviously just short for view-projection, which, as WLGfx said above, is a combined view and projection matrix, in other words a matrix that you transform worl-space positions with to get them into screen space using your rendering camera's settings.


There is no way to set custom matrices to a shader constant from the standard DBPro library.
Here is a function that follows the standard of all other "set effect constant ...." functions in the DarkSDK; you can put this in, create a dbSetEffectConstantMatrix(int iEffectId, char *szConstantName, int iMatrixId) wrapper function for it and export that if you use the official open source solution and rebuild the DBProBasic3DDebug.dll file:


Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Dec 2014 13:16 Edited at: 29th Dec 2014 13:19
No, I know what they are but I don't know what there all called or how many theres are.

For instance these are the one's I know:

World
View
Projection
WorldViewProjection
WorldInverseTranspose
ViewInverse
WorldInverse
WorldIT // have no clue what this is
Time
CameraPosition
...

So are there anymore? No matter where I look I can't find any information on these.

"Get in the Van!" - Van B
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Dec 2014 14:32
Ah, those are called semantics and are used to bind the value before them to a system value.
The following are listed in DBOFormat.cpp:


The descriptions are my qualified guesses by the way, so don't see them as necessarily cannon.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Dec 2014 14:53 Edited at: 29th Dec 2014 14:54
Wow there's more than I thought

But thanks Rudolpho, that's awesome. This makes identifying what things actually are in source material easier cause people name there variables all kind of things.

Quote: "There is no way to set custom matrices to a shader constant from the standard DBPro library"


Isn't there? Set Effect Constant Matrix is a command in DBP. Never actually needed to use it though.

And thanks also to WLGfx, that you link you provided had something useful informations

"Get in the Van!" - Van B
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Dec 2014 15:12 Edited at: 29th Dec 2014 15:13
You're welcome

Quote: "Isn't there? Set Effect Constant Matrix is a command in DBP. Never actually needed to use it though."

Oh hah, maybe there is then.
I remember writing some wrapper functions of my own because you couldn't set a lot of shader variable types from DBPro, but maybe the matrix wasn't one of them. You can only set float4 vectors at least, not float2 / float3

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Dec 2014 15:30 Edited at: 29th Dec 2014 15:30
Yeah I remember reading on the DBP sales page:
Quote: "You have full and direct control of these awesome hardware effects from within DarkBASIC Professional"


Full?! Where?

Just like an astronomical amount of stuff missing from DBP (even basic stuff)! Oh well, that's what the community is for, make up for it's short comings.

"Get in the Van!" - Van B
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2014 12:06
Quote: "You can only set float4 vectors at least, not float2 / float3 "


That also isn't true. Just use a vector4 in DBPro with set effect constant vector in the usual way and the shader will simply read off the first two or three components it needs. You'll need to assign all four components in the DBPro set vector4 command of course.

I don't know why people insist on forgetting the set effect constant matrix command. It's clearly there in the Help file as Sasuke said and works cleanly as intended. Although why that and related commands aren't listed under the SHADER COMMANDS subheading is a complete mystery to me.



Powered by Free Banners
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Dec 2014 13:13
Oh, so that's how it works... I stand corrected
Still, it's a bit counter-intuitive that it requires a vector4 when all vector types share the same indices anyway; would that the set effect constant vector function could take any vector (it could easily be expanded into a float4 with the remaining components set to 1 behind the scenes if that's necessary with DX9).

Quote: "I don't know why people insist on forgetting the set effect constant matrix command."

Can't give you an answer on that one

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2014 14:17
Quote: "Still, it's a bit counter-intuitive that it requires a vector4 "


Agreed. It puzzled me for a while too many moons ago.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-05 11:52:45
Your offset time is: 2026-07-05 11:52:45