So I tried both cases with a camera and things aren’t just going my way.
The model view projection - I guess this would be faster?
Now I’m trying to do this on a camera node instead of a light node and its giving a graphic state guardian error. Whats the deal with that?
self.projectionMatrix = base.camLens.getProjectionMat()
self.lightViewMatrix = self.model.getTransform(base.cam).getMat()
self.viewProjMatrix = self.lightViewMatrix * self.projectionMatrix
Its giving me this:
Assertion failed: lens != (Lens *)NULL at line 2850 of c:\temp\mkpr\panda3d-1.0.
5\panda\src\glstuff\glGraphicsStateGuardian_src.cxx
Traceback (most recent call last):
File "projectTexture.py", line 91, in ?
run()
File "C:\Panda3D-1.0.5\direct\src\showbase\ShowBase.py", line 1603, in run
self.taskMgr.run()
File "C:\Panda3D-1.0.5\direct\src\task\Task.py", line 781, in run
self.step()
File "C:\Panda3D-1.0.5\direct\src\task\Task.py", line 728, in step
self.__stepThroughList(taskPriList)
File "C:\Panda3D-1.0.5\direct\src\task\Task.py", line 671, in __stepThroughLis
t
ret = self.__executeTask(task)
File "C:\Panda3D-1.0.5\direct\src\task\Task.py", line 602, in __executeTask
ret = task(task)
File "C:\Panda3D-1.0.5\direct\src\showbase\ShowBase.py", line 1170, in igLoop
self.graphicsEngine.renderFrame()
File "GraphicsEngine", line 620, in renderFrame
AssertionError: lens != (Lens *)NULL at line 2850 of c:\temp\mkpr\panda3d-1.0.5\
panda\src\glstuff\glGraphicsStateGuardian_src.cxx
Whats the deal with that?
So as for projection screen method of doing that. I’m still having a bit of trouble. How do I actually get the calculated UV’s to the shader? Here’s the code:
self.lightLens = PerspectiveLens()
self.lightLensNode = LensNode('myLensNode')
self.lightLensNode.setLens(self.lightLens)
self.lightLensNodePath = render.attachNewNode(self.lightLensNode)
self.lightLensNodePath.setPos(20,20,20)
self.lightLensNodePath.lookAt(self.model)
self.ps = ProjectionScreen('ps')
self.ps.setProjector(self.lightLensNodePath)
self.ps.setTexcoordName('lensTexCoords')
self.psPath = render.attachNewNode(self.ps)
self.model.reparentTo(self.psPath)
self.spotlight.setLens(self.lightLens)
self.spotlight.setColor(Vec4(1,1,1,1))
self.snlp=render.attachNewNode("snlp")
self.snlp.attachNewNode( self.spotlight.upcastToLensNode() )
self.snlp.setPos(20,20,20)
self.snlp.lookAt(self.model)
self.lightAttrib = self.lightAttrib.addLight(self.spotlight)
render.node().setAttrib( self.lightAttrib )
self.shader=CgShader("genShader", "curTestingShaderv.cg", "curTestingShaderf.cg")
shaderAttrib=CgShaderAttrib.make(self.shader)
self.shader.addParam('lightPos', 'lightPos', CgShader.P3F, CgShader.BFRAME, 1)
self.shader.setParam('lightPos', Vec3(self.snlp.getPos()))
self.shader.addParam('modelViewProj', 'modelViewProj', CgShader.PMATRIX,CgShader.BFRAME, 1)
self.shader.setParam('modelViewProj', CgShader.MTXMODELVIEWPROJECTION, CgShader.TRFIDENTITY)
self.psPath.node().setAttrib(shaderAttrib)
In the cg shader I’m trying to access TEXCOORD0 and TEXCOORD1. TEXCOORD0 is the obvious imported UV coordinates. However TEXCOORD1 seems to be empty. Am I doing something wrong?