Problem with Normal Maps

Hello all
i’m trying to use Normal Maps I’ve seen this example
http://www.panda3d.org/manual/index.php/Sample_Programs:_Normal_Mapping

and I’ve also read
http://www.panda3d.org/manual/index.php/Texture_Modes

the problem is that i tried to apply the normal maps on a plan using the normal map images from the last example but i failed and i got very weird results

this is my code , i need to know where the problem is
I’m using Panda 1.7 on linux mint 9 ; ATI Radeon 4250

Thanks in advance

import direct.directbase.DirectStart
from panda3d.core import Filename,Shader
from direct.showbase.DirectObject import DirectObject
from direct.filter.CommonFilters import *
from panda3d.core import loadPrcFileData
loadPrcFileData("", "parallax-mapping-samples 3")
loadPrcFileData("", "parallax-mapping-scale 0.1")
from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *

class MyApp(DirectObject):
    def __init__(self):
        if (base.win.getGsg().getSupportsBasicShaders() == 0):
            print("Bump Mapping: Video driver reports that shaders are not supported.")
            return
        tex=[]
        tex.append(loader.loadTexture("layingrock-c.jpg"))
        tex.append(loader.loadTexture("layingrock-n.jpg"))
        tex.append(loader.loadTexture("layingrock-h.jpg"))

        plane=loader.loadModel("plane")

        plane.reparentTo(render)
        
        plane.setTexture(tex[0])
        ts = TextureStage('ts')
        ts.setMode(TextureStage.MNormal)
        plane.setTexture(ts, tex[1])
        
        plane.setScale(9.3)
        plane.setPos(0,0,0)

        dlight = DirectionalLight('my dlight')
        dlight.setColor(VBase4(1, 1, 0.9, 1))
        dlnp = render.attachNewNode(dlight)
        dlnp.reparentTo(camera)
        dlnp.setHpr(0,180,0)
        dlnp.setPos(0,10,0)
        render.setLight(dlnp)

        plane.setShaderAuto()
        plane.setShaderInput("light", dlnp)
        

app = MyApp()
run()

Does your model have tangents and binormals? You can process the egg file with “egg-trans -tbnall” if you’re not sure.

David

1 Like

thanks David for your help
my model doesn’t have tangents and binormals and i didn’t knew about them till now cuz the manual didn’t mention them
i think i will search for this topics and see
thx a lot for your help