Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 938 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Alpha Masked/Transparent Cubemaps #32489
08/30/04 10:20
08/30/04 10:20
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
Here is an "open" demo of the following.




Envbld demo - 2.5MB


=============================================================
The code, in case things get yanked from the server someday:
=============================================================


////////////////////////////////
Snippet #1
//
//

Code:


//////////////////////////////////////////////////////////////////
//
// Use alpha transparency with Envmap
//
//
// By: Eric Hendrickson-Lambert (Steempipe)
//
// If it whacks you computer.... Sorry.


bmap transenvmap_cube= <desertsm+6.tga>; // CubicEnvMap


function transenv_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
}


function transenv_init()
{

// Best to approach mipmapping this way with cubemap, I think.
bmap_to_cubemap(bmap_to_mipmap(mtl.skin1));

mtl.event=transenv_view;
mtl.enable_view=on;

}


material transenv
{
skin1=transenvmap_cube;

event=transenv_init;

effect=
"

texture mtlSkin1;

matrix matMtl;

Technique envmap
{

Pass p0
{

Texture[0]=<mtlSkin1>;

AddressU[0]=Clamp;
AddressV[0]=Clamp;

MagFilter[0]=Linear;
MinFilter[0]=Linear;
MipFilter[0]=Linear;

///////////////////////////////////
// Never trust any card's defaults
AlphaBlendEnable=True;
Zenable = True;
ZwriteEnable = True;
//////////////////////////////////

TexCoordIndex[0]=CameraSpaceReflectionVector;
TextureTransformFlags[0]=Count3;
TextureTransform[0]=<matMtl>;

ColorArg1[0]=Texture;
ColorOp[0]=Selectarg1;

ColorOp[1]=Disable;
AlphaOp[1]=Disable;



}

}
";
}



action ffp_TransEnvMap
{

my.transparent=on;
my.alpha=50;
my.material = transenv;

}





////////////////////////////////
Snippet #2
//
//

Code:


//////////////////////////////////////////////////////////////////
// This effect will take a texture and bumpmap it.
// Then it will display the cubicenv map based
// on a mask that is in the A channel of skintex.
//
// By: Eric Hendrickson-Lambert (Steempipe)


bmap maskedenvmap_cube= <desertsm+6.tga>; // CubicEnvMap
bmap maskedenvmap_skintex=<colormap.tga>; // Colormap + mask in alpha
bmap maskedenvmap_bumptex=<normalmap.bmp>; //DOT3 Normalmap


material* mtl1;

function mtl_copy(mtl_source)
{
mtl1 = mtl_source;
vec_set(mtl.ambient_blue,mtl1.ambient_blue);
vec_set(mtl.specular_blue,mtl1.specular_blue);
vec_set(mtl.diffuse_blue,mtl1.diffuse_blue);
vec_set(mtl.emissive_blue,mtl1.emissive_blue);
mtl.power = mtl1.power;

// set a lighting vector for DOT3 bumpmapping
// mtl.Skill4 = pixel_for_vec(vector(200,200,200),100,8888);


}



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

function MaskedEnvMap_init()
{

mtl_copy(mat_model);


bmap_to_cubemap(bmap_to_mipmap(mtl.skin1));
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);

mtl.event=MaskedEnvMap_view;
mtl.enable_view=on;
}

