Trouble applying normal map in texture stage

I’m going to have multiple textures that I want to swap in and out. I want them to have a normal map when I’m switching them out, but having trouble getting the normal map to work.

I’ve setup a simple example with the smiley model and I’m not seeing the normal map applied. Also, the MReplace doesn’t remove the model’s smile texture.

from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject

class world(DirectObject):
  def __init__(self):
    base.cam.setPos(0,-50,0)
    
    self.smiley = loader.loadModel('smiley')
    self.smiley.setScale(8)    
    self.smiley.reparentTo(render)

    self.setupLights()
    
    tex0 = loader.loadTexture("splatter.jpg") 
    tex1 = loader.loadTexture("normal.jpg") 
    #texGloss = loader.loadTexture("gloss.png")
    
    ts = TextureStage('ts')
    #ts.setPriority(1)
    ts.setMode(TextureStage.MReplace)
    self.smiley.setTexture(ts, tex0)

    ts2 = TextureStage('ts')
    #ts2.setPriority(2)
    ts2.setMode(TextureStage.MNormal)
    self.smiley.setTexture(ts2, tex1)
    
  def setupLights(self):
    self.dlight = DirectionalLight('dlight0')
    self.dlight.setColor(VBase4(0.2, 0.2, 0.2, 1))
    self.dlnp = render.attachNewNode(self.dlight)
    self.dlnp.setHpr(0, -5, 0)
    render.setLight(self.dlnp)
    self.alight = AmbientLight('alight0')
    self.alight.setColor(VBase4(0.65,0.65,0.65,1))
    self.alnp = render.attachNewNode(self.alight)
    render.setLight(self.alnp)
    
    render.setShaderAuto()
    

w = world()    
run()

Smiley model doesn’t seem to have tangent and binormal information. Try with a model which has them.

Thanks! That worked on my model. (Haven’t tried it on smiley though)

To add tangent and binormal information to my model I ran:

egg-trans -tbnall -o output.egg mymodel.egg

This should be put in the manual in the normals section.