Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, howardR), 646 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Terrain - FFP - Blend 5 Textures #45405
05/08/05 22:51
05/08/05 22:51
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 some code for blending (5) textures using the fixed-function pipe.

Code:

///////////////////////////////////
// ffp5tex_action.wdl
//

bind <ffp5tex.fx>;

//var terrain_chunk = 128;

// Additional FFP blendmaps
//


bmap sand = <sand.tga>;
bmap grass = <grass.tga>;
bmap road = <road.tga>;
bmap stone = <stone.tga>;


function makemips {
bmap_to_mipmap(mtl.Skin1);
bmap_to_mipmap(mtl.Skin2);
bmap_to_mipmap(mtl.Skin3);
bmap_to_mipmap(mtl.Skin4);
}


material mat_ffp5terrain{


Skin1 = sand;
Skin2 = grass;
Skin3 = road;
Skin4 = stone;

event = makemips;

}



Action Terrain {
fps_max = 60;
effect_load(mat_ffp5terrain, "ffp5tex.fx");
wait(1);
my.material = mat_ffp5terrain;
}





Code:

///////////////////////////////////
// ffp5tex.fx
//
/***********************************************************
FFP MultiTex Effect to blend 5 Textures.

5/8/05

Eric Hendrickson-Lambert (Steempipe)


Requires: GStudio 6.31 Comm+
DX 9.0c

Blendmaps for skins 2,3,4,5 are in their alpha channels

************************************************************/

////////////////////////////////////////////////////
// Assign the tile size of the Textures.
//

float Skin_Size1 = 20;
float Skin_Size2 = 20;
float Skin_Size3 = 20;
float Skin_Size4 = 20;
float Skin_Size5 = 20;


float4 vecLight;


/////////////////////////////////////////////////////////////////////////////////////
// Let's allow for adjusting the intensity of the ambient light color on the passes.
//
float ambientLightFactor = 1.0;


////////////////////////////////////////////////////////////////////
// Here we just create and plug some values into a matrix for
// use in multiplying during the stages.
//

float4x4 matTerrainTexSize = {1.0, 0.0, 0.0 ,0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};


float4x4 matAlphaMapSize = {1.0, 0.0, 0.0 ,0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};


Texture entSkin1; //1st tile tex RGB
Texture mtlSkin1; //2nd tile tex RGB and blender in A
Texture mtlSkin2; //3nd tile tex RGB and blender in A
Texture mtlSkin3; //4nd tile tex RGB and blender in A
Texture mtlSkin4; //5nd tile tex RGB and blender in A


sampler s_ShaleTex = sampler_state
{
Texture = (entSkin1);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.0;
};


sampler s_SandTex = sampler_state
{
Texture = (mtlSkin1);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.0;
};


sampler s_GrassTex = sampler_state
{
Texture = (mtlSkin2);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.0;
};


sampler s_RoadTex = sampler_state
{
Texture = (mtlSkin3);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.0;
};

sampler s_StoneTex = sampler_state
{
Texture = (mtlSkin4);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.0;
};



technique technique_one

{

pass p0
{
Sampler[0] = (s_ShaleTex);

AlphaBlendEnable = False;
AlphaTestEnable = False;
DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TexCoordIndex[0] = 1;
TextureTransform[0]= mul(matTerrainTexSize,Skin_Size1);

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


}


pass p1
{
Sampler[0] = (s_SandTex); // Blendmap is Alpha
Sampler[1] = (s_SandTex); // The Colormap

Lighting = True;
Clipping=True;
DitherEnable=True;

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

DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TextureTransform[0]= (matAlphaMapSize);
texcoordindex[0]=0;
ColorArg1[0] = Texture;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaOp[0] = SelectArg1;

TextureTransformFlags[1] = Count2;
TextureTransform[1]= mul(matTerrainTexSize, Skin_Size2);
texcoordindex[1]=1;

ColorArg1[1] = Texture;
ColorArg2[1]= Diffuse;
ColorOp[1] =Modulate;
alphaarg1[1] = current;
alphaop[1]=Disable;

}

pass p2
{
Sampler[0] = (s_GrassTex); // Blendmap is Alpha
Sampler[1] = (s_GrassTex); // The Colormap

Lighting = True;
Clipping=True;
DitherEnable=True;

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

DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TextureTransform[0]= (matAlphaMapSize);
texcoordindex[0]=0;
ColorArg1[0] = Texture;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaOp[0] = SelectArg1;

TextureTransformFlags[1] = Count2;
TextureTransform[1]= mul(matTerrainTexSize, Skin_Size3);
texcoordindex[1]=1;

ColorArg1[1] = Texture;
ColorArg2[1]= Diffuse;
ColorOp[1] =Modulate;
alphaarg1[1] = current;
alphaop[1]=Disable;

}

pass p3
{
Sampler[0] = (s_RoadTex); // Blendmap is Alpha
Sampler[1] = (s_RoadTex); // The Colormap

Lighting = True;
Clipping=True;
DitherEnable=True;

AlphaBlendEnable = True;
AlphaTestEnable = False;
SrcBlend = InvsrcAlpha;
DestBlend = SrcAlpha;

DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TextureTransform[0]= (matAlphaMapSize);
texcoordindex[0]=0;
ColorArg1[0] = Texture;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaOp[0] = SelectArg1;

TextureTransformFlags[1] = Count2;
TextureTransform[1]= mul(matTerrainTexSize, Skin_Size4);
texcoordindex[1]=1;

ColorArg1[1] = Texture;
ColorArg2[1]= Diffuse;
ColorOp[1] =Modulate;
alphaarg1[1] = current;
alphaop[1]=Disable;

}


pass p4
{
Sampler[0] = (s_StoneTex); // Blendmap is Alpha
Sampler[1] = (s_StoneTex); // The Colormap

Lighting = True;
Clipping=True;
DitherEnable=True;

AlphaBlendEnable = True;
AlphaTestEnable = False;
SrcBlend = InvsrcAlpha;
DestBlend = SrcAlpha;

DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True;

Ambient = mul(vecLight, ambientLightFactor);

TextureTransformFlags[0] = Count2;
TextureTransform[0]= (matAlphaMapSize);
texcoordindex[0]=0;
ColorArg1[0] = Texture;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaOp[0] = SelectArg1;

TextureTransformFlags[1] = Count2;
TextureTransform[1]= mul(matTerrainTexSize, Skin_Size5);
texcoordindex[1]=1;

ColorArg1[1] = Texture;
ColorArg2[1]= Diffuse;
ColorOp[1] =Modulate;
alphaarg1[1] = current;
alphaop[1]=Disable;

}

}




