Skip to content

Commit

Permalink
Show how to disable shadow map updates in shadow samples
Browse files Browse the repository at this point in the history
  • Loading branch information
rdb committed Aug 27, 2016
1 parent 20353f3 commit 40ff32c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
19 changes: 9 additions & 10 deletions samples/shadows/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self):
props, winprops,
GraphicsPipe.BFRefuseWindow,
base.win.getGsg(), base.win)
self.buffer = LBuffer

if not LBuffer:
self.t = addTitle(
Expand All @@ -73,9 +74,10 @@ def __init__(self):
self.inst_w = addInstructions(0.12, 'W : stop/start the Walk Cycle')
self.inst_t = addInstructions(0.18, 'T : stop/start the Teapot')
self.inst_l = addInstructions(0.24, 'L : move light source far or close')
self.inst_v = addInstructions(0.30, 'V: View the Depth-Texture results')
self.inst_x = addInstructions(0.36, 'Left/Right Arrow : switch camera angles')
self.inst_a = addInstructions(0.42, 'Something about A/Z and push bias')
self.inst_v = addInstructions(0.30, 'V : View the Depth-Texture results')
self.inst_u = addInstructions(0.36, 'U : toggle updating the shadow map')
self.inst_x = addInstructions(0.42, 'Left/Right Arrow : switch camera angles')
self.inst_a = addInstructions(0.48, 'Something about A/Z and push bias')

base.setBackgroundColor(0, 0, 0.2, 1)

Expand Down Expand Up @@ -120,20 +122,14 @@ def __init__(self):
self.accept("arrow_left", self.incrementCameraPosition, [-1])
self.accept("arrow_right", self.incrementCameraPosition, [1])
self.accept("p", self.toggleInterval, [self.pandaMovement])
self.accept("P", self.toggleInterval, [self.pandaMovement])
self.accept("t", self.toggleInterval, [self.teapotMovement])
self.accept("T", self.toggleInterval, [self.teapotMovement])
self.accept("w", self.toggleInterval, [self.pandaWalk])
self.accept("W", self.toggleInterval, [self.pandaWalk])
self.accept("v", base.bufferViewer.toggleEnable)
self.accept("V", base.bufferViewer.toggleEnable)
self.accept("u", self.toggleUpdateShadowMap)
self.accept("l", self.incrementLightPosition, [1])
self.accept("L", self.incrementLightPosition, [1])
self.accept("o", base.oobe)
self.accept('a', self.adjustPushBias, [1.1])
self.accept('A', self.adjustPushBias, [1.1])
self.accept('z', self.adjustPushBias, [0.9])
self.accept('Z', self.adjustPushBias, [0.9])

self.LCam = base.makeCamera(LBuffer)
self.LCam.node().setScene(render)
Expand Down Expand Up @@ -180,6 +176,9 @@ def toggleInterval(self, ival):
else:
ival.resume()

def toggleUpdateShadowMap(self):
self.buffer.active = not self.buffer.active

def incrementCameraPosition(self, n):
self.cameraSelection = (self.cameraSelection + n) % 6
if (self.cameraSelection == 0):
Expand Down
15 changes: 8 additions & 7 deletions samples/shadows/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def __init__(self):
self.inst_w = addInstructions(0.12, 'W : stop/start the Walk Cycle')
self.inst_t = addInstructions(0.18, 'T : stop/start the Teapot')
self.inst_l = addInstructions(0.24, 'L : move light source far or close')
self.inst_v = addInstructions(0.30, 'V: View the Depth-Texture results')
self.inst_x = addInstructions(0.36, 'Left/Right Arrow : switch camera angles')
self.inst_v = addInstructions(0.30, 'V : View the Depth-Texture results')
self.inst_u = addInstructions(0.36, 'U : toggle updating the shadow map')
self.inst_x = addInstructions(0.42, 'Left/Right Arrow : switch camera angles')

base.setBackgroundColor(0, 0, 0.2, 1)

Expand Down Expand Up @@ -88,15 +89,11 @@ def __init__(self):
self.accept("arrow_left", self.incrementCameraPosition, [-1])
self.accept("arrow_right", self.incrementCameraPosition, [1])
self.accept("p", self.toggleInterval, [self.pandaMovement])
self.accept("P", self.toggleInterval, [self.pandaMovement])
self.accept("t", self.toggleInterval, [self.teapotMovement])
self.accept("T", self.toggleInterval, [self.teapotMovement])
self.accept("w", self.toggleInterval, [self.pandaWalk])
self.accept("W", self.toggleInterval, [self.pandaWalk])
self.accept("v", base.bufferViewer.toggleEnable)
self.accept("V", base.bufferViewer.toggleEnable)
self.accept("u", self.toggleUpdateShadowMap)
self.accept("l", self.incrementLightPosition, [1])
self.accept("L", self.incrementLightPosition, [1])
self.accept("o", base.oobe)

self.light = render.attachNewNode(Spotlight("Spot"))
Expand Down Expand Up @@ -127,6 +124,10 @@ def toggleInterval(self, ival):
else:
ival.resume()

def toggleUpdateShadowMap(self):
buffer = self.light.node().getShadowBuffer(base.win.gsg)
buffer.active = not buffer.active

def incrementCameraPosition(self, n):
self.cameraSelection = (self.cameraSelection + n) % 6
if (self.cameraSelection == 0):
Expand Down

0 comments on commit 40ff32c

Please sign in to comment.