Texture seams visible from a distance

Blitz3D Forums/Blitz3D Beginners Area/Texture seams visible from a distance

RustyKristi(Posted 2016) [#1]
hey guys probably you have encountered this before but what can I do to fix the texture seams when the model is at a distance from the camera?


Bobysait(Posted 2016) [#2]
This is related to the mip maping.
It happens because mip maps create smaller and smaller textures thoose are replicants from the original but with serveral lower resolutions.
Once on the rendering, the depth of the texture (or the depth of the pixel the texture is applied on) will be used to choose the best mip map to render (it allows to create a low cost bilinear filter and is actually higher to render)

What happens with the seem is that lower resolution removes lots of pixels AND if you use at the same time a tilable texture (that does not clamp UV -> flag 16 and 32 on the texture flag) the seems will bleed.

You can :
Method 1 : Disable the mip maping on load texture (will also requires the use of ClearTextureFilters because by default a loaded texture adds the 1+8 flag to whatever flag you choose -> and "8" is the mipmaping)
(But ! because there is always a "but" : If you remove the mipmaping flag, there won't be any filter anymore for the textures and it will looks very sharpy and probably ugly.)

Method 2 : Try to use textures with paddings on the edges so that lower resolutions will preserve the seems from bleeding.
This method is relevant but not always appliable (does this word exist ?)
And, anyway, there will always be a distance where the texture will use a resolution so small that the seems will bleed.

Method 3 : Clamp the texture on U and V (flag 16+32 on Load/Create Texture) it will prevent your texture from wraping the UV coords.
-> this method works only for "non tiled" textures. (else it disables the tiling effect -> on terrain for example)


RustyKristi(Posted 2016) [#3]
Thanks for the very informative methods on b3d here! I think I'd go with #3. So Clamp is not enabled by default? interesting

not always appliable (does this word exist ?)
applicable


Blitzplotter(Posted 2016) [#4]
@RustyKristi:

The Collins dictionary reckons its a bit on the infrequent side, but here is their reference:

http://www.collinsdictionary.com/dictionary/english/appliable

Very interesting thread with respect to the 'blurring' of textures the further away you get - Method 3 does sound intriguing ;)


RustyKristi(Posted 2016) [#5]
thanks ok I see. I'm still having problems with the clamping and now other materials that depends on it has its textures gone :/

checking with mipmapping.


Polarix(Posted 2016) [#6]
I had this just a second ago but I somehow fixed it


RustyKristi(Posted 2016) [#7]
I had this just a second ago but I somehow fixed it


How?


RemiD(Posted 2016) [#8]
If you disable the bilinear filtering of textures, it helps to have small texels visible even if they are far away, but then you may have a problem with "aliasing"


RustyKristi(Posted 2016) [#9]
hey RemiD, it seams like if I force textures to VRAM, it automatically disables bilinear filtering but have not tested this yet.


Polarix(Posted 2016) [#10]
Before it was fixed it was

CameraRange cam,0.00001,10000000

now it is fixed it is now
CameraRange cam,0.01,1000000


must have something to do with the camera range?


RustyKristi(Posted 2016) [#11]
thanks but did not work for me, same as before


RemiD(Posted 2016) [#12]
In the land of the blinds, the one eyed is king... :P


Zethrax(Posted 2016) [#13]
The minimum camera range should be as high as you can get away with while still fitting inside whatever collision volume you have for the camera. My limited understanding is that the detail level of the Z-buffer (depth buffer) is logarithmic and detail nearer the camera has much greater precision. If the near value is too close to the camera then issues can occur due to the amount of work and resources being used in managing all that depth data.


RemiD(Posted 2016) [#14]
http://www.blitzbasic.com/b3ddocs/command.php?name=CameraRange&ref=3d_a-z

Try and keep the ratio of far/near as small as possible for optimal z-buffer performance and to avoid flickering triangles/objects.




http://www.blitzbasic.com/Community/posts.php?topic=98868

The other thing is that it depends on your camera range. Depending on how far away those building are, it may not have enough precision left for 0.01 to be a meaningful distance.




RustyKristi(Posted 2016) [#15]
Thanks guys. I have now used 1,10000 to be the default camera distance and it did improve a lot! It still did not solve the texture seams problem but I got a lot of flickering and z-depth fighting gone! wow, lesson learned again!

When checking the model, I could see the seam is really in an awkward spot and is not done by properly. I might do some uv remapping to correct this problem.

@RemiD

I have read your older posts and would like to know how you do the skybox switch so I can significantly reduce my far clip to to below 5000 or something that range.


Bobysait(Posted 2016) [#16]
Skybox are most of the time virtual (fake)
-> you don't scale them that large (something like ScaleEntity 5,5,5 is large enough -> it's really just to prevent it does not intersect with the near or far range)

Then, you just set the EntityOrder to something big (like 1000) it will force the skybox to be rendered before anything else and remove the Z-Depth test on it (So everything drawn after will "cover" it, so it will look like it's far ... or at least beyond everything else)

For ex, using a cube as background :
Local cam = CreateCamera()
Local skybox = CreateCube()
FlipMesh skybox ; so we see the inner faces
ScaleEntity skybox, 5,5,5
EntityOrder skybox, 1000 ; large order so it's drawn before everything
EntityFx skybox, 1+8 ; lighting and fog does not affect a skybox

...
Repeat

   ; set the skybox position on each frame, just before Renderworld (or after the last camera transform)
   ; so it doesn't move regarding camera position
   PositionEntity skybox, EntityX(cam,1), EntityY(cam,1), EntityZ(cam,1), 1
   
   RenderWorld()
   Flip True
Until KeyDown(1)
End



ps : for the seems problem, can you post a screenshot from what you're seeing ?
(and eventually a code that produices it)


RemiD(Posted 2016) [#17]

I have read your older posts and would like to know how you do the skybox switch so I can significantly reduce my far clip to to below 5000 or something that range.


@Rustykristi>>i don't remember, please quote what i wrote...


Usually i use a camerarange of 0.1,100 or 0.1,1000 with "impostors" (textured rectangle meshes which represent big far away things) for shapes which are far from the camera.


Bobysait(Posted 2016) [#18]
@About UV Clamp :
it locks the texture to draw only UV on the range [0.0, 1.0] so you don't get the borders bleeding with far mip maps.
It can only work if your UVs are in this range, else it will stretch the pixels of the edge accordingly (if you have a vertex with V=2, you'll get the texture drawn until v=1, then everything after will be the pixels of the right edge (most of the time, we can actually see the lines built by the pixels)

So, if your other textures does not show, maybe your UV map is outside the 0.0,1.0 range.

As mentioned in previous post, this technic can only work for "non-repeating" textures.


Zethrax(Posted 2016) [#19]
Take a look at the castle demo in the Blitz3D 3D samples (eg. C:\Program Files (x86)\Blitz3D\samples\mak\castle ). I think it has a good example of implementing a skybox.


RustyKristi(Posted 2016) [#20]
Thanks guys for the feedback

@RemiD

Here it is but just the steps:
http://www.blitzbasic.com/Community/post.php?topic=98868&post=1158099

@BobySait

I have a typical model like biped characters, without repeating textures.

Thanks Zethrax, I got the skybox figured out and scaled good.


RemiD(Posted 2016) [#21]
@RustyKristi>>What i wrote should work, try it...
Basically between 0.1 and 100 you would have high details meshes (for the things which are near the camera) and low details meshes (for the things which are far from the camera), between 100 and 10 000 you would have a low details terrain and "impostors" (textured flat meshes which represent big far away things, like buildings), and between 10 000 and 100 000 you would have the "fogbox" (the fog you see far away), the "terrainbox" (the mountains you see far away), the "cloudsbox" (the clouds), the sun, the blackskybox (for the night), the blueskybox (for the day).
That's what i remember...