Cube Map Error. OSError: Could not load cube map: sky#.png

Hello and good day. Also thank you in advanced for helping. I’m pretty new to panda3d and always run into a problem, but up till now I’ve got one I can’t figure out…
this is a section of the code with the error messages at the bottom.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
import math
from panda3d.core import CollisionTraverser, CollisionHandlerPusher
from panda3d.core import CollisionNode, CollisionSphere

class Scene(ShowBase):
    def __init__(self):
        super().__init__()

        self.loader.loadCubeMap('sky#.png')

        self.scene = self.loader.loadModel("models/sky.bam")
        self.scene.reparentTo(self.render)
        self.scene.setScale(.75, .75, .75)
        self.scene.setPos(0, 10, -0.1)

        self.scene = self.loader.loadModel("models/ground.bam")
        self.scene.reparentTo(self.render)
        self.scene.setScale(.75, .75, .75)
        self.scene.setPos(0, 10, -0.1)

        self.square = self.loader.loadModel('models/square.bam')
        self.square.setScale(1.5, 1.5, 1.5)
        self.square.setPos(0, 25, 10)
        self.square.reparentTo(self.render)

        self.sphere = self.loader.loadModel('models/sphere.bam')
        self.sphere.setScale(1, 1, 1)
        self.sphere.setPos(0, -7, 0)
        self.sphere.reparentTo(self.render)

C:\Users\owner\PycharmProjects\gameproject\venv\Scripts\python.exe C:/Users/owner/PycharmProjects/gameproject/gm.py
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:gobj(error): Texture::read() - couldn’t read: sky0.png
:gobj(error): Texture “sky#.png” cannot be read.
Traceback (most recent call last):
File “C:\Users\owner\PycharmProjects\gameproject\gm.py”, line 98, in
game = Scene()
File “C:\Users\owner\PycharmProjects\gameproject\gm.py”, line 11, in init
self.loader.loadCubeMap(‘sky#.png’)
File “C:\Panda3D-1.10.12-x64\direct\showbase\Loader.py”, line 923, in loadCubeMap
raise IOError(message)
OSError: Could not load cube map: sky#.png

Process finished with exit code 1


Not really sure what to think of this. My files are in my texture’s folder which is labeled “models” so it shouldn’t be my dear old friend “path issue”. also noteworthy, I made the sky#.png files in paint by grabbing some pictures of clouds off the internet. Could picture resolution/orientation be an issue?

Greetings, and welcome to the forum! I hope that you find your time here enjoyable! :slight_smile:

As to your problem, I’m not sure that it isn’t a path issue: I don’t see mention of the texture-directory in the file-path that’s being passed into your call to “loadCubeMap”.

Unless you have that directory in your model-path…?

I’ve gone ahead and, in the snippet,

self.loader.loadCubeMap(‘sky#.png’)

did this

self.loader.loadCubeMap(‘models/sky#.png’)

and got this now.

C:\Users\owner\PycharmProjects\gameproject\venv\Scripts\python.exe C:/Users/owner/PycharmProjects/gameproject/gm.py
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
Assertion failed: x_size == y_size at line 6775 of c:\buildslave\sdk-windows-amd64\build\panda\src\gobj\texture.cxx
:gobj(error): Texture “/c/Users/owner/PycharmProjects/gameproject/models/sky#.png” cannot be read.
Traceback (most recent call last):
File “C:\Users\owner\PycharmProjects\gameproject\gm.py”, line 98, in
game = Scene()
File “C:\Users\owner\PycharmProjects\gameproject\gm.py”, line 11, in init
self.loader.loadCubeMap(‘models/sky#.png’)
File “C:\Panda3D-1.10.12-x64\direct\showbase\Loader.py”, line 920, in loadCubeMap
texture = TexturePool.loadCubeMap(texturePattern, readMipmaps, loaderOptions)
AssertionError: x_size == y_size at line 6775 of c:\buildslave\sdk-windows-amd64\build\panda\src\gobj\texture.cxx

Process finished with exit code 1

I use Pycharm, I assume it takes the path in some small instances but to go ahead and clear that fog I’ve done the change as shown above. I now get this somewhat new error… Not sure what to think of it, assertion error? :frowning:

Judging by the error, it appears to me that that Panda is expecting the cube-map textures to be square, but that at least one of them isn’t.

I may be mistaken, but I think that you can generally assume that the program knows about the main program directory–and that directories can be specified relative to that program directory–but that otherwise paths should be specified.

So, for example, if your program directory is as follows:
c:\cat\mew\
Then, given the following file:
c:\cat\mew\kitten.png
It should be safe to load it thusly:
loader.loadTexture("kitten.png")
But given the following file:
c:\cat\mew\kitty\kitten.png
The following would likely not work:
loader.loadTexture("kitten.png")
But the following likely would:
loader.loadTexture("kitty/kitten.png")

Of course, you can generally modify your model-path as suits your project, I imagine.

Okay so I did the resize of the images and still have the snippet like

self.loader.loadCubeMap(‘models/sky#.png’)

The game runs now but my sky box is still grey/gray…

Well, looking at your code, you don’t appear to be applying your cube-map to anything–you’re loading it, but then not doing anything with the result of that loading.

Specifically, “loadCubeMap” returns a texture, which I imagine that one then applies to an inside-out cube placed into the scene.