material MaskedEnvMap
{
skin1=maskedenvmap_cube;
skin2=maskedenvmap_skintex;
skin3=maskedenvmap_bumptex;

event=MaskedEnvMap_init;

effect=
"
texture mtlSkin2;
texture mtlSkin1;
texture mtlSkin3;

matrix matMtl;

//dword mtlSkill4; // the light vector

vector vecAmbient; // Ambient Light Vector

technique envmap
{
pass p0
///////////////////////////////////////////////////
// This pass will do DOT3 Bumpmapping
//
{
Texture[0]=<mtlSkin3>; // The Normalmap
Texture[1]=<mtlSkin2>; // The Colormap + the mask in alpha

AlphaBlendEnable=False;

MagFilter[0]=linear;
MinFilter[0]=linear;
MipFilter[0]=linear;

MagFilter[1]=linear;
MinFilter[1]=linear;
MipFilter[1]=linear;

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

TextureTransform[0]=
{
4, 0.0, 0.0, 0.0, //u scale of Normalmap
0.0, 4.0, 0.0, 0.0, //v scale of Normalmap
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};

TextureTransform[1]=
{
4.0, 0.0, 0.0, 0.0, //u scale of Colormap
0.0, 4.0, 0.0, 0.0, //v scale of Colormap
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};


TextureFactor =<vecAmbient>;

ColorArg1[0] = Texture; // stage 0 = DOT3 Normalmap
ColorOp[0] = DotProduct3;
ColorArg2[0] = TFactor;

ColorArg1[1] = Texture; // stage 1 - Colormap
ColorOp[1] = AddSigned;
ColorArg2[1] = Current;

ColorOp[2]=disable;
AlphaOp[2]=disable;

}


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

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

MagFilter[0]=linear;
MinFilter[0]=linear;
MipFilter[0]=linear;

MagFilter[1]=linear;
MinFilter[1]=linear;
MipFilter[1]=linear;

AlphaBlendEnable=True;
SrcBlend=SrcAlpha;
DestBlend=InvSrcAlpha;

Zenable=True;
ZwriteEnable=True;

TextureTransformFlags[0] = disable;
TexCoordIndex[0]=0;

ColorArg1[0] = current;
ColorOp[0] = selectarg1;


AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;

ColorArg1[1]=Texture;
ColorOp[1]=BlendCurrentAlpha;

}



}
";
}


action ffp_MaskedEnvMap
{

sun_angle.pan=80;
sun_angle.tilt=30;

my.ambient=45;
my.albedo=90;

my.transparent=off;

my.unlit=on;
my.material = MaskedEnvMap;

}




Re: Alpha Masked/Transparent Cubemaps [Re: Steempipe] #32490
08/30/04 12:33
08/30/04 12:33
Joined: Aug 2002
Posts: 2,692
California, USA
bupaje Offline
Expert
bupaje  Offline
Expert

Joined: Aug 2002
Posts: 2,692
California, USA
The demo looks great. I can see this effect would really increase the realism of many areas -very cool.


Find me at: |Stormvisions| Twitter|
Re: Alpha Masked/Transparent Cubemaps [Re: bupaje] #32491
08/30/04 17:55
08/30/04 17: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
Thanks, and glad it worked!

If anyone wants to get rid of the DOT3 pass, and has trouble, to just get this effect, let me know and I'll post a modified code.



Re: Alpha Masked/Transparent Cubemaps [Re: Steempipe] #32492
08/31/04 04:50
08/31/04 04:50
Joined: Jul 2004
Posts: 262
O
Otsego Offline
Member
Otsego  Offline
Member
O

Joined: Jul 2004
Posts: 262
Steempipe, is it possible to use this shader to make puddles with reflections? With alpha masked cubemaps it would be possible, wouldnt it? To my mind this effect would be really cool.

Re: Alpha Masked/Transparent Cubemaps [Re: Otsego] #32493
08/31/04 10:24
08/31/04 10:24
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
Quote:

Steempipe, is it possible to use this shader to make puddles with reflections? With alpha masked cubemaps it would be possible, wouldnt it? To my mind this effect would be really cool.




Good idea. I think something along that line is possible. Just need someone to tackle it (hint hint) Or, wait for about 2-3 weeks when I get back to the water junk.

Re: Alpha Masked/Transparent Cubemaps [Re: Steempipe] #32494
08/31/04 10:29
08/31/04 10:29
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
In case there is a problem with the "transenv" code with a particular card, try this version.

I am sure there is some extra, irrelevant, code in it....

Code:
 

//////////////////////////////////////////////////////////////////
//
// Use alpha transparency with Envmap
//
//
// By: Eric Hendrickson-Lambert (Steempipe)
//
// If it whacks you computer.... Sorry.
//
// 8-30-04: Updated to help ensure it runs on geforce2(?)
//

bmap transenvmap_cube= <desertsm+6.tga>; // CubicEnvMap


