Fixed-Function Terrain Multi-Texturing Effect

Posted By: Steempipe

Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 06:14

I have been working on a Fixed-Function texture stage effect for mulit-texturing terrain. This is meant to be a fallback in the pixelshaders and also as an alternative.

This is using a 2 pass effect to keep stages under (2) in each pass. The textures are tiled using the texture transform matrix. The sand texture is blended using the alpha channel of a TGA.

I have included some fallback techniques, do not know if they are actually needed but I was having fun playing with this. I also may not be able test the fallbacks correctly. Feedback here, please.

This is done on 3DGameStudio A6.20.2 comm with a Radeon 9200 128 MB.

Goto my web site to get the Effect File, the Demo, or other info



This is adding another pass with a different alphamap and texture:



Please post mods, improvements, and if it does not work on your card please post the info pertaining to your card so I can know/learn.

Eric

Posted By: Cellulaer

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 07:24


I get the Default Effect on a Geforce 4 Ti 4400 (1.3 Pixel Shaders).
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 07:41

Thanks for letting me know!! Hope it works on a wide array of cards.

Note:
The downloadable demo does not have the pass with the grey cracked crap. It should look like the first screenshot.

Eric

Posted By: makai

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 08:15

hey really great job steem!
the default worked for me too, with my nvidia geforce 4 go 64 (thats the mx version which doesn't support many shaders..)


but there are some graphic errors, some parts of the terrain seem to transparent.. have a look on this :





Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 10:00

We'll have to fiddle with it.
I don't get that problem here, so it will be hard to troubleshoot.

Where does your alphamap live? Is it an entSkin or a mtlSkin?
Could you try adding the "my.tranparent=off" to your action, just in case?

Maybe try adding "zenable=true"

technique ffp_terrain_tex
{
pass P0
{

alphablendenable=false;
zenable=true; //<<<<<<<<<<<<<<<<

If need be can I get a publish of that level and see how it runs on my card?

I'll think on it a bit and get back to you in a Private message.

Eric

Posted By: ello

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 15:33

hey, great job. this works on a geforce2. this could be real helpfull fallback for my current work. thx for sharing your worx .
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 18:15

@ello: Thanks, this is good news.

@makai:
I had weird results with the textures if put the alphaTGA in the entSkins. I kept them as mtlSkins.

Lets see.... you could try adding the new things ("//<<<<<<< NEW") in the code, and playing with that. This might give you a start in a direction to tinker with it.

Let me know what happens so I can update the demo if need be before too many people get a hold of it.

technique ffp_terrain_tex
{
pass P0
{

alphablendenable=false;
alphatestenable=false; //<<<<<<< NEW
zenable=true; //<<<<<<< NEW
zwriteenable=true; //<<<<<<< NEW
cullmode=none; //<<<<<<< NEW
//
// Stage 0
//
Texture[0] = <entSkin1>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;




TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
texcoordindex[0]=0;

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

alphaop[0]=disable;

//
//stage 1
//
colorop[1]=disable;
alphaop[1]=disable;

}

pass P1
{

// We need to enable alphablending

alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;
alphatestenable=true; //<<<<<<< NEW
cullmode=none; //<<<<<<< NEW
zenable=false; //<<<<<<< NEW
zwriteenable=false; //<<<<<<< NEW

//
// Stage 0
//
Texture[0] = <mtlSkin2>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

//
// We don't want the alphamap to tile
//
TextureTransformFlags[0] = disable;

texcoordindex[0]=1;

ColorArg1[0] = current;
ColorOp[0] = selectarg1;
alphaarg1[0] = texture | alphareplicate;
alphaop[0]=selectarg1;

//
// Stage 1
//
Texture[1] = <entSkin2>;//sand

cullmode=none; //<<<<<<< NEW
zenable=true; //<<<<<<< NEW
zwriteenable=true; //<<<<<<< NEW

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;


TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
texcoordindex[1]=0;

ColorArg1[1] = texture;
ColorOp[1] = modulate;
alphaarg1[1] = current | alphareplicate;
alphaop[1]=disable;

//
// Stage 2
//
colorop[2]=disable;
alphaop[2]=disable;


}


Eric

Posted By: ventilator

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 18:20

you could add it to the wiki!

...
i think cullmode=none; just makes it slower and shouldn't be used.
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 18:43

Thats a good tip, leaving out cullmode, it is not necessary on my machine. Maybe everyone should leave that out. The code above is mainly for Makai to fiddle with and see if it can work.

Do you have any other suggestions?? You see, the thing ran fine on my card, but you see what happened on Makai's. What about the other things added in the "//<<<<<< NEW". I'm just learning, so most things are trial and error.

About the wiki, I am hoping that the code can be applicable across a varity of cards first. Needs testing and feedback. I am not going to change the code that is on the demo unless alot of people have problems. It will just get too confusing.

Thanks,
Eric



Posted By: Alkai

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/07/04 23:59

Excellent work, Steempipe!

I even tried it on my old pc with a 32mb Radeon 7500 card and it worked great!
Posted By: William

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/08/04 09:09

Great Work! Ran fine on my graphics card(9800). Thanks, i'll be sure to use it.
Posted By: William

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/08/04 11:53

What version of ps is required for the first technique? Ps 1.1? Thanks.
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/08/04 17:55

Should not need any pixelshaders. Fixed-function. I cannot test this on anything other than my ATI 9200 tho and I do not know what the minimum requirements might be.

I updated the website with the code to do 3 textures as well as some changes to the effect file, better comments, and a little instructions.

Theres a screen with 4 textures and an EBM water effect start.

web page

I want to get this thing tested out good, then posted on the wiki.


Posted By: Drew

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/09/04 09:22

what is the EBM water? looks cool...
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/09/04 09:47

Sorry, typo.... it's (EMBM) Environment-Mapped Bump Mapping. I am just gathering info about that stuff, so I do not have much light to shed on it.
Posted By: William

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/09/04 14:31

That water looks great. Thanks for all your work!
Posted By: Nadester

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/10/04 02:02

Looks very nice Steampipe. Are you going to release thet EMBM effect code? Looks great!

Btw.. That transparency problem in an engine issue on lower cards. Try giving a model or terrain a targa map, and you'll get the same same problem.
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/10/04 04:27

I am supposing that at some time in the very near future I'll post what I learn about water code. That will be a new thread when it happens so it should be easy to spot.

Thanx for the bit about the TGA transparency. Wish I would have known that a few days back as I started out with the TGA as an entSkin. Needless to say, I spent probably the whole evening going in circles and out of my mind because of that.
Posted By: Marco_Grubert

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/10/04 06:53

Geforce 3 works.
cullmode should be set to CCW or CW but not to none. Otherwise hidden triangles will be calculated. I am also concerned about the _zenable=false_ statement which means that the alpha blend will take place no matter whether the terrain is hidden behind another object. Not sure where that might cause errors, but it looks suspicious.
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/10/04 08:34

Thanks Marco, that is the kind of information that I need, and find very useful. I appreciate your technical input.

Eric
Posted By: mk_1

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/26/04 07:06

For the 3 pass thing: is it possible to pack the blend maps in one map so blendmap.tga is the red channel and blendmap2.tga is the green channel? This would make it much easier for me (have problems with alpha channels) and could be edited in gs by the pixel functions.

--> Imagine the entSkin3 to be earth full of ashes etc. Now you could make some bombs falling on terrain and paint on the blend map where they impact and you'll have some nice war terrain. (would need that for my game and putting sprites on terrains is a desaster).
Posted By: mk_1

@Steempipe (urgent) - 04/28/04 04:57

URGENT PROBLEM!
I'm using the fixed function for some time now and are now working on graphics. I encountered a problem: As soon as I see a sky texture there's an error (mat_terraintex - effect unsupported by hardware). The terrain still works but is now very bright and no multitexturing anymore.
Posted By: mk_1

Re: @Steempipe (urgent) - 04/28/04 05:07

I want to add that my effect is a modified version of the 3 textures script so it only uses two scripts (just deleted pass2). Well, I now tried the old effect that you wrote and it "works". That means there is no error but: when a sky texture is rendered the terrain turns grey - no texture is rendered. just gourad shading.

I'm using a GeForce2 MX400, latest drivers.
Posted By: Steempipe

Re: @Steempipe (urgent) - 04/28/04 06:39

Sky worked for me, I took the sky out of that thing to make the file smaller, however I didn't have any troubles here with a skycube or the stock animated sky texture. I guess we'll start at square one...

Did the trouble start when you went to build your own~ or did the demo never quite work right for you??

Let me give you a link to a 3 texture build with a sky in it, run it and tell me what happens. If you need one with 2 textures let me know and I will do that instead.
test.zip --- 3.49 MB

Eric
Posted By: Steempipe

Re: Fixed-Function Terrain Multi-Texturing Effect - 04/28/04 06:45

Quote:

For the 3 pass thing: is it possible to pack the blend maps in one map so blendmap.tga is the red channel and blendmap2.tga is the green channel? This would make it much easier for me (have problems with alpha channels) and could be edited in gs by the pixel functions.

--> Imagine the entSkin3 to be earth full of ashes etc. Now you could make some bombs falling on terrain and paint on the blend map where they impact and you'll have some nice war terrain. (would need that for my game and putting sprites on terrains is a desaster).




I desire to look into that... but the water thing is slamming me hard right now.
Posted By: mk_1

Re: @Steempipe (urgent) - 04/28/04 06:52

This works fine. Anyway you're using the new code but I only need 2 texture mixing and not 3. The one with 3 textures needs more memory.

I encountered another problem. If you move the mouse to the upper left while activating it (mouse_toggle?) the effect stops and only the first skin is shown. A6 bug? reproducable?
Posted By: Michael_Schwarz

Re: @Steempipe (urgent) - 04/28/04 07:03

In Antwort auf:

This works fine. Anyway you're using the new code but I only need 2 texture mixing and not 3. The one with 3 textures needs more memory.

I encountered another problem. If you move the mouse to the upper left while activating it (mouse_toggle?) the effect stops and only the first skin is shown. A6 bug? reproducable?




Same prob here MAybe a A6 bug?
Posted By: Steempipe

Re: @Steempipe (urgent) - 04/28/04 07:23

I cannot get the mouse-thing-problem to happen here. What version of A6 are you all using??

Okay.... I made some changes to the build. Just so you could digest some things.
1). It only blends the one texture, using 1 alphamap.
2). I resized the alphamap to 64x64 instead on 256x256 to save mem.
3). I resized the textures to 128x128 to save mem.
4). I resized the skycube texture to 128 height, to save mem.

reduced texture sizes = reduced filesize (1.79 MB)

Really curious on the mouse thing!

Eric
Posted By: mk_1

Re: @Steempipe (urgent) - 04/28/04 07:30

Dunno. The mouse bug still happens. Sometimes it doesn't occure the first time but the second or third.

Everything else seems okay. Maybe I had the error because I used a 512x512 blend map. I'll check that
Posted By: oliver2s

Re: @Steempipe (urgent) - 04/28/04 07:37

I don't have this problems with the demo(s). It works fine.
Posted By: mk_1

Re: @Steempipe (urgent) - 04/28/04 07:49

Okay. I changed most of my terrain. No big textures or so but I still get this dumb error message while your level works fine.
Posted By: Steempipe

Re: @Steempipe (urgent) - 04/28/04 07:52

Is this a "small" test level you have?? If so, could you get it to me, then I can explore what may be different. I had alot of crap go wrong before it went right for me, and usually it was something small.

Eric
Posted By: mk_1

Re: @Steempipe (urgent) - 04/28/04 08:18

send me your adress so I can send you my level.
Posted By: mk_1

Re: @Steempipe (urgent) - 01/07/05 00:27

Sorry to push this thread but it looks like the code doesn't work with 6.31.4/dx9c anymore. Could you please check it out?
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/07/05 04:50

