Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
WorldViewInverse no definition on manual? #209420
06/02/08 22:07
06/02/08 22:07
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline 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] #209687
06/05/08 00:02
06/05/08 00:02
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
will mul(matWorld,matViewInv) do it?

Re: WorldViewInverse no definition on manual? [Re: MMike] #209764
06/05/08 15:52
06/05/08 15:52
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

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;

Code:

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;

Code:
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;
Code:
 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: Grafton] #209784
06/05/08 18:23
06/05/08 18:23
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
hum i see you do muliply matworld with matview,
when will mul(matworld,matViewInv) do equal matWorldViewInv)?
i tryed and i seeams it does..

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 Offline OP
Serious User
MMike  Offline 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
G
Grafton Offline
User
Grafton  Offline
User
G

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: Grafton] #209815
06/05/08 21:44
06/05/08 21:44
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
oh yes the float needs to be var thanks !

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 Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
i found a quicker way:

Code:
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 Offline
Member
Mysterious  Offline
Member

Joined: May 2006
Posts: 133
ME
Hi this is a good idea... but I guess you can make it shorter and faster
Code:
while(1){
 
  mat_inverse(mtl.matrix, matWorldView); // copy the inverse of matWorldView to matWorldViewInverse
  
wait(1);
}
	
}


Regards
Mysterious smile

Re: WorldViewInverse no definition on manual? [Re: Mysterious] #212671
06/23/08 17:45
06/23/08 17:45
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
Unfortunatly you can only use "matWorldView" inside of a
shader, so that wouldnt work.


Not two, not one.
Page 1 of 2 1 2

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