function transenv_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
}


function transenv_init()
{

// Best to approach mipmapping this way with cubemap, I think.
bmap_to_cubemap(bmap_to_mipmap(mtl.skin1));

mtl.event=transenv_view;
mtl.enable_view=on;

}


material transenv
{
skin1=transenvmap_cube;

event=transenv_init;

effect=
"

texture mtlSkin1;

matrix matMtl;

vector vecAmbient; //<<---------
vector vecSpecular; //<<---------
vector vecDiffuse; //<<---------
vector vecEmissive; //<<---------

Technique envmap
{

Pass p0
{

Texture[0]=<mtlSkin1>;

AddressU[0]=Clamp;
AddressV[0]=Clamp;

MagFilter[0]=Linear;
MinFilter[0]=Linear;
MipFilter[0]=Linear;

///////////////////////////////////
// Never trust any card's defaults
AlphaBlendEnable=True;
Zenable = True;
ZwriteEnable = True;

SrcBlend=srcAlpha; //<<---------
DestBlend=InvSrcAlpha; //<<---------
BlendOp=Add; //<<---------
Lighting=True; //<<---------

AmbientMaterialSource=<vecAmbient>; //<<---------
DiffuseMaterialSource=<vecDiffuse>; //<<---------
SpecularMaterialSource=<vecSpecular>; //<<---------
EmissiveMaterialSource=<vecEmissive>; //<<---------
//////////////////////////////////

TexCoordIndex[0]=CameraSpaceReflectionVector;
TextureTransformFlags[0]=Count3;
TextureTransform[0]=<matMtl>;



ColorArg1[0]=Texture;
ColorOp[0]=SelectArg1;

Alphaop[0]=SelectArg1; //<<---------
AlphaArg1[0]=Diffuse; //<<---------


ColorOp[1]=Disable;
AlphaOp[1]=Disable;



}

}
";
}



action ffp_TransEnvMap
{

my.transparent=on;
my.alpha=60;
my.material = transenv;

}




Re: Alpha Masked/Transparent Cubemaps [Re: Steempipe] #32495
08/31/04 23:41
08/31/04 23:41
Joined: Jul 2004
Posts: 262
O
Otsego Offline
Member
Otsego  Offline
Member
O

Joined: Jul 2004
Posts: 262
In Antwort auf:

Good idea. I think something along that line is possible. Just need someone to tackle it (hint hint) Or, wait for about 2-3 weeks when I get back to the water junk.




Thanks, I can wait, thats not a problem. Perhaps then i'll ask for a quite simple watershader, too.

Re: Alpha Masked/Transparent Cubemaps [Re: Otsego] #32496
09/01/04 22:31
09/01/04 22:31
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
When you get back to watershaders, @Steempipe, please be so kind as to go here.

Sorry to go offtopic but I had to tell you

onTopic: Cool thing! I guess this would be best to use with bubbles or something similar?

Last edited by The Matrix; 09/01/04 22:32.

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: Alpha Masked/Transparent Cubemaps [Re: Thomas_Nitschke] #32497
09/01/04 23:10
09/01/04 23:10
Joined: Nov 2003
Posts: 1,380
Switzerland; Zurich
S
Sebe Offline
Serious User
Sebe  Offline
Serious User
S

Joined: Nov 2003
Posts: 1,380
Switzerland; Zurich
@Steempipe
Would it be possible to mix your envmap/bumpmap water ("watertestground", ffp_water and ffp_water2, the one with gradient and the other without) with this transparent env mapping? This would be a great alternative to your (wonderful) river shader, and with the envmap every user without pro could fake reflecting water. I tried about 3 hours to mix these two shaders but there was no success

Re: Alpha Masked/Transparent Cubemaps [Re: Steempipe] #32498
09/02/04 05:43
09/02/04 05:43
Joined: Aug 2004
Posts: 122
A small town near Cologne
E
Elitegunner Offline
Member
Elitegunner  Offline
Member
E

Joined: Aug 2004
Posts: 122
A small town near Cologne
Hi Steempipe!
When get you the new Shader Codes to download on your Site?

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