Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, Quad), 761 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
applying fx-file in MED6.4? #63121
02/02/06 22:41
02/02/06 22:41
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
(I posted this already in the model-section...without success. I know cross-posting = no good...please don't hit me now!)

So far I had to split my tree models into two seperate models (trunk and branches) to be able to apply a wind-shader that woulden't affect the trunk. Now in 6.4 there seems to be the possibility to apply to each texture a seperate fx-file wich means I woulden't have to split the tree model. I could just assign the branch uv's to the branch texture (wich I applay as 2. Texture on the tree model) and apply the fx-file to it. However it dident work for me (I don't even see the tree in WED anymore)...can this work with vertex shader at all???. Any help would be appreciated...The deal is as usual: Nice Trees for working code!

The fx-file looks like that:
(adressing entSkin2 diden't change anything. Also loading an external texSkin diden't work)

Code:

texture entSkin1;

matrix matWorldViewProj;
matrix matWorldView;

vector vecFog;
vector vecTime;

technique tree
{
pass p0
{
texture[0]=<entSkin1>;
zWriteEnable=true;
alphaTestEnable=true;
cullMode=none;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[8]=<matWorldView>;
vertexShaderConstant[16]=<vecFog>;
vertexShaderConstant[32]=<vecTime>;
vertexShaderConstant[33]={0.0f,0.5f,1.0f,2.0f}; // common constants
vertexShaderConstant[34]={-0.16161616f,0.0083333f,-0.00019841f,0.000002755731f}; // {-1/3!,1/5!,-1/7!,1/9!}
vertexShaderConstant[35]={4.0f,1.57079632f,3.14159265f,6.28318530f}; // {4.0,pi/2,pi,pi*2}
vertexShaderConstant[36]={1.07f,0.0f,0.0f,0.0f}; // fixup factor

vertexShaderConstant[40]={2.5f,1.0f,0.5f,0.1f}; // wave distort x
vertexShaderConstant[41]={3.0f,1.5f,1.25f,0.1f}; // wave distort y
vertexShaderConstant[42]={-0.5f,-0.01f,-0.04f,-0.01f}; // wave distort z
vertexShaderConstant[43]={-0.1f,-0.2f,0.1f,0.05f}; // wave dir x
vertexShaderConstant[44]={-0.005f,-0.01f,-0.005f,-0.0025f}; // wave dir y
//vertexShaderConstant[45]={0.02f,0.04f,0.05f,0.1f}; // wave speed
vertexShaderConstant[45]={0.003f,0.006f,0.008f,0.05f}; // wave speed
vertexShaderConstant[46]={0.35f,0.1f,0.1f,0.04f}; // lighting wave scale
vertexShaderConstant[47]={0.6f,0.8f,0.3f,0.0f}; // lighting scale bias

vertexShader=
asm
{
vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

mov r1.w,c16.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position (v0 is the position without sinusodial warping!)
add r0,r0,-c16.x // distance-fog_start
mad r0.x,-r0.x,c16.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog,r0.x,c33.x // clamp with custom max value

mul r0,c43,v0.x // use vertex pos x as inputs to sinusoidal warp
mad r0,c44,v0.y,r0 // use vertex pos y as inputs to sinusoidal warp

mov r1,c32.w // get current time
mad r0,r1,c45,r0 // add scaled time
frc r0.xy,r0 // take fraction of all 4 components
frc r1.xy,r0.zwzw
mov r0.zw,r1.xyxy

mul r0,r0,c36.x // multiply by fixup factor (due to inaccuracy of taylor series)
sub r0,r0,c33.y // subtract 0.5
mul r1,r0,c35.w // range -pi to pi

mul r2,r1,r1 // wave_vec^2
mul r3,r2,r1 // wave_vec^3
mul r5,r3,r2 // wave_vec^5
mul r7,r5,r2 // wave_vec^7
mul r9,r7,r2 // wave_vec^9

mad r0,r3,c34.x,r1 // wave_vec-(wave_vec^3)/3!
mad r0,r5,c34.y,r0 // +(wave_vec^5)/5!
mad r0,r7,c34.z,r0 // -(wave_vec^7)/7!
mad r0,r9,c34.w,r0 // +(wave_vec^9)/9!

dp4 r3.x,r0,c40
dp4 r3.y,r0,c41
dp4 r3.zw,r0,c42

sub r4,c33.z,v7.y // attenuate sinusoidal warping by (1-uv.y)^2
mul r4,r4,r4
mul r3,r3,r4

mov r2.w,v0
add r2.xyz,r3,v0 // add sinusoidal warping to grass position
m4x4 oPos,r2,c0 // transform position to clip space

dp4 r1.x,r0,c46 // scale and add sin waves together
mad oD0,c47.xzxz,-r1.x,c47.y // scale and bias color values (green is scaled more than red and blue)
mov oT0.xy,v7.xy // output uvs
};

pixelShader=
asm
{
ps.1.3
def c0,1,1,1,1
def c1,0,0,0,0
tex t0 // sample t0
mov r0,t0
cnd r0.a,r0.a,c0,c1 // if(r0.a>0.5){r0.a=1;}else{r0.a=0;}
//mul_x2 r0.rgb,r0,v0 // modulate with lighting
};
}
}

