First of all, I would like to point out that perhaps my problem is related to another, probably similar, which I also reported today:
I’m having trouble combining simple environment mapping and "gl-version 3 2"
.
I am trying to follow this tutorial:
https://docs.panda3d.org/1.10/python/programming/texturing/simple-environment-mapping
When I don’t enable newer versions of GLSL (i.e. I don’t set "gl-version 3 2"
in the configuration), everything is OK. A simple environment mapping texture is generated and they can set it on the teapot.
Code:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextureStage, TexGenAttrib, loadPrcFileData
# loadPrcFileData("", "gl-version 3 2")
base = ShowBase()
base.cam.setPos(0, -16, 2)
scene = base.loader.loadModel('environment')
scene.reparentTo(base.render)
scene_bounds = scene.getTightBounds()
base.saveSphereMap('scene_env.jpg', size=256)
teapot = base.loader.loadModel('teapot')
teapot.reparentTo(base.render)
tex = base.loader.loadTexture('scene_env.jpg')
ts = TextureStage('ts')
teapot.setTexGen(ts.getDefault(), TexGenAttrib.MEyeSphereMap)
teapot.setTexture(tex)
base.run()
Effect:
Now let’s assume I enable newer versions of GLSL (that is, I set "gl-version 3 2"
in the configuration). Note that for now, I don’t even set any custom shaders, just enabled the newer GLSL. Let’s also assume that this time I’m not generating a new version of a simple environment mapping texture, I’m using a previously generated one. Unfortunately, the teapot is a uniform dark green (I’m assuming it’s one of the colors of the old texture that has now spread across the entire teapot).
Code:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextureStage, TexGenAttrib, loadPrcFileData
loadPrcFileData("", "gl-version 3 2")
base = ShowBase()
base.cam.setPos(0, -16, 2)
scene = base.loader.loadModel('environment')
scene.reparentTo(base.render)
scene_bounds = scene.getTightBounds()
# base.saveSphereMap('scene_env.jpg', size=256)
teapot = base.loader.loadModel('teapot')
teapot.reparentTo(base.render)
tex = base.loader.loadTexture('scene_env.jpg')
ts = TextureStage('ts')
teapot.setTexGen(ts.getDefault(), TexGenAttrib.MEyeSphereMap)
teapot.setTexture(tex)
base.run()
Effect:
And when I try to generate a new simple environment mapping texture with "gl-version 3 2"
set in the configuration, the process throws the following error message to the console:
:display:gsg:glgsg(error): Sampler type of GLSL shader input p3d_Texture0 does not match type of texture scene_env.jpg.
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
:display:gsg:glgsg(error): Sampler type of GLSL shader input p3d_Texture0 does not match type of texture scene_env.jpg.
The texture generates all black and of course all black also makes the teapot.
Code:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextureStage, TexGenAttrib, loadPrcFileData
loadPrcFileData("", "gl-version 3 2")
base = ShowBase()
base.cam.setPos(0, -16, 2)
scene = base.loader.loadModel('environment')
scene.reparentTo(base.render)
scene_bounds = scene.getTightBounds()
base.saveSphereMap('scene_env.jpg', size=256)
teapot = base.loader.loadModel('teapot')
teapot.reparentTo(base.render)
tex = base.loader.loadTexture('scene_env.jpg')
ts = TextureStage('ts')
teapot.setTexGen(ts.getDefault(), TexGenAttrib.MEyeSphereMap)
teapot.setTexture(tex)
base.run()
Effect: