Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 801 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 1 of 2 1 2
DX9 version of Multi-Detailmapping Terrains #36036
11/11/04 21:47
11/11/04 21:47
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
Can be easily adapted to just modulating the textures (instead of Addsigned for a "detailmapping" effect) for multi-texturing. In that case, the colormap sampler could be a tileable texture and the transformation set to a scale factor.


This is from my FX file... so it will be necessary to load the FX file, create the Material, Action and so forth.

/*-------------------------------------------------------------------
A few Ideas on Detailmapping A large Colormap

Requirements: 3DGS A6.31+ Commercial and Directx 9.00c
-Large Colormap skin in entSkin1
-Suitable Detailmap Texture in entSkin2 and entSkin3
-Blendmap for Technique #1 in mtlSkin1 Alpha.
-Sun positions and color to be set in 'Map Properties'
-Ambient light color set in Map Properites
-Fog Color and ranges set

Eric Hendrickson-Lambert (Steempipe) ~ Credit if used, is appreciated

10-26-04: -Implemented
10-27-04: -Added variables for setting up lighting and tiling


Note: This is a WIP and in an expirimental phase right now.
Things most likely will change, for the better I hope.


If you have <var Detail_Size> set in you main function,
you will see that our scaling gets re-multiplied.
Pick the way you want to do it. If you choose using the
vars in this FX file, then set Detail_Size=0; in main func.

---------------------------------------------------------------------*/
/***************************************
Tweakable Variables
***************************************/

////////////////////////////////////////////////////
// Assign the tile size of the detailmap.
//
float Detailmap_Size1 = 16.0;
float Detailmap_Size2 = 14.0;




////////////////////////////////////////////////////
// Grab the ambient light color from the engine.
//
float4 vecLight;

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


/***************************************
Default Variables
***************************************/

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

float4x4 matDetailMapSize = {1.0, 0.0, 0.0 ,0.0, // U scale of Detailmap
0.0, 1.0, 0.0, 0.0, // V scale of Detailmap
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};

float4x4 matColorMapSize = {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
};


/***************************************
Setup Textures
***************************************/

Texture entSkin1; // The large Colormap Skin in RGB
Texture entSkin2; // Detailmap in RGB
Texture entSkin3; // Detailmap in RGB
Texture mtlSkin1; // Blendmap for Technique#1 - Pass 1 in Alpha

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

};


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

sampler s_Detailmap1 = sampler_state
{
Texture = (entSkin2);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
MaxMipLevel=0;
MipMapLodBias=0.1;
};

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

/////////////////////////////////////////////
// T E C H N I Q U E ' S
/////////////////////////////////////////////

/////////////////////////////////////////////
// Just slap down the colormap and
// then (2) Detailmaps based on
// a blendmap.
/////////////////////////////////////////////
technique detailmap_technique_one
{
pass p0
{
Sampler[0] = (s_Colormap);
Sampler[1] = (s_Detailmap1);

// Make sure defaults are set
//
AlphaBlendEnable = False;
DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting = True; // Allow for diffuse lighting from engine

////////////////////////////////////////////////////////////////////////
// If the Ambient Light Color is set in Map Properites,
// Here we have the opportunity to apply it to the terrain.
// We will use ambientLightFactor to adjust its intensity.
//
Ambient = mul(vecLight, ambientLightFactor);


//////////////////////////////////////////////////
// Apply the Colormap
//
TextureTransformFlags[0] = Count2;
TexCoordIndex[0] = 0;
TextureTransform[0]= (matColorMapSize);

ColorOp[0] = Modulate; // Modulate diffuse lighting with colormap texture
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
AlphaOp[0] = Disable;

//////////////////////////////////////////////////
// Apply the Detailmap
//
TextureTransformFlags[1] = Count2;
TexCoordIndex[1] = 1;
TextureTransform[1]= (matDetailMapSize * Detailmap_Size1);

ColorOp[1] = Addsigned;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
AlphaOp[1] = Disable;

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

}

pass p1
{
Sampler[0] = (s_DetailBlendmap); // Blendmap is Alpha
Sampler[1] = (s_Colormap); // The Colormap
Sampler[2] = (s_Detailmap); // The Detailmap
Lighting = True;
Clipping=True;
DitherEnable=True;

//////////////////////////////////////////////////
// Setup the Blendmap
//
AlphaBlendEnable = True;
SrcBlend = srcAlpha;
DestBlend = InvSrcAlpha;

DitherEnable = True;
zWriteEnable = True;
zEnable = True;
CullMode = None;
Lighting=True; // Get lighting from engine

///////////////////////////////////////////////////////////////
// Adjust the lighting, furthur, if desired.
//
//
//Ambient = mul(vecLight, (ambientLightFactor * 1.1));

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

//////////////////////////////////////////////////
// Re-apply the Colormap for blending reasons
// undetermined at this point.
//
TextureTransformFlags[1] = Count2;
TextureTransform[1]= (matColorMapSize);
texcoordindex[1]=0;

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

//////////////////////////////////////////////////
// Apply the 2nd Detailmap
//
TextureTransformFlags[2] = Count2;
TextureTransform[2]= (matDetailMapSize * Detailmap_Size2);

texcoordindex[2]=1;
ColorOp[2] = Addsigned;
ColorArg1[2] = Texture;
ColorArg2[2] = Current;
AlphaOp[2]=Disable;

ColorOp[3]=Disable;
AlphaOp[3]=Disable;

}

}

Re: DX9 version of Multi-Detailmapping Terrains [Re: Steempipe] #36037
11/17/04 18:01
11/17/04 18:01
Joined: Dec 2003
Posts: 266
Celle
task1 Offline
Member
task1  Offline
Member

Joined: Dec 2003
Posts: 266
Celle
nice shader!thanks Eric!!!

project


visit my pages: www.xiron.de ICQ: 335016379 Messenger: lalimited@hotmail.com
Re: DX9 version of Multi-Detailmapping Terrains [Re: task1] #36038
11/19/04 01:10
11/19/04 01:10
Joined: Dec 2002
Posts: 293
Minnesota
Peter Churness Offline
Member
Peter Churness  Offline
Member

Joined: Dec 2002
Posts: 293
Minnesota
Hey Eric,

This looks like great work! Could you possibly post examples of the actual color map, detail maps and blend map that a person might use with this shader? That would be helpful for me and perhaps for some others...

Thanks!!

Peter

Re: DX9 version of Multi-Detailmapping Terrains [Re: Steempipe] #36039
11/23/04 15:29
11/23/04 15:29
Joined: Nov 2004
Posts: 6
D
don Offline
Newbie
don  Offline
Newbie
D

Joined: Nov 2004
Posts: 6
thanks for your help Steempipe!!!it is working very nice!

one question: is there a way to give every texture another .tga?

Re: DX9 version of Multi-Detailmapping Terrains [Re: don] #36040
11/24/04 11:03
11/24/04 11:03
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
Peter Churness: I'll see about getting a small demo that has an example of the images and a brief document on what is what. May take awhile, since my time is limited right now. If all else fails, I'll cough up and post the images you are curious about.

don: As far as the extra "TGA's"; Are you asking about adding an alpha channel blendmap into the other texture?? If so, yes. But you will probably have side-effects if you put the alphas in the entSkin textures, tho.

Re: DX9 version of Multi-Detailmapping Terrains [Re: Steempipe] #36041
11/24/04 15:34
11/24/04 15:34
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
A small test level I threw together, combining a dirt and a grass detail map:


So, for those of you who were too lazy to try it on your own, that's what this effect looks like.

Re: DX9 version of Multi-Detailmapping Terrains [Re: LogantheHogan] #36042
11/25/04 23:10
11/25/04 23:10
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
nice...


The Art of Conversation is dead : Discuss
Re: DX9 version of Multi-Detailmapping Terrains [Re: indiGLOW] #36043
11/26/04 13:16
11/26/04 13:16
Joined: Jul 2002
Posts: 2,813
U.S.
Nadester Offline

Expert
Nadester  Offline

Expert

Joined: Jul 2002
Posts: 2,813
U.S.
Quote:

So, for those of you who were too lazy to try it on your own, that's what this effect looks like.



Want to post a demo Logan so all of us lazy folks don't have to get up off our rears and hack one together?


--Eric
Re: DX9 version of Multi-Detailmapping Terrains [Re: Steempipe] #36044
11/30/04 17:46
11/30/04 17:46
Joined: Dec 2003
Posts: 266
Celle
task1 Offline
Member
task1  Offline
Member

Joined: Dec 2003
Posts: 266
Celle
hi guys.

tried also to implementate more then one tga in this script.but it doesnīt work.donīt know why.is it possible that I could use for each texture a different tga?

thanx for help


visit my pages: www.xiron.de ICQ: 335016379 Messenger: lalimited@hotmail.com
Re: DX9 version of Multi-Detailmapping Terrains [Re: task1] #36045
11/30/04 18:01
11/30/04 18:01
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
Hmmmm.... looks like it may be time to make some changes and post a demo.

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