The slowdown is completly gone with latest svn. Now I have about 30-90 fps more!
The hardware I used to test is a Geforce 9600GT. I think the problem was that teh whole terrain was rendered before.
Talking about terrain rendering in General:
I am not shure the surface atlas is the ultimate way to go! Here is an alternative way which I already discussed with softcoder ( and I hope he understood what I said with my bad english
) Maybe we can mix some of the ideas to get a good result.
first idea:We use shaders to render the surfaceEach surface type has its own layer and an alpha map which is used for blending using shaders later. (So blending too is no longer made manually by the CPU!)
There is a way to use one alpha map for three layers by using RGB alphas where the red/green or blue stands for one layer. By this we can render 3 of the layers at once in only one render path . So we will need 3 render passes to render all layers.
Problem:
If we would do so we would always render the whole surface! This can be solved by working tile based, but with much bigger tiles than before ( I suggest 16x16 of the former cells ). This means we will have unique alpha maps for each of these squares, but we use the same layers for all of them.
second idea:If we work "big tile based" like suggested to solve the problem mentioned above we should have one big texture for each layer. So one big texture which is used for 16x16 cells instead of only 1 small texture for 1 cell before. The typical size is 1024x1024 for these 16x16 cells ( (16*64) * (16*64) because we typicaly use 64*64 bits to texture one cell ) . This big texture for the one layer is used for ALL 16x16 cell blocks!
How to get this big layer texture?
We calculate it by putting the small texture pieces we have now on the new texture, respecting their given probabilities for usage from the tileset xml.
This will also allow us to use bigger texture tiles up to 1024x1024!
For example imagine we use 128x128 textures: We can use them for 2x2 tiles now. This means we only need 8x8 of them to fill the 16x16 cell texture.
By these bigger texture pieces we are able to show more variety! This is not meant to raise the resolution of the single cell texturing, which is described in the next step:
If we want to use a more detailed texturing ( like for example 128x128 pixels for each cell ) we can introduce a new setting in the xmls( for each layer tyoe ). This setting can be called something like texture factor. typically/default is 1 which means 64x64 bit is used to texture one cell.
2 means 128x128 is used
3 means 256x256 is used and so on .... ( or something similar like the power of 2 saying 6,7,8 ....)
example: if we use factor 2 (128x128) we will have a 2048x2048 texture for the 16x16 cell block.
comments?