Here is the (2) texture version of the old code redone.

BTW: If you want to utilize HLSL, for more flexibility, then you can
modify code in this thread here.

Code:
 
///////////////////////////////////////////////////////////
// FFP Terrain MultiTexturing Effect
//
// Blending (2) Textures
//
// By: Eric A. Hendrickson-Lambert (Steempipe)
//
//
// 1/6/05: Update original code for MK_1
// to build with A6.31.4 & DX9.00c
//
//////////////////////////////////////////////////////////


//*****************************************************
//** I had strange results with putting the alphamaps
//** in to the HMP as entSkins.
//** Just load them as mtlSkins.
//*****************************************************

// RGB Channels are blank
// The A channel has the blending weight (pattern)
bmap blendmap = <blendmap.tga>; // Blender for Pass p1


//*****************************************************
//** entSkins 1-4 are tilable textures
//** Be sure to add mipmaps to them in MED
//*****************************************************


var Detail_Size = 0;


function mtl_terraintex_init()
{

bmap_to_mipmap(mtl.skin1);


//
// Adjust the texture transform to do some tiling of the textures
//

mtl.matrix11 = float(28); // default u scale
mtl.matrix22 = float(28); // default v scale

}

///////////////////////////////////////////////////////////////////////
//The Material
///////////////////////////////////////////////////////////////////////

material mat_terraintex
{

skin1 = blendmap;



// define a material effect string

event = mtl_terraintex_init;

effect =
"
matrix matMtl;

texture mtlSkin1; // Blending map for Pass P1

texture entSkin1; // Tileable Tex
texture entSkin2; // Tileable Tex




///////////////////////////////////////////////////////////////////////
//The Technique
///////////////////////////////////////////////////////////////////////

technique ffp_terrain_tex
{
pass P0
//////////////////////////////////////////////////////
//// Lets lay the first texture down. no alpha work
//////////////////////////////////////////////////////
{

AlphaBlendEnable=False;
AlphaTestEnable=False;

Lighting = True;

zEnable=True;
zWriteEnable=True;

////////////////////////////////////////
// Stage 0
///////////////////////////////////////

Texture[0] = <entSkin1>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
texcoordindex[0]=1;

ColorArg1[0] = Texture;
ColorOp[0] = Modulate;
ColorArg2[0] = Diffuse;
AlphaOp[0]=Disable;

//////////////////////////////////////
//stage 1
//////////////////////////////////////

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

}

pass P1
//////////////////////////////////////////////////////
//// Now we blend another texture using an alphamap
//////////////////////////////////////////////////////
{

//////////////////////////////////////
// Stage 0
//////////////////////////////////////

// We need to enable alphablending

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

zEnable=False;
zWriteEnable=False;

Texture[0] = <mtlSkin1>;

magFilter[0]=Linear;
minFilter[0]=Linear;
mipFilter[0]=Linear;

//
// We don't want the alphamap to tile
//
TextureTransformFlags[0] = disable;

TexCoordIndex[0]=0;

ColorArg1[0] = Current;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaOp[0]=SelectArg1;

//////////////////////////////////////////////
// Stage 1
//////////////////////////////////////////////

Texture[1] = <entSkin2>;

zEnable=True;
zWriteEnable=True;

magFilter[1]=Linear;
minFilter[1]=Linear;
mipFilter[1]=Linear;


TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
TexCoordIndex[1]=1;

ColorArg1[1] = Texture;
ColorOp[1] = Modulate;
AlphaArg1[1] = Current;
AlphaOp[1]=Disable;

///////////////////////////////////////////////
// Stage 2
///////////////////////////////////////////////
ColorOp[2]=Disable;
AlphaOp[2]=Disable;


}



} // End of Technique

"; // end of the effect string

} // End of Material


///////////////////////////////////////////////////////////////////////
//The Action we assign in WED
///////////////////////////////////////////////////////////////////////

action ffp_TerrainTex
{
my.transparent=off;
my.material = mat_terraintex;


}




Posted By: mk_1

Re: @Steempipe (urgent) - 01/07/05 05:48

Alright, I have this code now:
Code:
material mat_ffp_multitex
{
event = mtl_terraintex_init;
skin1 = blendmap1; //Blendmap for texture 2
skin2 = blendmap2; //Blendmap for texture 3
effect
"
TEXTURE entSkin1;
TEXTURE entSkin2;
TEXTURE entSkin3;

TEXTURE mtlSkin1;
TEXTURE mtlSkin2;


matrix matMtl;

technique ffp_terrain_tex
{
pass P0
//////////////////////////////////////////////////////
//// Lets lay the first TEXTURE down. no alpha work
//// This will tile across the entire HMP
//////////////////////////////////////////////////////
{

alphablendenable=false;
alphatestenable=false;

zenable=true;
zwriteenable=true;

////////////////////////////////////////
// Stage 0
///////////////////////////////////////

TEXTURE[0] = <entSkin1>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

TEXTURETransformFlags[0] = Count2;
TEXTURETransform[0] = <matMtl>;
texcoordindex[0]=0;

ColorArg1[0] = TEXTURE;
ColorOp[0] = SELECTARG1;

alphaop[0]=disable;

//////////////////////////////////////
//stage 1
//////////////////////////////////////

colorop[1]=disable;
alphaop[1]=disable;

}

pass P1
//////////////////////////////////////////////////////
//// Now we blend another TEXTURE using an alphamap
//// This TEXTURE will be blended
//////////////////////////////////////////////////////
{

//////////////////////////////////////
// Stage 0 - Setup the alphamap
//////////////////////////////////////

// We need to enable alphablending

alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;

// AlphaTestEnable uses the AlphaRef and AlphaFunc to
// determine which pixels get drawn.
// In this case, anything greater that 0 will be drawn.
alphatestenable=true;
alpharef=0x00000000; //Reference Value
alphafunc=Greater; //Comparison Function

TEXTURE[0] = <mtlSkin1>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

//
// We don't want the alphamap to tile
//
TEXTURETransformFlags[0] = disable;

texcoordindex[0]=0;

COLORARG1[0] = CURRENT;
ColorOp[0] = SELECTARG1;
ALPHAARG1[0] = TEXTURE | ALPHAREPLICATE;
alphaop[0]=selectarg1;

//////////////////////////////////////////////
// Stage 1 -- This is the TEXTURE to splat
//////////////////////////////////////////////

TEXTURE[1] = <entSkin2>;


// Zenable is supposed to default to true.
// This enables depth testing to determine what pixels
// are visible to the viewer

zenable=true;
zwriteenable=true;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;


TEXTURETransformFlags[1] = Count2;
TEXTURETransform[1] = <matMtl>;
texcoordindex[1]=1;

COLORARG1[1] = TEXTURE;
ColorOp[1] = modulate;
ALPHAARG1[1] = CURRENT | ALPHAREPLICATE;
alphaop[1]=disable;

///////////////////////////////////////////////
// Stage 2
///////////////////////////////////////////////
colorop[2]=disable;
alphaop[2]=disable;


}

pass P2
{

////////////////////////////////////////
// Stage 0
////////////////////////////////////////

alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;

alphatestenable=true;
alpharef=0x00000000;
alphafunc=Greater;

TEXTURE[0] = <mtlSkin2>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;


TEXTURETransformFlags[0] = disable;

texcoordindex[0]=1;

COLORARG1[0] = CURRENT;
ColorOp[0] = selectarg1;
ALPHAARG1[0] = TEXTURE | ALPHAREPLICATE;
alphaop[0]=selectarg1;

/////////////////////////////////////////
// Stage 1
/////////////////////////////////////////
TEXTURE[1] = <entSkin3>;

zenable=true;
zwriteenable=true;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;


TEXTURETransformFlags[1] = Count2;
TEXTURETransform[1] = <matMtl>;
texcoordindex[1]=0;

COLORARG1[1] = TEXTURE;
ColorOp[1] = modulate;
ALPHAARG1[1] = CURRENT | ALPHAREPLICATE;
alphaop[1]=disable;

////////////////////////////////////////
// Stage 2
////////////////////////////////////////
colorop[2]=disable;
alphaop[2]=disable;

} // End of Pass P2

} // End of Technique
";
}


three textures, they all blend perfectly. Now a last question: Is it possible to use dynamic lights on them? This is really important for the game.

The terrains reacts on fog but not dynamic light.
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/07/05 06:50

Yes... make your dynamic lights and since we already have lighting-true in the FFP. It should work out.


Posted By: PHeMoX

Re: @Steempipe (urgent) - 01/08/05 01:21

Mmmm, it's tiny little off topic, but does anyone knows what parameters I have to use for multitexturing based on height?


Cheers
Posted By: mk_1

Re: @Steempipe (urgent) - 01/08/05 17:59

just use your heightmap as blendmap.

EDIT:
@steempipe:
Could you add a third texture (for shadows) please?
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/08/05 22:13

MK_1: Getting your code finished. Just need to add comments and things this weekend.

You will have:
-Blending (2) textures
-Adding of dynamic lights
-Diffuse Lighting from the engine
-Modulating a shadowmap



Posted By: Locutus_of_Borg

Re: @Steempipe (urgent) - 01/08/05 23:57

I also wait for the dynamic light...
With my terrain, the first midmap does not react on light at all, but the 2nd and 3rd does.. would be great if first would also...
I use your code from above...
THX!
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/09/05 01:26

After I get everything worked out I will put the code up and a demo.

-Added a detailmap to it.


Posted By: Rhuarc

Re: @Steempipe (urgent) - 01/09/05 01:43

Looks Great Steempipe! This is very similar to my 2-texture terrain shader, although I didn't do anything with lights or shadowmaps yet (once I add those there will be 4 different terrain rendering quality settings, LOL). Can't wait to see it.
Posted By: William

Re: @Steempipe (urgent) - 01/09/05 05:56

What is the difference between this terrain shader and the one you released earlier that contained a colormap and 2 detail maps(FFP, very great shader!)?
Posted By: Rhuarc

Re: @Steempipe (urgent) - 01/09/05 06:02

Other one:
Colormap
detail map 1
detail map 2

This one:
Texture map 1
Texture map 2
Shadowmap
Lighting Responsive

Detail maps are a little different than texture maps. A detail map is usually a rather low-saturated texture that goes over a color (the saturation) that is below it. A texture map contains full saturation and is rendered like any other texture. Both are good, it depends on where you use it as to which is better.

-Rhuarc
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/09/05 06:06

Nice short and accurate answer [Rhuarc], thanks.
Posted By: William

Re: @Steempipe (urgent) - 01/09/05 08:54

Thanks.
Posted By: mk_1

Re: @Steempipe (urgent) - 01/09/05 11:17

uh-oh!!! great!
all I need is the code now.
great stuff, steempipe.
Posted By: PHeMoX

Re: @Steempipe (urgent) - 01/10/05 08:46

(It's a bit off topic, but I'll ask it anyways...)
I asked what to use for a multi texture terrain shader based on heights...
Quote:

just use your heightmap as blendmap.




That's really not what I'm looking for, because a) I'm not working with heightmaps (all terrains created in MED from scratch) b) I add some meshdeformation randomness in script c) it is a very very very large terrain (when seen all together, 'cause they are quite small actually ), so the blendmap isn't useful...
Anyone?
Posted By: Steempipe

Re: @Steempipe (urgent) - 01/10/05 08:56

The best way I can suggest is using Destops "HMPSplit". It will generate a BMP Heightmap from an HMP. I've used it and am very happy with it.

web page
Posted By: Galiot

Re: @Steempipe (urgent) - 01/15/05 00:06

Hello,

