terrain

Posted By: Robotronic

terrain - 12/20/06 17:38

Hello!
Iīve got a question about chunked terrain.
For a very large outdoor area I would like to use several different chunked terrain entities, and wanted to ask if this is possible /recommended.
Basically I already tested this, it works fine, but Iīm not 100 percent sure if it is rendered as chunked or non-chunked.
I ask this. because the manual (in the entity chapter) says: "The catch is that a chunked terrain can't be put multiple times in the level ...", and now I am a little bit unsure. Does this mean, that I should use only one chunked terrain in a level?

Another thing - Iīm not sure if someone has already mentioned: I heve the impression, that the multitexture shader from the templates (A6.50) doesnīt switch to mipmaps for the red and green channel. The texture that I use, where the color map is black works fine. I tested this with different textures, formats and terrains. Maybe I have do do something with bitmap_to_mipmap?
Thanks for looking into this ...
Posted By: jcl

Re: terrain - 12/21/06 17:46

You can use multiple chunked terrains as long as they are different. You can not use two chunked terrain entities that have the same terrain file.

The mipmap processing occurs before the shader stage. Thus a shader has no influence on whether mipmaps are used or not.
Posted By: Robotronic

Re: terrain - 12/21/06 22:34

Fine, Iīm glad to hear this, especially about the chunked terrain. Now I just have to figure out, how I can proceed with my mipmaps. Maybe bitmap_to_mipmap will work.
Thanks, and a nice christmas to all Conitecs!
Posted By: Joey

Re: terrain - 12/22/06 10:50

but beware since these bitmap functions are rather slow, even though they might write directly to the grapics memory (do they?).
Posted By: Robotronic

Re: terrain - 12/22/06 11:19

Well, basically I created the mipmaps already in MED, when I was seting up the skins. But somehow they donīt show up. Maybe I missed something, but MED tells me, that all my skins have mipmaps.
I was looking into other multitexture code, and in one case, for example it is done like this:

bmap tex3 = <Landstrasse.tga>; // Texture Layer Red
bmap tex4 = <Fels.tga>; // Texture Layer Green
bmap tex5 = <FelsB.tga>; // Texture Layer Blue
bmap tex6 = <Grasboden.tga>; // Texture Layer Black


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

}


material multirgb {
flags = tangent;
skin1 = tex3;
skin2 = tex4;
skin3 = tex5;
skin4 = tex6;

event=multirgb_roughness; // here the mipmaps are created ...

effect
" //...

Maybe I can adapt this to the template code. The material from the templates however works a little bit different, since it uses internal skins from the terrain entity, so they should already be there? I like this shader, because it works so well with sun_color and lighting ...
Posted By: Joey

Re: terrain - 12/22/06 16:30

it's ok to use the functions only once, shouldn't produce much overhead.
Posted By: Robotronic

Re: terrain - 01/07/07 20:10

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 ...
Posted By: jcl

Re: terrain - 01/08/07 13:01

This works, but I would not recommend that. A much easier way - without any code changes - is clicking the "Mipmaps" checkbox in MED skin settings. It then also loads faster.

For external textures the skin settings have no effect, but you can then use DDS textures with mipmaps.
Posted By: Robotronic

Re: terrain - 01/08/07 18:48

Thanks again for looking into this.
Actually thatīs what I did, before I started this research project: I loaded all the skins with the skin manager in MED, the mipmap checkbox was checked by default, and I expected the mipmaps to show up in the engine. For normal models this works fine, but I tested this with different terrains and texture formats (512*512, .tga and DDS with internal mipmaps) but only the first terrain texture (the second skin) was using the mipmaps. The textures that are used for the red and green parts of the RGB map appeared too sharp (pixelig) in the distance.

Actually I would prefer the more simple way, it would be also much more flexible, but I have no idea, why the mipmaps donīt show up.
Maybe I should try the .bmp format? Or maybe I missed something, when creating the mipmaps? Any ideas are welcome ...

PS: I use A 6.50.2 and a Radeon X850XT videocard
Posted By: jcl

Re: terrain - 01/09/07 11:07

Maybe you used non-mipmap DDS textures for internal skins? The mipmap checkbox only creates mipmaps for PCX, BMP, or TGA textures. DDS textures are expected to already contain mipmaps.

For the rendering it should not make any difference whether the mipmaps are created by MED, by the DDS paint program, or afterwards by bmap_to_mipmap. The latter has only the disadvantage of slower loading and more code.
Posted By: Robotronic

Re: terrain - 01/09/07 20:19

Actually I created my terrains exactly that way. When I tried DDS textures, I was creating the mipmap chain with the Ati Compressonator, I put the textures in the level folder and in MED I was setting them up as external textures.
But like with (internal) .tga textures only the first texture is rendered with mipmaps. In my terrains the first texture is usuall a gras texture.
I was making some screenshots.

This one shows the terrain with .tga textures (mipmaps created in MED):



This here shows another terrain with DDS texture. While the gras texture is rendered with mips, the roadtexture in the background doesnīt show the mips.



For comparison here are two other screenshots with the modified template code. The road and the rocks are blurred in the distance.





But anyway, if noone else has this problem it is maybe my videocard or something else in my configuration. But the strange thing is, that normally mipmaps do show up. Itīs not an urgent issue for me (Iīm just testing and developping my skills at the moment), but I wanted to inform you about this and if thereīs an opportunity, maybe someone could have a look at this on a different system.
Posted By: Frederick_Lim

Re: terrain - 03/14/07 07:36

I am using A6 Pro 6.50.6. But I am experiencing the same problem:

Quote:

only the first terrain texture (the second skin) was using the mipmaps. The textures that are used for the red and green parts of the RGB map appeared too sharp (pixelig) in the distance.




I use .bmp as texture, I check the Mipmaps button checked in skin2, skin3 and skin4.
Posted By: jcl

Re: terrain - 03/14/07 09:19

Does something change when you use 24 bit TGA instead? BMP is normally converted to 16 bit, which reduces the colors and could maybe give the impression that it's not mipmapped. If the problem also occurs with TGA, can you upload the terrain so that I can look into the problem? On my test terrain the mipmaps work well.
Posted By: Robotronic

Re: terrain - 03/14/07 15:02

Hello!

I had this problem also with .tga textures. I made a little level with the terrain file, if you could look into this, it would be great. I also included DDS Textures, where I had the same problems.

level
Posted By: Frederick_Lim

Re: terrain - 03/15/07 11:50

I replaced all skins with 24 bit TGA but same. And I found the mirror of terrain is strange, it only show the 1st skin in terrain.

http://putstuff.putfile.com/58337/2633198

I also post my problem in another thread

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/736903/Main/736859/#Post736903
Posted By: Robotronic

Re: terrain - 03/27/07 00:23

Unfortunately I found another problem, that might be related.

For a tree I use two different DDS textures one for the leaves and one for the trunk.
When I store the textures separately (MED setting "external"), no mipmaps on my screen.
If I store the same DDS textures (DXT1 and DXT5) in the model file, they work.



The picture shows the tree model. The tree on the left side uses the DDS textures stored internally, the tree on the right side uses the same DDS files. The only difference is, they are now external.

The model on the right side - in comparison to the identical model on the left - is very pixelated, when the view is not close to the models.
Posted By: jcl

Re: terrain - 03/27/07 08:52

Yes, this could be a related problem. I'll be away next week and am having a tight schedule until then, but I'll look into this problem after my return.
Posted By: Robotronic

Re: terrain - 04/16/07 17:45

Any news on this issue?
Posted By: jcl

Re: terrain - 04/17/07 12:46

Not yet, but it's still on my schedule.
© 2024 lite-C Forums