Having trouble implementing texture maps

I’ve download these texture maps for a brick texture


and now I’m trying to implement them into the scene using TextureStages.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        render.setShaderAuto()

        cm=CardMaker('')
        cm.setFrame(-1,1,-1,1)
        square = render.attachNewNode(cm.generate())
        square.setPos(0,4,0)
        square.setH(-20)
        square.setScale(3)

        temp = DirectionalLight('temp')
        temp.setShadowCaster(True,2048,2048)
        tempNP = render.attachNewNode(temp)
        temp.getLens().setNearFar(0,5)
        temp.getLens().setFilmSize(5,5)
        render.setLight(tempNP)

        brickColor = loader.loadTexture('APPDEV/test/testTex/brick_color.jpg')
        brickDisp = loader.loadTexture('APPDEV/test/testTex/brick_disp.png')
        brickNormal = loader.loadTexture('APPDEV/test/testTex/brick_normal.jpg')
        brickOcc = loader.loadTexture('APPDEV/test/testTex/brick_occ.jpg')
        brickRough = loader.loadTexture('APPDEV/test/testTex/brick_rough.jpg')

        tsColor = TextureStage('color')

        tsHeight = TextureStage('height')
        tsHeight.setMode(TextureStage.MHeight)

        tsNormal = TextureStage('normal')
        tsNormal.setMode(TextureStage.MNormal)

        tsGloss = TextureStage('gloss')
        tsGloss.setMode(TextureStage.MGloss)

        tsGlow = TextureStage('glow')
        tsGlow.setMode(TextureStage.MGlow)

        square.setTexture(tsColor, brickColor)
        square.setTexture(tsNormal, brickNormal)
        square.setTexture(tsHeight, brickDisp)
        square.setTexture(tsGloss, brickRough)
        square.setTexture(tsGlow, brickOcc)

app = MyApp()
app.run()

Am I doing something wrong? The texture looks the exact same as it did when only color is applied.
Also, do I have the maps linked to their correct Texture Stages? eg. brickRough to tsGloss.
I can upload the texture maps if needed

I definitely can’t say what’s wrong with you. But I had an example of a normal map test.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import loadPrcFileData, Point3, TextureStage, PointLight, Vec4
loadPrcFileData("", "parallax-mapping-samples 3")
loadPrcFileData("", "parallax-mapping-scale 0.1")

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        light = render.attachNewNode("light")
        light.setPos(0,0,0)
        light.hprInterval(8, Point3(360, 0, 0)).loop()

        plight = PointLight('plight')
        plnp = light.attachNewNode(plight)
        plnp.setPos(0, 1.5, 0)
        plight.setColor(Vec4(1,1,1,1))

        render.setShaderAuto()
        render.setLight(plnp)

        Object = loader.loadModel('test')

        layer1 = TextureStage('normal')
        layer1.setMode(TextureStage.MNormal)
        Object.setTexture(layer1, loader.loadTexture('layingrock-n.png'))

        layer2 = TextureStage('diffuse')
        layer2.setMode(TextureStage.MModulate)
        Object.setTexture(layer2, loader.loadTexture('layingrock-c.jpg'))

        Object.reparentTo(render)

app = MyApp()
app.run()



test.egg (6.8 KB)

Most likely the case is CardMaker.

*ping!* Ah, that just reminded me–you’re quite right, I do think! If I recall correctly, CardMaker doesn’t generate tangents and bi-normals, and thus normal-mapping won’t work.

I don’t know whether there’s a way to convince CardMaker to generate those elements, offhand. It might be simpler to just model a quad in a 3D modelling package (such as Blender) and export it with tangents and bi-normals.

Yes, I don’t really see the benefits of CardMaker over the mesh.

It’s sometimes convenient to use CardMaker–but yeah, in this case a mesh is likely by far the easier way to go.

CardMaker is convenient for me for a 2D screen (for example: like a canvas for a movie), not 3D.

I have used it as a convenience in putting together a simple tile-based 3D world–but it’ll likely be replaced for that purpose in due course. (I’m seeing occasional gaps between cards, so I fear that I’m likely going to end up going with procedural geometry.)

Thank you! CardMaker does seem to be the problem.

1 Like

Thank you, I did exactly that and it worked :slight_smile:

1 Like

How did you generate your egg file if you dont mind me asking?

I don’t know how serega-kkz did it in that example, but it should be fairly easy to make such a model in a 3D modeller such as Blender, and then export it via YABEE. (Make sure that, in the YABEE export-screen, “TBS generation” isn’t set to “no”!)

1 Like

And it exports as an egg file? Thank you! That’s super convenient

Yup! That’s how I make nearly all of my egg-models. It really is often convenient. :slight_smile: