Thanks, Joey, a little late. I now tested my combination idea and after lots of try and error, I found a way. The framerate loss wasnīt dramatic, but I didnīt do exact research here.
Maybe other people also want to have mipmaps in combination with the template shader, so here is a little step by step description. Of course the main credit goes to the authors of these other codes, from which I was borrowing the missing parts:
1) Copy mtlFX.wdl and default.fx into your gamefolder.
2) I used external skins for the terrain, only the RGB-blendmap remains part of the terrainentity. I deleted the three texture skins in MED.
3) Changes in mtlFX.wdl:
3.1) At the beginning of this script under these lines of code ...
ifndef mtlFX;
define mtlFX;
... I inserted and modified:
Code:
bmap tex1 = <Grasboden.tga>; //Texture black
bmap tex2 = <Landstrasse.tga>; //Texture red
bmap tex3 = <FelsB.tga>; //Texture green
function multimip()
{
bmap_to_mipmap(mtl.Skin1);
bmap_to_mipmap(mtl.Skin2);
bmap_to_mipmap(mtl.Skin3);
}
MATERIAL mtl_terraintex3
{
skin1 = tex1;
skin2 = tex2;
skin3 = tex3;
event = multimip;
effect = " //...
3.2) Now in the effect string I changed ...
Texture entSkin1; // Red/green for blending, blue for shadow
Texture entSkin2; // Basic tiled terrain texture
Texture entSkin3; // Red masked tiled texture
Texture entSkin4; // Green masked tiled texture
... simply into this:
Texture entSkin1; // Red/green for blending, blue for shadow
Texture mtlSkin1; // Basic tiled terrain texture
Texture mtlSkin2; // Red masked tiled texture
Texture mtlSkin3; // Green masked tiled texture
3.3) Then I added some instructions to the mysterious sampler part. Normally itīs only like this:
sampler sMaskTex = sampler_state{Texture = <entSkin1>;};
I changed all the sampler stuff into something, that somehow seemed to help the mipmaps:
Code:
sampler sMaskTex = sampler_state // MORE FROM BOB
{
Texture = <entSkin1>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
sampler sBaseTex = sampler_state
{
Texture = <mtlSkin1>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
sampler sRedTex = sampler_state
{
Texture = <mtlSkin2>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
#ifdef GREENMASK
sampler sGreenTex = sampler_state
{
Texture = <mtlSkin3>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
As everyone can see, I simply changed the names from entSkin into the mtlSkin, where it was convenient and I put in many MinFilters, MipFilters and MagFilters.
3.3) Now in the action fx_terraintex3() (can be found directly below the materialdefinition) there also have to be some changes. I noticed for example, that the mipmaps want my.dynamic to be on, so I would recommend to comment out the last instruction. Some other lines should also be modified ( because the number of entity skins is now different (only one in my test).
For reference, this is what I did:
Code:
action fx_terraintex3()
{
// use skin 5 for non-shader hardware
// if (d3d_shaderversion < 1111) {
// if (ent_skins(my) >= 5) { my.skin = 5; }
// return;
// }
// if entity skins are missing, replace them by standard skins
mtl = mtl_terraintex3;
my.material = mtl;
// if (ent_skins(my) < 4) { mtl.skin4 = bmap_create("rock.tga"); }
// if (ent_skins(my) < 3) { mtl.skin3 = bmap_create("sand.tga"); }
// if (ent_skins(my) < 2) { mtl.skin2 = bmap_create("grass.tga"); }
// copy the texture scales to vecSkill41
if (my.skill2) { my.skill41 = float(my.skill2); }
else { my.skill41 = float(15); }
if (my.skill3) { my.skill42 = float(my.skill3); }
else { my.skill42 = float(15); }
if (my.skill4) { my.skill43 = float(my.skill4); }
else { my.skill43 = float(15); }
// my.DYNAMIC = OFF; // when all done, set terrain static
}
Thatīs the action without safety nets. I hope I didnīt forget something, but thatīs it. I tested everything, and it seemed to work fine. Since I am an absolute shader noob it is very well possible, that not every magfilter is really needed or that there isnīt a better or more simple way to enjoy multitexture in connection with mipmaps. If a more experienced user has some ideas, please feel free to comment ...