Currently I'm using the script found on Steempipe's webpage(http://steempipe.technicalfoundry.com/terrain/terraintexffp_4-7-04.zip) and I've got the terrain up and looking pretty well, although I am having some problems when I try to Publish the project. Here is a screenshot of the error message.



Not having any luck figuring out what is causing this error, any help would be appreciated. The game runs fine if I run it from the WED.
Posted By: ello

Re: @Steempipe (urgent) - 01/15/05 00:15

try putting the fx into a separate fx-file. this things happen when to much shadercode is inside the wdl/material
Posted By: Galiot

Re: @Steempipe (urgent) - 01/15/05 01:42

Quote:

try putting the fx into a separate fx-file. this things happen when to much shadercode is inside the wdl/material




I'm not sure exactly what you mean by this, if you could explain in more detail it would be very helpful.

Thanks for the input.
Posted By: PHeMoX

Re: @Steempipe (urgent) - 01/15/05 01:52

What he means is, that you should copy your code into a new file and save it as (for example) shader.fx ...

Code:
 ///////////////////////////////////////////////////////////

// FFP Terrain MultiTexturing Effect
//
// By: Eric A. Hendrickson-Lambert (Steempipe)
//
// Rev. 04.05.04.1
//
// Description:
// Using 2 tileable textures and an alphamap for blending.
// This code uses (2) passes because more than 2 stages would be needed
// for 1 pass. The First Fallback Technique is just a 2 stage 1 pass but
// has the transformation. The second fallback has no transformation.
//
//////////////////////////////////////////////////////////


// A tileable texture
//bmap grass = <tilegrass.bmp>;


//RGB Channels are blank
//The A channel has the blending weight (pattern)
bmap blendmap = <blendme.tga>;

// A tileable texture
//bmap sand = <tilesand.bmp>;


function mtl_terraintex_init()
{


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

//
// Adjust the texture transform to do some tiling of the textures
//
mtl.matrix11 = float(18); // default u scale
mtl.matrix22 = float(18); // default v scale

}



material mat_terraintex
{
//skin1 = grass;
Skin2 = blendmap;
//skin3 = sand;

// define a material effect string

event = mtl_terraintex_init;

effect =
"

matrix matMtl;


texture entSkin1; // Grass
texture mtlSkin2; // Alpha Blending Map
texture entSkin2; // sand
texture entSkin3; // detailmap
texture entSkin4; // Basic Skin



// default technique


technique ffp_terrain_tex
{
pass P0
{

alphablendenable=false;

//
// Stage 0
//
Texture[0] = <entSkin1>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;



TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
texcoordindex[0]=0;

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

alphaop[0]=disable;

//
//stage 1
//
colorop[1]=disable;
alphaop[1]=disable;

}

pass P1
{

// We need to enable alphablending

alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;

//
// Stage 0
//
Texture[0] = <mtlSkin2>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

//
// We don't want the alphamap to tile
//
TextureTransformFlags[0] = disable;

texcoordindex[0]=1;

ColorArg1[0] = current;
ColorOp[0] = selectarg1;
alphaarg1[0] = texture | alphareplicate;
alphaop[0]=selectarg1;

//
// Stage 1
//
Texture[1] = <entSkin2>;//sand

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;


TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
texcoordindex[1]=0;

ColorArg1[1] = texture;
ColorOp[1] = modulate;
alphaarg1[1] = current | alphareplicate;
alphaop[1]=disable;

//
// Stage 2
//
colorop[2]=disable;
alphaop[2]=disable;


}



}


technique firstfallback
{
pass P0
{
//
// Stage 0
//
Texture[0] = <entSkin4>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

texcoordindex[1]=0;

ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
ColorOp[0] = Modulate;
//
// Stage 1
//
Texture[1] = <entSkin3>;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;


TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
texcoordindex[1]=1;

ColorArg1[1] = texture;
ColorArg2[1] = Current;
ColorOp[1] = addsigned;


}
}



technique secondfallback
{
pass P0
{
//
// Stage 0
//
Texture[0] = <entSkin4>;

ColorArg1[0] = Texture;
//ColorArg2[0] = Diffuse;
ColorOp[0] = selectarg1;

//
// Stage 1
//
Texture[1] = <entSkin4>;

ColorArg1[1] = texture;
ColorArg2[1] = Current;
ColorOp[1] = modulate;

}
}


"; // end of the effect string

}



action ffp_TerrainTex
{
my.material = mat_terraintex;
}



Is this the code you are using?

Cheers
Posted By: b_102373

Re: @Steempipe (urgent) - 01/15/05 17:55

My Geforce 5x 5200 doesnt work. I get my water as a black texture.
Posted By: ShoreVietam

Re: @Steempipe (urgent) - 01/15/05 23:53

Do you know why the Camera transparency doesn't work with the FFP Terrain?
Posted By: PHeMoX

Re: @Steempipe (urgent) - 01/16/05 01:43

My father's Geforce 5200 can't display this shader either.. This is because for the watershader it's pixelshader or vertexshader 2.0 when I'm not mistaken, which isn't supported by this graphics card....


Cheers
Posted By: ShoreVietam

Re: @Steempipe (urgent) - 01/16/05 04:39

I don't know if this was some kind of answer to my question...

What I ment is, that you have no blur effect on the FFP Terrain when you set CAMERA.TRANSPARENT = ON;
Posted By: ShoreVietam

Re: @Steempipe (urgent) - 01/16/05 19:03

Ok I got it now!

Set

AlphaBlendEnable = True;
AlphaTestEnable = True;

at the beginning of every pass to make camera transparency repossible.
The terrain is a bit dominant, but better than nothing!
© 2024 lite-C Forums