Apply a normal map from an saved image


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):
        mydir = os.path.abspath(sys.path[0]) 
        mydir = Filename.fromOsSpecific(mydir).getFullpath()
        base.setBackgroundColor(0.0, 0.0, 0.0)

        #camera does not move,-3,0)
        self.bloki = self.loader.loadModel(mydir + "/test/map_test.x.egg")       
        light = render.attachNewNode("Light")
        modelLight = loader.loadModel("misc/Pointlight.egg.pz")
        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))
        alight = AmbientLight('alight')
        alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)
        tex = loader.loadTexture(mydir + "/test/test-norm.png")
        ts = TextureStage('ts')
        self.bloki.setTexture(ts, tex)
        """shader = loader.loadShader("shader.sha")        
        self.bloki.setShaderInput("light", light)"""
app = MyApp()

I uploaded a zip file containing the model and the texture files. … c/

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.