Thank you for the reply. I just read this message.
I read the panda3d-simplepbr example. It needs to install gltf. May I ask what is gltf? I run the command pip install panda3d-gltf
to install gltf, is it correct?
I try the auto shader
and simplepbr
to try about the lighting when I use gl-version 3 2
. But not working, Here is my code:
import simplepbr
from panda3d.core import loadPrcFileData
configVars = """
win-size 1280 720
fullscreen 0
show-frame-rate-meter 1
gl-version 3 2
"""
loadPrcFileData("", configVars)
from direct.showbase.ShowBase import ShowBase
from panda3d.core import PointLight, AmbientLight, NodePath
from math import sin, cos
from direct.filter.CommonFilters import CommonFilters
class LightsAndShadows(ShowBase):
def __init__(self):
super().__init__()
self.set_background_color(0, 0, 0, 1)
self.cam.setPos(0, -12, 0)
# simplepbr
# simplepbr.init()
self.tree1 = self.loader.loadModel('jack')
self.tree1.setPos(0, 0, -2.5)
self.tree1.reparentTo(self.render)
self.tree2 = self.loader.loadModel('jack')
self.tree2.setPos(4, 5, 2.5)
self.tree2.reparentTo(self.render)
self.tree3 = self.loader.loadModel('jack')
self.tree3.setPos(-4, 7, 2.5)
self.tree3.reparentTo(self.render)
# self.trees.reparentTo(self.render)
self.floor = self.loader.loadModel('my-models/floor')
self.floor.setPos(0, 0, -2.5)
self.floor.reparentTo(self.render)
self.light_model = self.loader.loadModel('models/misc/sphere')
self.light_model.setScale(0.2, 0.2, 0.2)
# self.light_model.setPos(4, -4, 0)
self.light_model.reparentTo(self.render)
plight = PointLight("plight")
plight.setShadowCaster(True, 1024, 1024)
self.render.setShaderAuto()
plnp = self.light_model.attachNewNode(plight)
# plight.setAttenuation((1, 0, 0)) # constant, linear, and quadratic.
self.render.setLight(plnp)
alight = AmbientLight("alight")
alight.setColor((0.04, 0.04, 0.04, 1))
alnp = self.render.attachNewNode(alight)
self.render.setLight(alnp)
self.floor.setLight(plnp)
self.floor.setLight(alnp)
filters = CommonFilters(self.win, self.cam)
filters.setBloom(size="large")
# Auto Shader
# self.render.setShaderAuto()
self.taskMgr.add(self.move_light, "move-light")
def move_light(self, task):
ft = globalClock.getFrameTime()
self.light_model.setPos(cos(ft)*4, sin(ft)*4, 0)
return task.cont
game = LightsAndShadows()
game.run()
I commented the self.render.setShaderAuto()
and simplepbr.init()
. If you want to use it you can uncomment the commands.
-
self.render.setShaderAuto()
not working in my program.
-
simplepbr.init()
have those error:
Traceback (most recent call last):
File "/Users//gitdir/fyp/panda3d/other/test_lighting.py", line 81, in <module>
game = LightsAndShadows()
File "/Users//gitdir/fyp/panda3d/other/test_lighting.py", line 25, in __init__
simplepbr.init()
File "/Users//opt/anaconda3/envs/py310/lib/python3.10/site-packages/simplepbr/__init__.py", line 350, in init
return Pipeline(**kwargs)
File "/Users//opt/anaconda3/envs/py310/lib/python3.10/site-packages/simplepbr/__init__.py", line 128, in __init__
self._recompile_pbr()
File "/Users//opt/anaconda3/envs/py310/lib/python3.10/site-packages/simplepbr/__init__.py", line 214, in _recompile_pbr
pbr_vert_str = _load_shader_str('simplepbr.vert', pbr_defines)
File "/Users//opt/anaconda3/envs/py310/lib/python3.10/site-packages/simplepbr/__init__.py", line 48, in _load_shader_str
with open(os.path.join(shader_dir, shaderpath)) as shaderfile:
FileNotFoundError: [Errno 2] No such file or directory: './shaders/simplepbr.vert'
If you don’t understand my explanation, please feel free to tell me. And thank you for reading this.