Ground is only showing as black with no colour or texture

Hi, I am quite new to using Panda3d so am quite inexperienced with the engine, although I have been programming in Python for a while now. I am creating a program which is supposed to search a maze and find the exit point. I am trying to set up my scene but when I try and load the model of the ground it loads in but it is only black and shows no texture. I am unsure if it is something wrong with the model or if there is something with the lights in the scene which I am doing wrong so any help is appreciated. My code is below:

    def loadGround(self):
        #load ground
        ground = self.loader.loadModel(self.mydir + "/my-models/Ground2")
        ground.setScale(10,10,10)
        ground.setPos(0,0,-5)
        ground.reparentTo(self.render)
        
    def loadMaze(self):
        #load maze
        maze = self.loader.loadModel(self.mydir + "/my-models/HamptonCourtMaze")
        maze.setScale(.7,.7,.7)
        maze.setPos(-7,20,-3)
        maze.reparentTo(self.render)
        
    def setupLights(self):
        # lights
        self.ambientLight = self.render.attachNewNode(AmbientLight('ambient'))
        self.ambientLight.node().setColor((0.1, 0.1, 0.1, 1))
        self.render.setLight(self.ambientLight)
        # directional lights
        self.dirLight = self.render.attachNewNode(DirectionalLight('directional'))
        self.dirLight.node().setColor((.1, .1, .25, 1))

        # setup light vector
        lightFromBack = .4
        lightFromLeft = .2
        lightFromBottom = 1
        lightVec3 = Vec3(lightFromBack, lightFromLeft, lightFromBottom)
        lightVec3.normalize()
        self.dirLight.node().setDirection(lightVec3)
        self.render.setLight(self.dirLight)

        # add spotlight for shadows
        self.spotLight = self.render.attachNewNode(Spotlight('spot'))
        self.spotLight.node().setColor((1, 1, 1, 1))
        self.spotLight.node().setShadowCaster(True, 1024, 1080)

        #fitting near and far planes for the light
        self.spotLight.node().getLens().setNearFar(0.1,20)
        #setting the light cone to be narrower
        self.spotLight.node().getLens().setFov(25)
        #smoother falloff
        self.spotLight.node().setExponent(120)
        self.spotLight.set_pos(-8,0,8)
        self.render.setLight(self.spotLight)

I cannot add the files in the topic as I am a new user but I can provide them if needed.


I have also added an image of what the scene looks like when it is running. Like I said previously I am very new to Panda3d so any advice at all will be really appreciated

Hi, welcome!

This can be due to a range of issues. It would be helpful for you to do a bit more trouble-shooting, such as disable all of the the setLight calls to see if disabling lighting makes any difference at all, and enabling two-sided rendering using render.setTwoSided(True) for a moment to see whether the ground may be upside-down.

We may need to know a bit more about how you created and exported the models, and which format they are in.

As an aside, I do not recommend using a size of 1080 for the shadow caster. I recommend sticking with 1024x1024, since power-of-two sizes are more efficient.

Hello and thank you for the reply. I have tried to do a bit of debugging on my own and if I turn the lights off the ground remains black but the maze is a lighter green than it was in the picture which I added in the last post. I have also tried the self.render.setTwoSided(True) and the ground is not upside down.
The files that I am using are both egg files, the maze was exported from blender using the YABEE exporter and the ground was taken from here (it is Ground2). I am unsire for what the next step of debugging would be as this is my first time using a programming heavy game engine (I have used Unity in the past)

Continuing the discussion from Ground is only showing as black with no colour or texture:

I think it may have been something to do with the model as I have now changed my environment to something different and it shows with the textures loaded.

@kian5749
Which version of YABEE are you using?

I used the Yabee for blender 2.8 which I believe is not the official Yabee exporter?

Yes, it’s broken, too.

This indicates that the author has made changes for himself. This is not public.

As for the ground, there may also be problems with the material. But this needs to be clarified.

I have managed to get the colours and textures for another environment to load into the scene so I am guessing that it has something to do with the .egg file itself. The old model was from alice.org but the new model I am using is from ArsThaumaturgis’ panda sample models which seems like a much better quality model. Thank you for your help. I am sure I will be back here over the course of this project :slight_smile:

Another quick question sorry. Is there a place that I can download good p3d models? I am after a player model (preferably human) all the assets which are on alice .org (won’t let my hyperlink again) do not load the textures correctly for me. I have tried loading them manually with the self.loader.loadTexture() but that doesn’t work and loading it within the egg file with the file path does not work either.

If you’re looking for panda models, this doesn’t make sense. You use a blender and it’s an exporter:

You can convert any models to upload to panda.

Please note that these are not panda models.
http://alice.org/pandagallery/Environments/index.html

Okay, thank you! Does blend2bam support a specific version of blender? Or am I free to use blender 2.9? Also the reason I thought that the alice web page had panda3d files was because I seen it on a post on this forum I believe, which is why i used it.

Yes, there are versions of egg, but the question is when were they made?

I believe that the following repository includes a free-to-use human model:

(See the license in the base directory of that repository–direct link here–for information on the legalities of using what’s provided there.)

Ah okay. this must be like teaching a toddler for you :slight_smile:. So the older versions of egg files are no longer compatible with the newer versions of p3d. I feel like I’m starting to understand the engine a bit better now but there is still a lot of learning to do .

It depends on what kind of renderer you are using.

Yes thank you! I found this model not too long ago after following your tutorial, although the textures are not loading for the model. I am trying to do a bit of debugging now to see what the problem is.

1 Like

If you’re having texture-loading problems with models from multiple sources, including Wezu’s above, then I’m inclined to suspect that the problem isn’t with the models.

It may be that the exporter that you’re using has problems, as suggested above, or that you’re not keeping the textures in the right place relative to the models, or that you have the wrong settings applied–or something else that doesn’t occur to me offhand.

For reference, I’m using Panda 1.10.8, and having just downloaded the egg-version of Wezu’s Panda-chan (the model to which I linked above), loading it in PView shows the textures as expected.

I have tried to have a look at where the path is supposed to be for the panda-chan model but because it is an .egg.pz I could not find it when I open the .egg file in a text editor as it is compressed. Is there a way to see the path from the compressed file? I assumed the textures file is just named ``textures’’ as it is when the master file is downloaded. I know how to include the texture file path in the egg file, but I cannot since the .egg is zipped. I am sorry if I am annoying you with all the questions.

You’re not annoying me at all. :slight_smile:

So, if you just download the master file (and unzip it, if you downloaded it as a single zip), you should end up with a hierarchy that, in part, looks something like this:

p3d_samples-master/
   |
   ---> models/
          |
          ---> texture/
          |       |
          |       ---> <various texture-files>
          ---> act_p3d_chan.egg.pz

That is, “act_p3d_chan.egg.pz” should be located in the same directory as the sub-directory “texture”.

If, in this state–i.e. with no changes made–you simply open “act_p3d_chan.egg.pz” with PView, you should see the model with its full set of textures. Is that the case on your end?