# lighting on Geom

using the ball from the normal mapping tutorial, and a geom wall, I was able to enable an ambient light, and a point light. but the point light does not shine on the geometry.
Any help?

``````#from pandac.PandaModules import loadPrcFileData

from direct.directbase import DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from pandac.PandaModules import *
from random import randint, random

import sys, os
import math
import random

def makeSquare(x1,y1,z1, x2,y2,z2,flip):
format=GeomVertexFormat.getV3n3cpt2()
vdata=GeomVertexData('square', format, Geom.UHDynamic)
vertex=GeomVertexWriter(vdata, 'vertex')
texcoord=GeomVertexWriter(vdata, 'texcoord')
color=GeomVertexWriter(vdata, 'color')

if x1!=x2:

else:

tri1=GeomTriangles(Geom.UHDynamic)
tri2=GeomTriangles(Geom.UHDynamic)

tri1.closePrimitive()
tri2.closePrimitive()

square=Geom(vdata)

return square

def renderwall(snode, texttype):

cube=mazenode.attachNewNode(snode)

cube.setTwoSided(True)

def drawbox(boxx,boxy):
rl=1
ll=0
nt=2
square0=makeSquare(boxx-2,boxy-2,-1, boxx,boxy-2, 1.5,ll)
square1=makeSquare(boxx-2, boxy,-1, boxx, boxy, 1.5,rl)
square2=makeSquare(boxx-2, boxy, 1.5, boxx,boxy-2, 1.5,nt)
square3=makeSquare(boxx-2, boxy,-1, boxx,boxy-2,-1,ll)
square4=makeSquare(boxx-2,boxy-2,-1, boxx-2, boxy, 1.5,rl)
square5=makeSquare(boxx,boxy-2,-1,  boxx, boxy, 1.5,ll)
snode=GeomNode('square')
renderwall(snode, 0)

def lighting():
areacolour=VBase4(0.4,0.4,0.4,0.4)

ambient = AmbientLight('ambient')
ambient.setColor(VBase4(areacolour))
ambientNP = mazenode.attachNewNode(ambient.upcastToPandaNode())
mazenode.setLight(ambientNP)

def lighting1():
sphere.reparentTo(mazenode)
sphere.setScale(0.5,0.5,0.5)
plight = PointLight('plight')
plight.setColor(VBase4(1, 0, 0, 1))
plnp = mazenode.attachNewNode(plight)
plnp.setPos(-5, -5, 0)
mazenode.setLight(plnp)

mazenode=render.attachNewNode("mazeNode")
mazenode.reparentTo(render)
def main():
drawbox(2,2)
lighting()
lighting1()
base.useDrive()
base.setBackgroundColor(0.3, 0.3, 0.3)
# base.camera.setPos(0,-4.5,0)
# base.camera.lookAt(0,0,0)
#base.camera.setHpr(-38,0,0)
main()
run()``````

My first guess is that you don’t have enough vertices on your walls. By default, the lighting calculation is done per-vertex, which means your PointLights and Spotlights have to be close enough to a vertex in order to illuminate the wall. If they’re right in the middle of the wall where there are no vertices, no lighting effects are visible.

The usual solution is to subdivide your walls into a grid of smaller polygons. You can also enable per-pixel lighting, if your graphics card supports shaders, by calling setShaderAuto(). This may be slower to render, though.

David