Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by AndrewAMD. 12/05/23 10:56
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 (3run, AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip), 605 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
CubicEnvMappping on models' parts w alpha channel #53065
08/22/05 20:11
08/22/05 20:11
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
This code was made by Steempipe and modified by me. And that means that, probably, there is a better way to code this.
You need to make a alpha channel on the textureof your model in a program like photoshop, and on this alpha channel, paint with white color all the parts of the model that you want to use the effect in.




Code:
 
bmap maskedenvmap_cube= <sk_free2_256+6.tga>; // CubicEnvMap
bmap maskedenvmap_skintex=<AuditTexture.tga>; // Colormap + mask in alpha

function MaskedEnvMap_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
mat_scale(mtl.matrix,1,-1,1);
}

function MaskedEnvMap_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event=MaskedEnvMap_view;
mtl.enable_view=on;
}

material MaskedEnvMap
{
skin1=maskedenvmap_cube;skin2=maskedenvmap_skintex;
event=MaskedEnvMap_init;

effect=
"
texture mtlSkin2;texture mtlSkin1;texture entSkin1;
matrix matMtl;
technique envmap
{
pass p0
// This pass will apply the Texture to the car
//
{
Texture[0] = <entSkin1>; TextureFactor = 0xC0FFFFFF;
ColorArg1[0] = Texture; ColorArg2[0] = current;
ColorOp[0] = selectarg1;
}

pass p1
// This pass will apply the Cubemap to a mask
//
{

Texture[0]=<mtlSkin2>; // The blendmap in Alpha
Texture[1]=<mtlSkin1>; // The cubemap

AlphaBlendEnable=True;
SrcBlend=SrcAlpha;
DestBlend=InvSrcAlpha;
Zenable=True;
ZwriteEnable=True;
AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
Texture[1] = <mtlSkin1>;TextureFactor = 0x80FFFFFF;
colorArg1[1]=Texture;ColorArg2[1] = Current;
colorOp[1]=BlendFactorAlpha;
}

}
";
}

action ffp_MaskedEnvMap
{
my.material = MaskedEnvMap;
}



Last edited by Sorcerer; 08/22/05 20:15.
Re: CubicEnvMappping on models' parts w alpha channel [Re: XNASorcerer] #53066
08/22/05 20:26
08/22/05 20:26
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline
User
Schmerzmittel  Offline
User

Joined: Aug 2005
Posts: 512
Bayern
Thats good. I use this too. But the collors are very ... opposite from dark????

I make the standard colors from my models extrem dark, so the colors with envmap are good. (i know....bad english )

P.s. Where can i found a tut or a referenc, that explain the scripts? For GS i mean. THX!!!


YOUR CAR LOOKS VERY NICE! I LIKE THE REFLECTIONS!


A7 Com V7.80
Re: CubicEnvMappping on models' parts w alpha channel [Re: Schmerzmittel] #53067
08/22/05 20:40
08/22/05 20:40
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Put all the code inside of a wdl file and save it as CubicEnvMappping.wdl. Then include inside your main wdl like this:
include <CubicEnvMappping.wdl>;

Now give the ffp_MaskedEnvMap action to your model.

Ps.: Don't forget to make an alpha channel inside the model's texture.

Re: CubicEnvMappping on models' parts w alpha chan [Re: XNASorcerer] #53068
08/22/05 20:57
08/22/05 20:57
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Thanks for posting your script! Thanks for posting it complete, and with screenshots! That all together helps more than thousand explanations!

Quote:

colorArg1[1]=Texture;ColorArg2[1] = Current;




Here is the important difference, I guess!

Re: CubicEnvMappping on models' parts w alpha chan [Re: Pappenheimer] #53069
08/22/05 21:01
08/22/05 21:01
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
If you want to make parts of your model invisible, just comment out the pass0 of the material like this:

Code:
 
...
// pass p0
// ///////////////////////////////////////
// // This pass will apply the Texture to the car
// //
// {
// Texture[0] = <entSkin1>; TextureFactor = 0xC0FFFFFF;
// ColorArg1[0] = Texture;
// ColorArg2[0] = current;
// ColorOp[0] = selectarg1;
// }
...





Re: CubicEnvMappping on models' parts w alpha chan [Re: XNASorcerer] #53070
08/23/05 08:19
08/23/05 08:19
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Another think that I forgot to mention...
If you want you can add differents effects to differents parts of the model. Just add another Texture with a different alpha mask and another skin inside the material, then another pass that uses that new skin. The only think that I didn't manage to do was a very different effect. Maybe some of Shader's Gurus could do that. The code would be like this:

Code:
 

bmap maskedenvmap_cube= <sky_cube+6.tga>; // CubicEnvMap
bmap maskedenvmap_skintex=<AlphaMaskedTexture1.tga>; // Colormap + mask in alpha





bmap maskedenvmap_skintex2=<AlphaMaskedTexture2.tga>; //Colormap + mask in alpha






function MaskedEnvMap_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
mat_scale(mtl.matrix,1,-1,1);
}

function MaskedEnvMap_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event=MaskedEnvMap_view;
mtl.enable_view=on;
}

material MaskedEnvMap
{
skin1=maskedenvmap_cube;skin2=maskedenvmap_skintex;

skin3=maskedenvmap_skintex2;


event=MaskedEnvMap_init;

effect=
"
texture mtlSkin2;texture mtlSkin1;texture entSkin1;
matrix matMtl;
technique envmap
{
pass p0
// This pass will apply the Texture to the car
//
{
Texture[0] = <entSkin1>; TextureFactor = 0xC0FFFFFF;
ColorArg1[0] = Texture; ColorArg2[0] = current;
ColorOp[0] = selectarg1;
}

pass p1
// This pass will apply the Cubemap to a mask
//
{

Texture[0]=<mtlSkin2>; // The blendmap in Alpha
Texture[1]=<mtlSkin1>; // The cubemap

AlphaBlendEnable=True;
SrcBlend=SrcAlpha;
DestBlend=InvSrcAlpha;
Zenable=True;
ZwriteEnable=True;
AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
Texture[1] = <mtlSkin1>;TextureFactor = 0x80FFFFFF;
colorArg1[1]=Texture;ColorArg2[1] = Current;
colorOp[1]=BlendFactorAlpha;
}

pass p2
///////////////////////////////////////////
// This pass will applay the Cubemap to a second mask
//
{
texture[0]=<mtlSkin3>;
texture[1]=<mtlSkin1>;

alphaBlendEnable=true;
SrcBlend=SrcAlpha;
DestBlend=InvSrcAlpha;
Zenable=true;
ZwriteEnable=True;

colorArg1[0]=Texture;
colorOp[0]=Modulate2x;
colorArg2[0]=Diffuse;
colorArg1[1]=Texture;
textureFactor=0xC0FFFFFF; // -> C0=75%, 80=50%, 40=25%
colorOp[1]=blendFactorAlpha;

addressU[1]=Clamp;
addressV[1]=Clamp;
texCoordIndex[1]=cameraSpaceReflectionVector;
textureTransformFlags[1]=Count3;
textureTransform[1]=<matMtl>; // transform camera space back to world space
}

}
";
}

action ffp_MaskedEnvMap
{
my.material = MaskedEnvMap;
}





Re: CubicEnvMappping on models' parts w alpha chan [Re: XNASorcerer] #53071
08/23/05 18:45
08/23/05 18:45
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Any screens to see the effect? Please!


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