I´m getting a bad result when I make a shadow map for my scene, i´ve tried everything and searched what can this problem cause by, but i don´t found anything about it.
my code is this:
from direct.showbase.ShowBase import ShowBase
from direct.showbase.ShowBaseGlobal import globalClock
from panda3d.core import *
from panda3d.bullet import BulletWorld
from win32api import GetSystemMetrics
class World(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Deshabilitar caché
cache = BamCache.get_global_ptr()
cache.set_active(False)
# Color fondo
self.setBackgroundColor(0.553, 0.906, 0.922, 1.0)
# Configuración física
self.world = BulletWorld()
self.world.setGravity(Vec3(0, 0, -9.8))
# Configuración de la pantalla
wp = WindowProperties()
wp.setSize(800, 600)
#wp.setFullscreen(True)
self.win.requestProperties(wp)
# Cargar nivel
level = self.loader.loadModel('models/level_1.glb')
level.setPos(0, 0, 0)
level.setScale(0.5)
level.setTag('at', str(0))
level.reparentTo(self.render)
# Crear modelos
for i in range(0, 10):
model = self.loader.loadModel('models/SSphere.glb')
model.setPos(0, 0, i)
model.setScale(0.5)
model.setTag('at', str(i))
model.reparentTo(self.render)
# Luz direccional (sol)
self.d_light = DirectionalLight('sun')
self.d_light.setColor((1, 1, 0.9, 1)) # Luz cálida como el sol
self.d_light.getLens().setFilmSize(50, 50)
self.d_light.getLens().setNearFar(1, 100)
self.d_light.setShadowCaster(True, 4096, 4096)
self.render.setShaderAuto()
self.dl_node = self.render.attachNewNode(self.d_light)
self.dl_node.setHpr(0, -45, 0) # Ángulo inclinado
self.dl_node.setPos(0, -10, 10)
self.render.setLight(self.dl_node)
# Luz ambiental
self.a_light = AmbientLight('ambientLight')
self.a_light.setColor((0.2, 0.2, 0.2, 1))
self.al_node = self.render.attachNewNode(self.a_light)
self.render.setLight(self.al_node)
# Tarea de actualización
self.taskMgr.add(self.update, 'UpdateWorld')
def update(self, task):
dt = globalClock.getDt()
self.world.doPhysics(dt)
return task.cont
This is the result with de shadow mapping:
And when i dont make the shadows that lines doesn´t exists.