Smeared Texture on Sphere

Hi, I half copied this program to test texture config, and when run on Windows 10, it shows a “smeared” texture. How do I fix this to show a non-smeared one?


Original texture image (taken from Wikimedia Commons):

The “test_model.stl” is a sphere.

Any help would be appreciated. Thanks in advance.

from direct.showbase.ShowBase import ShowBase, Texture


class TextureTester(ShowBase):
  def __init__(self):
    ShowBase.__init__(self)
    self.model = self.loader.loadModel('test_model.stl')
    self.model.reparentTo(self.render)
    self.model.setScale(1, 1, 1)
    self.model.setPos(0, 0, 0)
    self.tex = self.loader.loadTexture('test_texture.jpg')
    self.tex.setWrapU(Texture.WM_repeat)
    self.tex.setWrapV(Texture.WM_repeat)
    self.model.set_texture(self.tex)
    self.useDrive()
    self.useTrackball()


app = TextureTester()
app.run()

I’m only seeing a single colour on your sphere, which suggests to me that it’s using a single point on the image for the whole thing, and thus that the sphere isn’t mapping its vertices across the image. So, does your sphere have a UV-map? If not, then giving it one may well solve your problem.

1 Like

Thanks! That seems to have been the problem:

Adding these lines solved it:

from panda3d.core import TextureStage, Texture, TexGenAttrib
self.tex = self.loader.loadTexture('test_texture.jpg')
# v added this line
self.model.setTexGen(TextureStage.default, TexGenAttrib.MWorldPosition)
# ^ added this line
self.tex.setWrapU(Texture.WM_repeat)
1 Like