Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Passing Vars #127481
05/01/07 08:57
05/01/07 08:57
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline OP
Expert
Slin  Offline OP
Expert

Joined: May 2005
Posts: 2,713
Lübeck
This is what my script looks like:
Code:

function mat_model_event();
material mat_model_depth
{
flags = enable_tree;
event = mat_model_event;
effect = "renderdepthmap.fx";
}

function mat_model_event()
{
if(render_view == depth_cam)
{
my.material = mat_model_depth;
}else
{
my.material = mat_model;
mtl.skill1 = float(front);
mtl.skill2 = float(back);
}
}



mat_model has the same flag and event then mat_model_depth.

The .fx file looks like this:
Code:

//---------------------------------------------------------
// Depthmap shader by ello
//---------------------------------------------------------

struct VS_IN
{
float4 position : POSITION;
};

struct VS_OUT
{
float4 position : POSITION;
float depth : TEXCOORD0;
};

float mtlSkill1;
float mtlSkill2;

float4x4 matWorldViewProj : WorldViewProjection;


VS_OUT mainVS (VS_IN In)
{
VS_OUT Out;
Out.position = mul(In.position, matWorldViewProj);
Out.depth = ((Out.position.z - mtlSkill1)/1000) * ((Out.position.z - mtlSkill2)/1000);
return Out;
}

float4 mainPS (VS_OUT In) : COLOR0
{
return In.depth;
}

technique depth
{
pass p0
{
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}



If front and back are both 0 everything is fine but if they are above 0 it seems as if they are very big.

What have I done wrong?

Thanks,
Slin

Re: Passing Vars [Re: Slin] #127482
05/01/07 13:41
05/01/07 13:41
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Eh, I've also had this problem. Passing vars to shaders is a little... "off".

I had to use the pixel_for_vec() function (which means you can pass 4 vars in one skill ).

var pix[4];
pix[0] = front;
pix[1] = back;
pix[2] = 0;
pix[3] = 0;
mtl.skill1 = pixel_for_vec(pix, pix[3], 8888);

float4 mtlSkill1;
...
Out.depth = ((Out.position.z - mtlSkill1.x)/1000) * ((Out.position.z - mtlSkill1.y)/1000);

The variables will automatically be converted to float values...


xXxGuitar511
- Programmer
Re: Passing Vars [Re: xXxGuitar511] #127483
05/01/07 14:12
05/01/07 14:12
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline OP
Expert
Slin  Offline OP
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Thanks,
but it makes no difference.
Any other idea?

Re: Passing Vars [Re: Slin] #127484
05/01/07 14:35
05/01/07 14:35
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
That should work. Make sure it's not in your other code...


xXxGuitar511
- Programmer
Re: Passing Vars [Re: xXxGuitar511] #127485
05/01/07 15:03
05/01/07 15:03
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline OP
Expert
Slin  Offline OP
Expert

Joined: May 2005
Posts: 2,713
Lübeck
I tried it like this:
mtl.skill1 = pixel_for_vec(vector(1000,1200,0),0, 8888);

The shader gets displayed as if it´s nullvector.

Re: Passing Vars [Re: Slin] #127486
05/01/07 23:39
05/01/07 23:39
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Code:
function mat_model_event()
{
if(render_view == depth_cam)
{
my.material = mat_model_depth;
}else
{
my.material = mat_model;
mtl.skill1 = float(front);
mtl.skill2 = float(back);
}
}



I dont understand at all what your code is trying to do, but just an idea.. this seems to set the mtl.skill for mat_model, NOT mat_model_depth, because you change the current material before changing those variables. Try using a global, and only update the mtl.skills when you switch back to to mat_model_depth.

Maybe I'm just misinterpreting what you are doing though, in that case just ignore me


Sphere Engine--the premier A6 graphics plugin.

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