When scaling a subsection of a texture, its edges become fuzzy, and some of its surrounding colours spill through. Is there a way to avoid this aside from padding my texture sheets?
Here is my code:
from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.task import Task
pixel2d = NodePath('pixel2d')
pixel2d.reparentTo(render2d)
pixel2d.setPos(-1,0,1)
pixel2d.setScale(2.0/base.win.getXSize(), 1, -2.0/base.win.getYSize())
tex = loader.loadTexture('simpleuis.png')
cm = CardMaker('cardz')
tx, ty = float(tex.getXSize()), float(tex.getYSize())
u, v, us, vs = (2, 2, 98, 197)
u, v, us, vs = u/tx, 1-v/ty, (us+1)/tx, 1-(vs+1)/ty
cm.setUvRange(Point2(u, v), Point2(us, vs))
cm.setFrame(-0, 97, -0, 196)
card1 = NodePath(cm.generate())
card1.reparentTo(pixel2d)
card1.setTexture(tex)
card1.setPos(1, 0, 1)
cm.setFrame(-0, 690, -0, 580)
card1 = NodePath(cm.generate())
card1.reparentTo(pixel2d)
card1.setTexture(tex)
card1.setPos(100, 0, 1)
run()
Here is my texture:
Here’s the result in Panda (enlarged with Photoshop). As you can see, the green edge is spilling through:
Is this kind of precision possible with Panda?