Loading .gltfs without panda3d-simplepbr

Hi folks,

I am struggling to display textures correctly together for (a) .gltfs exported from Blender 2.8 with embedded textures and (b) textures loaded from .jpg files with loader.loadTexture() (for a GeoMipTerrain).

For (a), the colors are incorrect unless I use panda3d-simplepbr:

However, using panda3d-simplepbr seems to prevent (b) textures from displaying at all, showing just a gray area (I have tried playing with adding various lights in Panda3D, and that does not seem to be the problem).

What is the simplest approach to make these both work together? Can the color issue be fixed without using simplepbr, or can I do anything to make the basic textures display with it enabled?

To be clear, you are saying that with panda3d-simplepbr, the textures are not appearing correctly on your terrain, but correctly on your model?

Thanks for your reply. Yes, the textures are not appearing on the terrain, but correctly on the model.

I’ve attached a screenshot and code showing both terrain and model without (left) and with (right) panda3d-simplepbr. As you can see, the colors on the model are strange (blueish) without panda3d-simplepbr, and correct for the model but not shown at all for the terrain with it enabled.

The colors seems hazy on the right image because of the ambient light - removing that makes the right model look totally normal, but is necessary to show the terrain on the left. Is there some sort of interaction between these lights that needs to be taken into consideration when using python3d-simplepbr?

import simplepbr
from direct.showbase.ShowBase import ShowBase
from panda3d.core import AmbientLight, DirectionalLight, GeoMipTerrain, PointLight, TextureStage, VBase4

class MyApp(ShowBase):
  def __init__(self):
    ShowBase.__init__(self)
    simplepbr.init()  # commenting this out to disable

    terrain = GeoMipTerrain('terrain')
    terrain.setHeightfield('heightmap.png')
    root = terrain.getRoot()
    root.setScale(10, 10, 10)
    root.setPos(-100, 0, -10)
    root.setTexScale(TextureStage.getDefault(), 16)
    root.setTexture(loader.loadTexture('grass.jpg'))
    root.reparentTo(render)
    terrain.update()

    model = loader.loadModel('lion.gltf')
    model.setScale(0.5, 0.5, 0.5)
    model.setPos(0, 5, -1)
    model.reparentTo(render)

    alight = AmbientLight('alight')
    alight.setColor(VBase4(0.3, 0.3, 0.3, 1.0))
    alnp = render.attachNewNode(alight)
    render.setLight(alnp)

    plight = PointLight('plight')
    plnp = render.attachNewNode(plight)
    render.setLight(plnp)

app = MyApp()
app.run()

Perhaps @Moguri could confirm, but I don’t think panda3d-simplepbr supports texture transformations as of yet. So the texture is instead stretched across the entire terrain.

You can disable the shader for the terrain only by calling root.setShaderOff(1). Then the PBR shaders will only be active on all the other objects.

Correct, texture transforms have not been implemented for panda3d-simplepbr. Enabling the auto shader on the terrain (root.set_shader_auto(True)) should also give it a ShaderAttrib that will override the one assigned to base.render by panda3d-simplepbr.

Many thanks to you both for your help with this! Both setShaderOff and set_shader_auto fixed the problem :smiley: