|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
WorldViewInverse no definition on manual?
#209420
06/02/08 22:07
06/02/08 22:07
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
im converting a hsls shader and there's a line:
float4x4 matViewInv:WorldViewInverse;
how i do it? since matWorldViewInv not exist ?
Thanks
Last edited by MMike; 06/04/08 22:24.
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: MMike]
#209764
06/05/08 15:52
06/05/08 15:52
|
Joined: Jun 2005
Posts: 656
Grafton
User
|
User
Joined: Jun 2005
Posts: 656
|
DANGER! This code is made up on the spot and untested. I have no use for matWorldViewInverse nor do I have the shader you are trying to convert, So the code is probably wrong. But maybe it will help you start thinking about how it can be done. Since matWorldInv and matWorldView can only be used in shaders, and there is no matWorldViewInv, we must generate it in a material event each frame. So we call a event function like this from the material;
MATERIAL* mtl_myMaterial =
{
effect = "myShader.fx;
event = create_WVI; // the function to create our custom matrix
flags = ENABLE_VIEW; // call the event before view rendering
}
Now create a function to generate the matrix, something like this;
float temp_matrix[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float matWorldViewInverse[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
function create_WVI()
{
mat_set(temp_matrix, matWorld); // copy the matWorld matrix to the temp_matrix
mat_multiply(temp_matrix, matView); // multiply matWorld by matView to get matWorldView matrix
mat_inverse(matWorldViewInverse , temp_matrix); // copy the inverse of matWorldView to matWorldViewInverse
mat_transpose(mtl.matrix, matWorldViewInverse); // copy the transpose of the new matrix into the material matrix
}
Now in your shader you define the matrix like this;
float4x4 matMtl; // this matrix holds the matWorldViewInv we created.
And everywhere in your shader you have "matWorldViewInv", replace it with "matMtl". I am pretty sure you must use "mat_transpose(mtl.matrix, matWorldViewInverse);" however you might only need to copy it instead like this; "mat_set(mtl.matrix, matWorldViewInverse);". So if you get odd results, try replacing mat_transpose() with mat_set() in the function. Anyway, this is how I would start to tackle this problem. I am sure you will need to experiment a little with the code to get it right. Good Luck!
Not two, not one.
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: MMike]
#209785
06/05/08 18:31
06/05/08 18:31
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
it says float error i mean i guess engine doesn't know what means float "unknown float...." startup error bla bla error...
Im using not using the lite-C, but the A7,7!!
Last edited by MMike; 06/05/08 20:35.
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: MMike]
#209812
06/05/08 21:30
06/05/08 21:30
|
Joined: Jun 2005
Posts: 656
Grafton
User
|
User
Joined: Jun 2005
Posts: 656
|
MMike, You may not be able to use c-script to create the matrix accurately. You could try replacing the "float" type with "var".
Using mul(matworld,matViewInv) will not give you a correct matWorldViewInv. But then again, if you like the results then why worry about it?
Not two, not one.
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: MMike]
#210763
06/12/08 18:06
06/12/08 18:06
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
i found a quicker way: function SHADER_planet_create_wvi{
while(1){
mat_set(mtl.matrix, matWorld); // copy the matWorld matrix to the temp_matrix
mat_multiply(mtl.matrix, matView); // multiply matWorld by matView to get matWorldView matrix
mat_inverse(mtl.matrix, mtl.matrix); // copy the inverse of matWorldView to matWorldViewInverse
wait(1);
}
}
Last edited by MMike; 06/12/08 18:07.
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: MMike]
#212608
06/23/08 12:09
06/23/08 12:09
|
Joined: May 2006
Posts: 133 ME
Mysterious
Member
|
Member
Joined: May 2006
Posts: 133
ME
|
Hi this is a good idea... but I guess you can make it shorter and faster
while(1){
mat_inverse(mtl.matrix, matWorldView); // copy the inverse of matWorldView to matWorldViewInverse
wait(1);
}
}
Regards Mysterious 
|
|
|
Re: WorldViewInverse no definition on manual?
[Re: Mysterious]
#212671
06/23/08 17:45
06/23/08 17:45
|
Joined: Jun 2005
Posts: 656
Grafton
User
|
User
Joined: Jun 2005
Posts: 656
|
Unfortunatly you can only use "matWorldView" inside of a shader, so that wouldnt work.
Not two, not one.
|
|
|
|