Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help in this effect chrome !!!!!!!!!!!!!! #174182
12/21/07 13:16
12/21/07 13:16
Joined: Aug 2007
Posts: 49
Rio Claro, São Paulo, Brazil
C
Cristiano_Iost Offline OP
Newbie
Cristiano_Iost  Offline OP
Newbie
C

Joined: Aug 2007
Posts: 49
Rio Claro, São Paulo, Brazil
Hello all,

I have this effect that aply the chrome in the model:

float4x4 matWorldViewProj;
float4x4 matWorldInv;
float4x4 matWorldView;
float4x4 matWorld;

float4x4 matViewInv;
float4x4 matView;
float4 vecSkill41;
float4 mtlSkill1;
float4 vecSunDir;

float4 vecFog;

float DoFog(float3 Pos)
{
// convert the vector position to view space to get it's depth (.z)
float3 P = mul(Pos,matWorldView);
// apply the linear fog formula
return saturate((vecFog.y-P.z) * vecFog.z);
}

void mainVS(
in float4 inPos : POSITION,
in float3 inNormal: NORMAL,
in float2 inXY : TEXCOORD0,
out float4 Pos : POSITION,
out float2 chrome : TEXCOORD0,
out float2 uv : TEXCOORD1,
out float oNrm : COLOR0,
out float Fog : FOG
)
{
// transform the vector position to screen coordinates
Pos = mul(inPos,matWorldViewProj);
// rotate and normalize the normal
float3 N = normalize(mul(inNormal,matWorldInv));
// Add fog
Fog = DoFog(inPos);
// convert texture coordinates or do other stuff
oNrm = mul(inNormal,matWorld); //pass normal
chrome=mul(N,matView)*mtlSkill1.x; //mtlSkill1 contains the scale of the reflMap
uv = inXY;
}

texture mtlSkin1;
sampler basemap = sampler_state
{
texture=(mtlSkin1);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
//AddressU = Mirror;
//Addressv = Mirror;
};

texture entSkin1;
sampler entskin = sampler_state
{
texture=(entSkin1);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};



float4 mainPS(
in float2 chrome : TEXCOORD0,
in float2 uv : TEXCOORD1,
in float iNrm : COLOR0
) : COLOR
{
//change shinyness where "2" stands , play around whith it till it fits your needs
//skill41-43 contains rgb values, skill44 contains power value
float4 result=0.5*dot(tex2D(basemap,chrome),vecSkill41.w)-0.5;
//change the "2" below to adjust the shyniness, too
result*=result/2+float4(vecSkill41.xyz,1)*tex2D(basemap,chrome);
float sunL = 0.5*dot(iNrm,-vecSunDir)+0.5; //sunLight

//return (result-sunL+tex2D(entskin,uv))*pow(sunL,2); //dark metallic, mixed with entSkin1
return (result+tex2D(entskin,uv))*sunL; //standard, mixed with entSkin1
}

technique better_looking_chrome
{
pass base
{
//CullMode = none;
VertexShader=compile vs_2_0 mainVS();
PixelShader=compile ps_2_0 mainPS();
}
}

technique fallback_chrome
{
pass base
{
//CullMode = none;
VertexShader=compile vs_1_1 mainVS();
PixelShader=compile ps_1_4 mainPS();
}
}

and the script for the function is:

bmap chrome_lookup=<cromo.tga>;

material mat_chrome
{
skin1 = chrome_lookup;
effect="chrome.fx";
}

function chrome()// chamar essa função no script desejado.
{
my.material = mat_chrome;
my.Skill41 = float(random(2)-1); //r
my.Skill42 = float(random(2)-1); //g
my.Skill43 = float(random(2)-1); //b
my.Skill44 = float(1.0); //specular power
mat_chrome.skill1 = float(1); //reflectmap scale
}

My question is: how do i to aply the effect only in the first skin of the model ? This effect act in all the skins, and no only in the part that i want in model.

For example, the model have 3 skins made in MED (skin0, skin1, skin2) and i want aply the effect only in the skin0 or skin1.

OBS: don´t works aplying the effect in MED, i tried this.

Re: Help in this effect chrome !!!!!!!!!!!!!! [Re: Cristiano_Iost] #174183
12/21/07 21:33
12/21/07 21:33
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
just change the material the object has, when the first skin is not shown.
also from now on, when showing code use the code tags so we can see how its formatted because nobody can read it the way it is like that.

Re: Help in this effect chrome !!!!!!!!!!!!!! [Re: lostclimate] #174184
01/13/08 11:15
01/13/08 11:15
Joined: Jul 2006
Posts: 511
Germany,NRW
KMS Offline
User
KMS  Offline
User

Joined: Jul 2006
Posts: 511
Germany,NRW
Hi @all!
I also would like to use this nice shader in my level.But I have the problem,that it doesn't work with A7.The compiled level from Earthcontrol.de is also only working with the A6.The compiled A7-level shows no effect.
Could anyone try to modify the code for A7? I would be very happy!


You need full animated lowpoly-fishes?Look at
http://www.projekt-3d.de/pages/shop2pag.html
Re: Help in this effect chrome !!!!!!!!!!!!!! [Re: KMS] #174185
01/13/08 18:25
01/13/08 18:25
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
i just ran the wdl from the zip and it works with a7 , too. with no problems. i can also load any entity and it shows up the desired effect, so i dont knwo why it doesnot work for you

Re: Help in this effect chrome !!!!!!!!!!!!!! [Re: ello] #174186
01/14/08 03:20
01/14/08 03:20
Joined: Jul 2006
Posts: 511
Germany,NRW
KMS Offline
User
KMS  Offline
User

Joined: Jul 2006
Posts: 511
Germany,NRW
Ok,it seems to be my radeon9200Se.With geoforceFx5200 it works fine!

Last edited by KMS; 01/14/08 04:22.

You need full animated lowpoly-fishes?Look at
http://www.projekt-3d.de/pages/shop2pag.html

Moderated by  Blink, Hummel, Superku 

Gamestudio download | 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