[HELP] Texture discontinuity on borders

starlike

06-11-2005 08:49:01

Sorry for poor english... :?

I could see texture discontinuity as follows:



So, I modified one of the terrain texture(ps_texture_1k.1.1.png) to see what is happening in detail. See the modified texture below:


The outline of 1 pixel width is fill with black, and the next inner 1 pixel is filled with red.

And the result is like this.

Left top:

Right top:

Left Bottom:

Right Bottom:

Full view:


It seems that the top and left border of the texture are rendered correctly
but the bottom and right look like missing some part of texture,
in this case the outer black line is totally missing.
I guess this missing part of texture could make the discontinuity.

Any idea?


About the test environment,
- Ogre Source : 1.0.5 Azathoth source code release (not from CVS)
- PLSM2: Ogre 1.05 SDK compatible PLSM2 source from http://tuan.kuranes.free.fr/OgreSDKplsm2source.7z
- The terrain(ps_height_1k) is generated using mapsplitter.
I used PageSize=257 instead of PageSize=513 from original file included in the PLSM2 source package.
Also, I modified some contents of ps_height_1k.cfg as below:
Width=4
Height=4
PageSize=257
- I've tested the original configuration, and this discontinuity is also shown.

tuan kuranes

06-11-2005 10:48:30

nice finding and well explained.

if you want to fix it , look in paginglandscaperenderable::loadtexturecoordinates, how we compute K_Tex1DataPos and K_Tex2DataPos, we must be missing something. (beware, it's per tile, not per page/texture)

Or I'll try to fix that tomorrow.

starlike

06-11-2005 14:16:24

It's better to wait for your fix, I guess. :)

Thank you.

tuan kuranes

07-11-2005 12:50:02

Done, will soon be in cvs.
And thanks for the red-black border method it make it a lot easier.

starlike

08-11-2005 15:23:05

Thank you for the fix, Tuan.

I checked the CVS source you updated.

I found that PagingLandScapeRenderable::loadTextureCoordinates() has been moved into PagingLandScapeTextureCoordinatesManager::getBuffer(). And, as far as I found, the only change related with this discontinuity is:

const Real Aux1 = 1.0 / mOpt->PageSize;

is replaced with

const Real Aux1 = 1.0 / (mOpt->PageSize-1);

So, I modified PagingLandScapeRenderable::loadTextureCoordinates() and tried again.

Here are two screenshots of right bottom side.





As you can see, the missing texture seems to be shown correctly, but the texture is flickering as I move the camera.
Thus, I checked the wireframe of terrain, and found something wrong. Here is the screenshot of wireframe.


It looks like something wrong.... doesn't it?

This is the wireframe of original code, that is, Aux1 = 1.0 / mOpt->PageSize.
Even though it has problem with texture coordinates, but the wireframe looks fine.


I guess I'm still missing something.
It will be appreciated if you give me more hints.

I'm going to try CVS versions tomorrow.

tuan kuranes

08-11-2005 15:34:18

you missed the modification applied when vertexcompression is used.

vertexcompression uses textures coordinates as x,z position for vertex.
it needs this :

const double scalemodif = static_cast <double> (PageSize - 1) / PageSize;
ScaledPageSizeX = scale.x * scalemodif;
ScaledPageSizeZ = scale.z * scalemodif;

in paginglandscapeoptions.cpp

starlike

08-11-2005 23:09:21

Oops! :shock:
I thought that I looked over whole changes, but I missed OgrePagingLandScapeOptions.cpp.

Thank you for your comment.