Re: Terrain - FFP - Blend 5 Textures [Re: Steempipe] #45406
05/08/05 23:03
05/08/05 23:03
Joined: Mar 2005
Posts: 110
MI
paulshort Offline
Member
paulshort  Offline
Member

Joined: Mar 2005
Posts: 110
MI
Steampipe your amazing...

Re: Terrain - FFP - Blend 5 Textures [Re: paulshort] #45407
05/08/05 23:37
05/08/05 23:37
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
are you sure there's no way to use a rgb blend map? Can you access the rgb channels at all in fixed function? because my terrain editor generates a color blend map.

Re: Terrain - FFP - Blend 5 Textures [Re: Matt_Aufderheide] #45408
05/08/05 23:49
05/08/05 23:49
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
I have some ideas I'll try to work out this week. With any luck I will be able to post good news. I'd like to finish the ps.1.1 5 tex hack, also.

paulshort: Thanks!

Re: Terrain - FFP - Blend 5 Textures [Re: Steempipe] #45409
05/09/05 00:11
05/09/05 00:11
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
You can use the RGB components by first masking the blendmap with a texture factor to remove all other colors, use dotproduct3 as the colorop to remove coloring and multiply it with the tiled texture stage. Quick example:

TextureFactor = 0x00FF0000; //Mask for red
ColorOp[0] = DotProduct3;
ColorArg2[0] = Texture;
ColorArg1[0] = TFactor;
////////////////////////////////////////////
TextureTransformFlags[1] = Count2;
TextureTransform[1]= mul(matTerrainTexSize, Skin_Size2);
texcoordindex[1]=1;
ColorOp[1] = Modulate;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;


-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Terrain - FFP - Blend 5 Textures [Re: Rhuarc] #45410
05/09/05 00:30
05/09/05 00:30
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
Not quite so cut and dry... but you're on the right path.

Re: Terrain - FFP - Blend 5 Textures [Re: Steempipe] #45411
05/09/05 01:33
05/09/05 01:33
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Well, at least it works . I've got a 4 texture + reflection mask running on this basis via FFP; performance isn't anything great- but it isn't too shabby either.

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Terrain - FFP - Blend 5 Textures [Re: Steempipe] #45412
05/09/05 06:12
05/09/05 06:12
Joined: Mar 2005
Posts: 969
ch
Loopix Offline
User
Loopix  Offline
User

Joined: Mar 2005
Posts: 969
ch
You did it! Thank you very much for sharing it with all of us. Not everyone who has got such abilities does share his work for free...you do...and that is most generous! This way, good Ideas can become even better (example: GNU) and everyone can learn a lot.
Thx!
(sorry for giving feedback only now. Where I live, people just get out of bed while you are making night-shifts in front of your screens... )

Re: Terrain - FFP - Blend 5 Textures [Re: Loopix] #45413
05/09/05 07:55
05/09/05 07:55
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Thanks for the contribution ill have to give it a try. Hope it works with my graphics card I really need to update that thing..... Anyone want to buy me a graphics card just kidding .... Or am i Thanks again.


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: Terrain - FFP - Blend 5 Textures [Re: FeiHongJr] #45414
05/09/05 16:21
05/09/05 16:21
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Fantastic Contribution!
I totally agree with Loopix!

Page 1 of 3 1 2 3

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