Hi, there is absolutly no full example in the web of texturestage, I tried to test it:
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 *
from panda3d.physics import *
from panda3d.ode import *
from random import Random
from direct.particles.ParticleEffect import *
from direct.particles.Particles import *
from direct.particles.ForceGroup import *
from panda3d.bullet import *
from geom import *
from skybox import SkyBox
from direct.gui.OnscreenText import OnscreenText
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.render.setShaderAuto()
ts = TextureStage("TextureStage")
ts.setMode(TextureStage.MModulate)
self.ts = ts
tsNormal = TextureStage("TextureStageNormal")
tsNormal.setMode(TextureStage.MNormal)
self.tsNormal = tsNormal
nodePath = NodePath(CubeGeom().loadNode())
nodePath.reparentTo(self.render)
texture = loader.loadTexture("planet.png")
nodePath.setTexture(ts, texture)
texture = loader.loadTexture("planet_normal.png")
nodePath.setTexture(tsNormal, texture)
light = DirectionalLight("Light")
light.setColor(Vec4(1, 0, 0, 1))
nodePath = self.render.attachNewNode(light)
self.light = nodePath
self.render.setLight(nodePath)
self.taskMgr.add(self.update)
self.accept("a", self.toggleLight)
def update(self, task):
self.light.setH(self.light.getH()+0.25)
return task.cont
def toggleLight(self):
if self.render.hasLight(self.light):
self.render.clearLight()
else:
self.render.setLight(self.light)
base = MyApp()
base.run()
But a black box appears when the light is on. Where is the error, or I am missing something ?
I didn’t understood the concept of “TextureStage” well, and i don’t really know how to use it with multiple objects to.
I have a second question, is that if we use in the same time vertices normal and texture normal, which one will be applies ? Will the model normal will be applies with a little modulation with the texture normal ?
Thanks