Changing Spotlight image and some GUI questions

Hey guys.

I wanted to change the image of Spotlight today and I couldn’t find any information about doing that on the manual, except “makeSpot” function, but I’m not sure if that has something to do with Spotlight image. Anyway, is it possible to change it and if so, how can I do that?

And another question.

This function creates a frame, a button, parents button to frame and shows everything. So far, so good, expect that it’s not full screen. If I parent self.Frame to render2d, everything is in full screen, just how I want it, but I cannot click on the button anymore.

So my question would be: How to make my button clickable, when directframe is in full screen? Or parenting it to render2d is a bad idea?

  def initMenu(self):

    self.Frame = DirectFrame(frameSize=(-1, 1, -1, 1), frameTexture = "Marble.jpg")
    Maps = loader.loadModel('Buttons/button.egg')
    Button = DirectButton(parent=self.Frame, geom = (maps.find('**/BQuitN'), maps.find('**/BQuitC'), maps.find('**/BQuitU'), maps.find('**/BQuitD')), command=sys.exit)


I don’t understand what you mean by the Spotlight “image”. If you mean the shape of the lighted area, you can’t change it other than through the normal methods of the Spotlight class, which change its field of view or make it softer or harder.

A DirectButton must be parented somewhere under a PGTop node to be clickable. As it happens, render2d is not a PGTop node, but aspect2d is. If you want a DirectButton that fills the entire window, you could contrive to make render2d a PGTop node, but it’s probably easier just to parent it to aspect2d and set its size to compensate. There are members stored on the base instance that give you the appropriate values for this. For instance:

self.Frame = DirectFrame(frameSize=(base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), frameTexture = "Marble.jpg") 


Thanks for the reply David.

By Spotlight image I mean the texture. I think the default one looks something like this :

And I was wondering if I could make the Spotlight look something like this :

But I guess this isn’t possible?

Still not sure what texture you’re referring to. A “Spotlight” object in Panda doesn’t have a texture; it’s just a light that illuminates vertices. However, some people do use a projected texture in conjunction with a Spotlight, to achieve a very smooth projected spot. In that case you can use whatever texture you like.

There might also be some shader-based approaches that use a projected texture in a similar way. Again, that’s up to you to implement; and of course you can use whatever texture you like.


I’ve been trying to achieve flashlight effect here and I just wanted to apply a texture to my Spotlight. I really don’t know how else to explain. I doubt that I could even explain it in my native language… well, I think that Projected Textures is the solution. I’ll have to figure out how to use it, thanks for your help.

EDIT - I’ve looked up in the manual about Projected Textures and I took the example code and merged it with my flashlight code, now whole thing looks like this :

FlashlightNode = NodePath( 'Flashlight Node' )
FlashlightNode.reparentTo( camera )
FlashlightNode.setPos( 1 , 0 , 0.5 )

FlashlightLens = PerspectiveLens()
FlashlightLens.setFov( 90 )
Flashlight = Spotlight( 'Flashlight' )
Flashlight.setCameraMask( BitMask32.bit( 1 ) )
Flashlight.setLens( FlashlightLens )

Color = 0.12

Flashlight.setColor( VBase4 ( Color , Color , Color , 1 ) )
Flashlight.setExponent( 50 )

FlashlightNodePath = FlashlightNode.attachNewNode( Flashlight )

proj = render.attachNewNode( LensNode ( 'proj' ) )
proj.node().setLens( FlashlightLens )

proj.reparentTo( FlashlightNode )

tex = loader.loadTexture( 'Data/Materials/Lights/Flashlight.png' )
ts = TextureStage('ts')

render.projectTexture(ts, tex, proj)

And I’m suffering heavy lags. ~5 FPS Is there something I’m doing wrong?

EDIT 2 - I realized that the problem is with “render.setShaderAuto( True )”. If I have it off, then I have no lags at all. Is there any solution?