Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: samples/o3d-webgl-samples/shadow-map.html

Issue 2718003: Adding wireframe to the shadow map demo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | samples/o3d-webgl/effect.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright 2009, Google Inc. 2 Copyright 2009, Google Inc.
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are 6 modification, are permitted provided that the following conditions are
7 met: 7 met:
8 8
9 * Redistributions of source code must retain the above copyright 9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer. 10 notice, this list of conditions and the following disclaimer.
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 function initMaterials() { 237 function initMaterials() {
238 var colorVertexShader = document.getElementById('colorVertexShader').text; 238 var colorVertexShader = document.getElementById('colorVertexShader').text;
239 var colorPixelShader = document.getElementById('colorPixelShader').text; 239 var colorPixelShader = document.getElementById('colorPixelShader').text;
240 240
241 g_colorEffect = g_pack.createObject('Effect'); 241 g_colorEffect = g_pack.createObject('Effect');
242 g_colorEffect.loadVertexShaderFromString(colorVertexShader); 242 g_colorEffect.loadVertexShaderFromString(colorVertexShader);
243 g_colorEffect.loadPixelShaderFromString(colorPixelShader); 243 g_colorEffect.loadPixelShaderFromString(colorPixelShader);
244 244
245 var shadowVertexShader = document.getElementById('shadowVertexShader').text; 245 var shadowVertexShader = document.getElementById('shadowVertexShader').text;
246 var shadowPixelShader = document.getElementById('shadowPixelShader').text; 246 var shadowPixelShader = document.getElementById('shadowPixelShader').text;
247 247
248 g_shadowMaterial = g_pack.createObject('Material'); 248 g_shadowMaterial = g_pack.createObject('Material');
249 g_shadowMaterial.drawList = g_shadowViewInfo.performanceDrawList; 249 g_shadowMaterial.drawList = g_shadowViewInfo.performanceDrawList;
250 250
251 var shadowEffect = g_pack.createObject('Effect'); 251 var shadowEffect = g_pack.createObject('Effect');
252 shadowEffect.loadVertexShaderFromString(shadowVertexShader); 252 shadowEffect.loadVertexShaderFromString(shadowVertexShader);
253 shadowEffect.loadPixelShaderFromString(shadowPixelShader); 253 shadowEffect.loadPixelShaderFromString(shadowPixelShader);
254 254
255 g_shadowMaterial.effect = shadowEffect; 255 g_shadowMaterial.effect = shadowEffect;
256 shadowEffect.createUniformParameters(g_shadowMaterial); 256 shadowEffect.createUniformParameters(g_shadowMaterial);
257 257
258 g_shadowSampler = g_pack.createObject('Sampler'); 258 g_shadowSampler = g_pack.createObject('Sampler');
259 g_shadowSampler.texture = g_shadowTexture; 259 g_shadowSampler.texture = g_shadowTexture;
260 g_shadowSampler.minFilter = g_o3d.Sampler.POINT; 260 g_shadowSampler.minFilter = g_o3d.Sampler.POINT;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 } 376 }
377 377
378 378
379 /** 379 /**
380 * Creates the wireframe frustum showing the shadow map's render volume. 380 * Creates the wireframe frustum showing the shadow map's render volume.
381 */ 381 */
382 function createLightShape() { 382 function createLightShape() {
383 var inverseMatrix = g_math.matrix4.inverse(g_lightViewProjection); 383 var inverseMatrix = g_math.matrix4.inverse(g_lightViewProjection);
384 384
385 /*
386 // Scale and translate a cube of side length 2 to get a box 385 // Scale and translate a cube of side length 2 to get a box
387 // that extends from [-1, -1, 0] to [1, 1, 1]. 386 // that extends from [-1, -1, 0] to [1, 1, 1].
388 var shape = o3djs.debug.createLineCube( 387 var shape = o3djs.lineprimitives.createLineCube(
389 g_pack, 388 g_pack,
390 o3djs.material.createConstantMaterial(g_pack, 389 o3djs.material.createConstantMaterial(g_pack,
391 g_colorViewInfo, 390 g_colorViewInfo,
392 [1, 0, 0, 1]), 391 [1, 0, 0, 1]),
393 2, 392 2,
394 g_math.matrix4.compose( 393 g_math.matrix4.compose(
395 g_math.matrix4.translation([0, 0, 0.5]), 394 g_math.matrix4.translation([0, 0, 0.5]),
396 g_math.matrix4.scaling([1, 1, 0.5])));*/ 395 g_math.matrix4.scaling([1, 1, 0.5])));
397 396
398 g_lightFrustumTransform = g_pack.createObject('Transform'); 397 g_lightFrustumTransform = g_pack.createObject('Transform');
399 g_lightFrustumTransform.localMatrix = inverseMatrix; 398 g_lightFrustumTransform.localMatrix = inverseMatrix;
400 g_lightFrustumTransform.parent = g_client.root; 399 g_lightFrustumTransform.parent = g_client.root;
401 //g_lightFrustumTransform.addShape(shape); 400 g_lightFrustumTransform.addShape(shape);
402 } 401 }
403 402
404 403
405 /** 404 /**
406 * Creates a Phong-shaded, shadowed material based on the given color. 405 * Creates a Phong-shaded, shadowed material based on the given color.
407 */ 406 */
408 function createColorMaterial(baseColor) { 407 function createColorMaterial(baseColor) {
409 var material = g_pack.createObject('Material'); 408 var material = g_pack.createObject('Material');
410 material.drawList = g_colorViewInfo.performanceDrawList; 409 material.drawList = g_colorViewInfo.performanceDrawList;
411 410
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 <h1>Shadow Maps</h1> 622 <h1>Shadow Maps</h1>
624 This sample implements a basic shadow map. 623 This sample implements a basic shadow map.
625 <br/> 624 <br/>
626 <!-- Start of O3D plugin --> 625 <!-- Start of O3D plugin -->
627 <div id="o3d" style="width: 800px; height: 600px;"></div> 626 <div id="o3d" style="width: 800px; height: 600px;"></div>
628 <!-- End of O3D plugin --> 627 <!-- End of O3D plugin -->
629 Use A, S, D, W, I and O to move the light. 628 Use A, S, D, W, I and O to move the light.
630 Press spacebar to see the shadow map. 629 Press spacebar to see the shadow map.
631 </body> 630 </body>
632 </html> 631 </html>
OLDNEW
« no previous file with comments | « no previous file | samples/o3d-webgl/effect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698