Hello my friends:
Trying to figure simplest way to get ‘bump map’ and ‘shininess’ to work in the game.
here is my workflow so far.
I create my model and apply the textures in Blender. Then in export I select GLTF
(I’m new they will only let me upload 1 screenshot )
Making sure to choose GLTF embedded, in order to pack the textures with the file.
I like to go on this site, upload my file to get a preview;
GLTF online Viewer
The results in the game engine after adding lights, still aren’t what you would expect;
What we need is a ‘shader’ that tells Panda3d how to display that bump map and the glossyness.
but all the tutorials I tried were for the old .egg format not GLTF. and for some reason I can’t get it to work.
My question is there a sort of ‘toggle’ to just tell panda to do it? Like built into the engine?
Panda3d.core.Shader
from panda3d.core import Shader
# Something like this;
self.abracadabra.allMyTexturesAppear
If any of you fellas can point me in the right direction I would be much obliged.
Not That its relevant but the code just in case;
#!/usr/bin/env python3
"""
Works but we need to figure out how to use a 'shader'
in order to apply the bump-mapping
My red cube if you load it in a GLTF you will see has bump map on it.
"""
import sys
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.actor.Actor import Actor
from direct.interval.IntervalGlobal import Sequence
from panda3d.core import Point3
from panda3d.core import AmbientLight
from panda3d.core import DirectionalLight
from panda3d.core import LPoint3
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.accept('escape', sys.exit)
# Disable the camera trackball controls.
self.disableMouse()
# Check video card capabilities.
if not self.win.getGsg().getSupportsBasicShaders():
addTitle("Bump Mapping: "
"Video driver reports that Cg shaders are not supported.")
return
# put some lighting on the model
dlight = DirectionalLight('dlight')
alight = AmbientLight('alight')
dlnp = render.attachNewNode(dlight)
alnp = render.attachNewNode(alight)
dlight.setColor((1.0, 1.0, 1.0, 1))
alight.setColor((0.5, 0.5, 0.5, 1))
dlnp.setHpr(0, -60, 0)
render.setLight(dlnp)
render.setLight(alnp)
# Load the environment model.
self.scene = self.loader.loadModel("models/floor_plane.gltf")
# Reparent the model to render.
self.scene.reparentTo(self.render)
# Apply scale and position transforms on the model.
self.scene.setScale(1, 1, 1)
self.scene.setHpr(0, 90, 0)
self.scene.setPos(0, 0, 0)
# Add the spinCameraTask procedure to the task manager.
self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
# Load and transform the panda actor.
self.textcube = Actor("models/textured_cube.gltf")
self.textcube.setPos(0, 0, .5)
self.textcube.setScale(0.5, 0.5, 0.5)
self.textcube.reparentTo(self.render)
# Load and transform the panda actor.
self.pandaActor = Actor("models/shiny_red_cube.gltf",
{"walk": "models/panda-walk4"})
self.pandaActor.setPos(3, 3, .5)
self.pandaActor.setScale(0.5, 0.5, 0.5)
self.pandaActor.reparentTo(self.render)
# Define a procedure to move the camera.
def spinCameraTask(self, task):
angleDegrees = task.time * 6.0
angleRadians = angleDegrees * (pi / 180.0)
speed = 20
offset = -10
zheight = 2.5
self.camera.setPos(speed * sin(angleRadians), offset * cos(angleRadians), zheight)
self.camera.setHpr(angleDegrees, 0, 0)
return Task.cont
app = MyApp()
app.run()