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
1 registered members (AndrewAMD), 801 guests, and 6 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
Page 1 of 2 1 2
mtl.matrix problems? #44832
04/24/05 19:55
04/24/05 19:55
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
I was sitting down to do some scaling and shifting.

Gstudio 6.31.4 Pro. When I ran into a situation where I could only scale the texture "hardcoded" into the effect file.

Here are (2) level blocks. Left one is using material floor_two. Right one is using material floor_one. They are identical texture images. They are only different in the way I attempt scaling.

Could you advise?? It follows.

Thanks,
Eric




Code:
 var d3d_automaterial=1;


function mtl_scale()
{

mtl.matrix11 = float(10);
mtl.matrix12 = float(0);
mtl.matrix13 = float(0);
mtl.matrix14 = float(0);

mtl.matrix21 = float(0);
mtl.matrix22 = float(10);
mtl.matrix23 = float(0);
mtl.matrix24 = float(0);

mtl.matrix31 = float(0);
mtl.matrix32 = float(0);
mtl.matrix33 = float(0);
mtl.matrix34 = float(0);

mtl.matrix41 = float(0);
mtl.matrix42 = float(0);
mtl.matrix43 = float(0);
mtl.matrix44 = float(0);

}

material floor_one
{

effect = "

texture entSkin1;

technique one
{

pass p0
{

Texture[0] = (entSkin1);
TextureTransformFlags[0] = Count2;

TextureTransform[0]=
{
10.0, 0.0, 0.0, 0.0,
0.0, 10.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};


Colorop[0] = Modulate;
ColorArg1[0]=Texture;
ColorArg2[0] = Diffuse;
ColorOp[1] = Disable;

}
}

";
}

//////////////////////////////////////////////////
// Material Floor_Two
//

material floor_two
{
event = mtl_scale;

effect = "

matrix matMtl;
texture entSkin1;

technique one
{

pass p0
{

Texture[0] = (entSkin1);
TextureTransformFlags[0] = Count2;

TextureTransform[0] = (matMtl);

Colorop[0] = Modulate;
ColorArg1[0]=Texture;
ColorArg2[0] = Diffuse;
ColorOp[1] = Disable;

}
}

";
}



Re: mtl.matrix problems? [Re: Steempipe] #44833
04/25/05 07:40
04/25/05 07:40
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
As to my knowledge, external variables are referred to in angular brackets:

TextureTransform[0] = <matMtl>;

I'm not sure if that is the reason for the problem, but apart from that I see nothing obviously wrong in your code. The model looks as if the scale factors are zero. Maybe mtl_scale is never called?

In the effects.wdl you'll find an example how to use the material matrix for shifting and scaling textures. Compare your code with that example.

function mtl_eye_init()
{
// copy standard model material properties
mtl_copy(mat_model);
mtl.matrix11 = float(1); // default u scale
mtl.matrix22 = float(1); // default v scale
}

material auge_mdl
{
event = mtl_eye_init;
effect = "
matrix matMtl;

technique scale
{
// use material transformation matrix, leave everything else at default values
pass p0
{
TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
}
}

technique fallback { pass p0 { } }
";
}




Let me know if you find out the reason for the problem.

Re: mtl.matrix problems? [Re: jcl] #44834
04/25/05 19:40
04/25/05 19:40
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
I've checked things over.... Found that the "event function" is not being called from the "material effect". I have tried everything.

As a last resort; I added a model and assigned it the _same_ FX file that the level geometry uses, and the _same_ "event function" the level geometry is supposed to use.

The model texture transforms behave correctly, where the level block still does not.

Can I send you the small project with the code?? What address??

Thanks,
Eric

Re: mtl.matrix problems? [Re: Steempipe] #44835
04/26/05 09:46
04/26/05 09:46
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
From the manual:

material.event
This function is called once for every entity this material is assigned to as long as ENABLE_VIEW or ENABLE_RENDER aren't set.

If zero entities are assigned to the material, the event is executed zero times. What you probably want to use is a starter function, not an event function.