Re: applying fx-file in MED6.4? [Re: Loopix] #63122
02/03/06 15:38
02/03/06 15:38
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
As far as I know, these "integrated" fx-files are somewhat not completely functional at the moment. At least that's what I experienced with multi-texturing shaders that always worked fine before... Sorry for demotivating you


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: applying fx-file in MED6.4? [Re: Thomas_Nitschke] #63123
02/03/06 15:59
02/03/06 15:59
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Arghh! And I thought this would make it all sooo easy...hope conitec 's gonna fix this very soon!

Thanks anyway!

Re: applying fx-file in MED6.4? [Re: Loopix] #63124
02/03/06 16:27
02/03/06 16:27
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
I just found something in addition! Unfortunately, I closed the window and thus lost the link, but somewhere here on the fora jcl said that fx-files that have been directly attached to a model require the model to have an action applied to it that takes care of additional textures, material skills and so on. If the effect doesn't need any of those things, I stick with my old theory though


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: applying fx-file in MED6.4? [Re: Thomas_Nitschke] #63125
02/03/06 20:22
02/03/06 20:22
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Thanks for this info! But how would the action look like (applying two skins on the model)??? Sorry for being dumb

Re: applying fx-file in MED6.4? [Re: Loopix] #63126
02/04/06 12:28
02/04/06 12:28
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
As I said, jcl stated this somewhere here. I'm afraid I've never tried it myself yet. My guess is that, for example if you're using a water shader which uses material skills to determine flow speed or something similar, you'd have to attach to the model a simple action that reads like this
Code:

action whatever
{
theMaterial.skill1 = float(someValue);
}


in order for the material skill's value to be converted to floating point. As far as I know, shaders can't use fixed-point vars which, in this case, would cause the shader not to function properly.
Another example: If your shader uses material skins, you'd probably need an action which assigns the proper material to the model. Otherwise the shader won't have a clue about which material's skin to use.
All this is just guesswork though, if I were you I'd maybe PM jcl so he could explain this in more detail...

Last edited by The Matrix; 02/04/06 12:30.

Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: applying fx-file in MED6.4? [Re: Thomas_Nitschke] #63127
02/04/06 13:06
02/04/06 13:06
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
"PM jcl so he could explain this in more detail... "

Better post in Beta Forum or Ask Conitec!

Re: applying fx-file in MED6.4? [Re: Pappenheimer] #63128
02/04/06 13:13
02/04/06 13:13
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
Yah, right... I should have thought of that


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: applying fx-file in MED6.4? [Re: Thomas_Nitschke] #63129
02/13/06 12:06
02/13/06 12:06
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
well, i tried to attach an effect to a special skin and it works. no problem. maybe you can send me your tree and i'll give it a shot


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
Re: applying fx-file in MED6.4? [Re: ello] #63130
02/13/06 14:36
02/13/06 14:36
Joined: Mar 2002
Posts: 221
USA
zefor Offline
Member
zefor  Offline
Member

Joined: Mar 2002
Posts: 221
USA
try this:
instead of texture=entSkin1; try: texture=mtlSkin1;

At the top of your script have something like:
bmap branches = <branchtexture.tga>; //whatever your texture is called

And replace: texture[0]=<entSkin1>; with texture[0]=<mtlSkin1>

make sure you have the "branchtexture.tga" in your work folder (whatever the braches texture on you branches is).
Under where you call your material in script:
material wind_branches
{
skin1 = branches;
etc......
}

This in not tested, and I am no expert, but worth a try.

Last edited by zefor; 02/13/06 14:37.

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