Last active
March 17, 2017 12:15
-
-
Save vorg/be1a5d626bcdce29092fcacb2e7da7d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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