Apply a normal map from an saved image

Hi

I am trying to apply a normal map to a model I have created in blender. I baked the textures and normal map and saved them in png files. I maneged to write a shader to show the normal map, but I would like to try the shader generator, but I can’t make it work. For some reason I can’t apply the normal map.

The code is a little disorganized (I have been testing a couple of thing in the file.) But It’s not much.

Here is the code file.

from math import pi, sin, cos
import sys,os 
from pandac.PandaModules import *

from direct.showbase.ShowBase import ShowBase
"""from pandac.PandaModules import loadPrcFileData
loadPrcFileData("", "want-directtools #t")
loadPrcFileData("", "want-tk #t")"""

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        mydir = os.path.abspath(sys.path[0]) 
        mydir = Filename.fromOsSpecific(mydir).getFullpath()
        base.setBackgroundColor(0.0, 0.0, 0.0)
        render.setShaderAuto()

        #camera does not move
        self.camera.setPos(3,-3,0)
        
        self.bloki = self.loader.loadModel(mydir + "/test/map_test.x.egg")       
        self.bloki.reparentTo(self.render)
        self.bloki.setPos(0,0,-1.5)
        
        
        light = render.attachNewNode("Light")
        modelLight = loader.loadModel("misc/Pointlight.egg.pz")
        modelLight.reparentTo(light)        
        light.setPos(6,-3,6)
        
        self.plight = PointLight('plight')
        self.plight.setColor(VBase4(1, 1, 1, 1))
        self.plnp = render.attachNewNode(self.plight)
        self.plight.setAttenuation(Point3(0, 0, 0.1))
        self.plnp.reparentTo(light)
        render.setLight(self.plnp)
        
        alight = AmbientLight('alight')
        alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        render.setLight(alnp)
        
        tex = loader.loadTexture(mydir + "/test/test-norm.png")
        ts = TextureStage('ts')
        ts.setMode(TextureStage.MNormal)
        self.bloki.setTexture(ts, tex)
        
        """shader = loader.loadShader("shader.sha")        
        self.bloki.setShader(shader)
        self.bloki.setShaderInput("light", light)"""
               
        
        #render.ls()   
    
    
app = MyApp()
app.run()

I uploaded a zip file containing the model and the texture files.
cid-004885d229766a70.office.live … c/test.zip

The files in the zip file are located in a folder named test that is in the same folder as the code file.

And something more. For some reason the camera doesn’t move with the code above.

Your egg file doesn’t contain tangent and binormal information for vertices.

You’d better disable mouse.

Great! Thanks! This helped me a lot!

I believe the post above mine is spam. He’s just trying to sell gold.

Great, thanks for pointing that out. I just cleared his spammy signature line.