|
0 registered members (),
938
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Alpha Masked/Transparent Cubemaps
#32489
08/30/04 10:20
08/30/04 10:20
|
Joined: Dec 2003
Posts: 1,097 Maryland, USA
Steempipe
OP
Serious User
|
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: Otsego]
#32493
08/31/04 10:24
08/31/04 10:24
|
Joined: Dec 2003
Posts: 1,097 Maryland, USA
Steempipe
OP
Serious User
|
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
OP
Serious User
|
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
Otsego
Member
|
Member
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
Thomas_Nitschke
Senior Developer
|
Senior Developer
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?
|
|
|
|