Skip to content

Instantly share code, notes, and snippets.

@vorg
Last active March 17, 2017 12:15
Show Gist options
  • Select an option

  • Save vorg/be1a5d626bcdce29092fcacb2e7da7d3 to your computer and use it in GitHub Desktop.

Select an option

Save vorg/be1a5d626bcdce29092fcacb2e7da7d3 to your computer and use it in GitHub Desktop.
const depthPassCmd = ctx.command({
name: 'depthPass',
framebuffer: shadowFramebuffer,
viewport: [0, 0, depthMapSize, depthMapSize],
clearColor: [1, 1, 0, 1],
clearDepth: 1
})
...
const drawFloorDepthCmd = ctx.command({
name: 'drawFloorDepth',
vert: showNormalsVert,
frag: showNormalsFrag,
uniforms: {
uProjectionMatrix: lightCamera.projectionMatrix,
uViewMatrix: lightCamera.viewMatrix,
uModelMatrix: Mat4.create()
},
vertexLayout: [
['aPosition', 0, 3],
['aNormal', 1, 3]
],
attributes: {
aPosition: { buffer: floorPositionsBuf },
aNormal: { buffer: floorNormalsBuf }
},
elements: { buffer: ctx.elementsBuffer(floor.cells) },
depthEnable: true
})
...
raf(function frame () {
updateTime()
updateCamera()
updateBunny(ctx)
ctx.debug((++frameNumber) === 1)
ctx.submit(depthPassCmd, () => {
ctx.submit(drawFloorDepthCmd)
ctx.submit(drawBunnyDepthCmd)
})
ctx.submit(clearCmd)
ctx.submit(drawFloorCmd)
ctx.submit(drawBunnyCmd)
ctx.submit(drawFullscreenQuadCmd)
raf(frame)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment