ive been trying for about 4 hours to get shadows to work
with no luck. idk if its the type of light im using or something else. If i could get a reallly basic example of shadows or maybe some help with my code i woukd be grateful :smiley:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import WindowProperties 
import sys

class Main(object):
	def __init__(self):
		base.disableMouse() # disables the default mouse camera controls
		base.accept( "escape" , sys.exit) # quits when escape is pressed
		self.loadPlayer = Player() # Calls up the Player() class
		self.addlight() # load the light
	def addlight(self): #create the light
		#create a directional light to give a sense of 3d ness
		dlight = DirectionalLight('dlight')
		dlight.setColor(VBase4(0.8, 0.8, 0.8, 1))
		dlnp = render.attachNewNode(dlight)
		dlnp.setHpr(0, -60, 0)
	def addWinProps(self):#defines the windows properties aka title and hide cursor etc
		props = WindowProperties()
		props.setTitle('Space Fighter')
class Player(object): # controls the Player
	speed = 250 # controls the speed of the ship
	FORWARD = Vec3(0, 2, 0) # sets direction and speed of forward direction
	STOP = Vec3(0, 0, 0)# sets the speed and direction of stop
	walk = STOP # makes walk = stop
	def __init__(self):
		self.loadShip() #calls up the function to load the ship
		taskMgr.add(self.updatePos, 'update position')
		taskMgr.add(self.mouseUpdate, 'update mouse')
	def loadShip(self): # just loads the ship model
		self.ship = loader.loadModel('ship')
	def loadWorld(self): # loads world = loader.loadModel('level'), 30, 3)
	def setCamera(self): # sets the camera lense
		place =
	def mouseUpdate(self,task): # updates the mouse and changes ships P and H accordingly
		md =
		x = md.getX()
		y = md.getY()
			self.ship.setP(self.ship.getP() -  (y -*0.1)
			self.ship.setH(self.ship.getH() - (x -*0.1)
		return task.cont
	def createControls(self): # changes the value of walk to either STOP or Forward depending on the keypress
		base.accept( "w" , self.__setattr__,["walk",self.FORWARD])
		base.accept( "w-up" , self.__setattr__,["walk",self.STOP] )

	def updatePos(self,task): # task to move the ship and camera
		return task.cont

Try with spotlight, it’s easier.

Yes, the builtin shadows are only good with spotlights. But scenes that use spotlights arent much as well.

Youre gonna have to use a custom shader if you want shadows with other types of lights. But then you basically break the whole shader generator.

Proper shadows is something I think Panda3d is really lacking.

Thanks :slight_smile: I’ll try a spotlight and see what happens. If it doesnt turn out well looks like I’ll have to go with custom shaders :confused: