Clamping

Blitz3D Forums/Blitz3D Programming/Clamping

JeeyD(Posted 2013) [#1]
Trying to set up a sprite atlas for drawing without bleeding edges, how do you set clampmode in blitz?

Or do you use repeatmode or something else to gee it from bleeding around the edges?

And also which is your favorite atlas / texture packer?


RemiD(Posted 2013) [#2]

how do you set clampmode in blitz?



I think you can do this by adding +16+32 when you load your texture.
TexDiffuse = LoadTexture("TexFile.png",16+32)

See :
http://blitzbasic.com/b3ddocs/command.php?name=LoadTexture&ref=3d_a-z

But if you want a clean texture it is better to let 1 or 2 or 3 pixels of margin around your unwraped triangles when you create the UVMap texture.


Bobysait(Posted 2013) [#3]
It's right for the flag 16+32 (16 for disable U wraping, 32 for V)

But you might also notice "bleeding edges" if the mipmaping is enabled
due to the different size of the texture created for the mipmap, if you have an "alpha" or "masked" texture, it will be smoothed (in a dirty manner)
(especially with tiled-textures > when you have different parts of textures on the same texture, or with "repeated" textures (and, as you describe your need, it is probably the most relevant here))

You can disable the mip maping using "ClearTextureFilters()" and not use the "+8" flag on Loadtexture/LoadSprite

But, it will probably look really rough and not really better :)



ps : JeeyD ... RemiD ... the D'Familly ? ^.^


JeeyD(Posted 2013) [#4]
Thanks for the replies :)

One more question comes to mind, what if you use mipmapping and you use few pixels margin around texture? the actual margins gets tinier with the graphics inside the mipmap till its eventually gone?

How does those two things work together?


Bobysait(Posted 2013) [#5]
the mipmaping generates some lower textures (each one is the half of the previous)
Then in realtime, when the renderworld is called, each entity textured with a "mipmaped" texture will use the sub-texture according to its distance from the camera (actually, it depends on the average pixelsize rendered)
then, all you have to know is that a texture generates mipmaped textures as long as the texture size is greater than "1".
So, the last mipmaped level is a 1*1 color pixel.
Whatever you use pading on your texture, there will always be some kind of blurish artifacts at a level or an other.

the flag 16+32 prevents from wraping the coords, but it depends on the graphics card parameters (set in the GC control panel, It's up to the user to set this to get the best 'performance vs nicest render' rate. In blitz, all you can setup is wether or not you enable the mipmaping on a texture. And whatever you enable it or not, some GC card override this state on the control panel) and whatever you choose, th wrap flag is only applyed on the main texture borders. It does not help to avoid wraping on a small part of the texture

maybe the solution would be to extract each sub-image from your sprite sheet to single textures. Then, the mipmaping will still be there, but it will just blur single texture.
By the way, there is also the LoadAnimTexture that can help (if your sprites are all same size on the sheet)
not sure, but I think it might solve your problem (each sprite would be stored as a single frame)


JeeyD(Posted 2013) [#6]
Great info, thanks alot. Time to get digging!!