Re: mtl.matrix problems? [Re: jcl] #44836
04/26/05 18:50
04/26/05 18:50
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
You were correct, the material is working fine by using a starter func.

Thanks for your patience, and the answer.

Eric

Re: mtl.matrix problems? [Re: jcl] #44837
04/26/05 19:10
04/26/05 19:10
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline
Developer
Rigoletto  Offline
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
@steempipe: thank you very much for make the problem clear.

I have figured out to get a pointer/access to the material via starter function and will finish the tutorial, and make a new for just scaling and shifting level textures static and dynamicaly.

I find the adress for shifting and scaling, have someone a info about the other matrix-adresses. I can´t find it in the manual.

Re: mtl.matrix problems? [Re: Rigoletto] #44838
04/26/05 20:57
04/26/05 20:57
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
No prob, man. Glad that you are taking a keen interest in these things Rigoletto.

Okay.... if it helps anyone else, here is some code to spark ideas.

What is it??:
An example to allow a bit of user interaction with a material effect applied to level geometry.
This example is very simple; It shows a bit of scaling and shifting of the block texture.

Code:
 

//////////////////////////////////////////////////
// Example of adjusting the material.matrix
// while using an FX file on _Level Geometry_.
// Enlists the help of a Starter Function to
// call additional functions.
//
// Here we adjust the scale with key 2, or key 4
// And also make it scroll in a direction.
//
// Eric Hendrickson-Lambert (Steempipe)
//
// 4/26/04: -Put into operation
//
// Todo: -Add more examples, etc.
// -Tighten up code
//

var d3d_automaterial=1;


//bind <ffp_scale.fx>;


// Material assignment for the level geometry
// The name of the texture in WED.
material floor_one
{

// Because my effect file is not too long,
// I will just use the effect string inside the material.
// NOTE: If you use <effect_load>, then take
// the effect string out of here.

effect = "

matrix matMtl;
texture entSkin1;

technique one
{

pass p0
{

Texture[0] = <entSkin1>;

TextureTransformFlags[0] = Count2;
TexCoordIndex[0]=0; //1

TextureTransform[0] = <matMtl>;


Colorop[0] = Modulate;
ColorArg1[0]=Texture;
ColorArg2[0] = Diffuse;

}
}
";

}


function load_shader()
{
//effect_load(floor_one,"ffp_scale.fx");
wait(1);
}


function scale_x2() {

floor_one.matrix11 = float(2);
floor_one.matrix22 = float(2);

};

function scale_x4() {

floor_one.matrix11 = float(4);
floor_one.matrix22 = float(4);

};


function scroll_tex() {

floor_one.skill1 -= time;
floor_one.matrix31 = floatd(floor_one.skill1,500);
floor_one.matrix32 = floatd(floor_one.skill1,500);

}


starter floor_init {

// Set a default texture scale
//
floor_one.matrix11 = float(1);
floor_one.matrix22 = float(1);

//floor_one.skill1 = 50;

// Pressing key 2 will scale texture x2
// Pressing key 4 will scale texture x4
while(1)
{
if (key_2) { scale_x2(); };

if (key_4) {scale_x4(); };

scroll_tex();

wait(1);
}

}





Re: mtl.matrix problems? [Re: Steempipe] #44839
05/16/05 15:09
05/16/05 15:09
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I dont get it =\
I have created a map entity with a texture assigned...
I copied the code, wrote a main with a load_level...
And then? Should it work when I press 2 or 4?
nothing happens when I press them.

Jostie

Last edited by Jostie; 05/16/05 15:12.
Re: mtl.matrix problems? [Re: Joozey] #44840
05/16/05 18:13
05/16/05 18:13
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Is the name that you gave your texture in the WAD:
"floor_one"?? Without the quotes.

Re: mtl.matrix problems? [Re: Steempipe] #44841
05/16/05 19:01
05/16/05 19:01
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Now THAT explains a lot...
HURRAY!!! It works
Big thanx!

Jostie

p.s. Keep it going with your tutorials, they are great for noobs like me


Click and join the 3dgs irc community!
Room: #3dgs
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