Skip to content

Commit

Permalink
Tweak scene
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Feb 13, 2024
1 parent 75efeae commit 1c814ff
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions deferred.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

const { mat4, vec3 } = glMatrix;
const NUM_BOXES = 256;
const NUM_LIGHTS = 256;
const NUM_LIGHTS = 64;

checkSupport();
addDescription(
Expand Down Expand Up @@ -314,19 +314,19 @@
const lights = {
data: new Array(NUM_LIGHTS).fill(null).map(() => ({
position: [
randomRange(-4, 4),
randomRange(-4, 4),
randomRange(-4, 1)
randomRange(-3, 3),
randomRange(-3, 3),
randomRange(-2.5, 0.5)
],
color: [
randomRange(0, 1),
randomRange(0, 1),
randomRange(0, 1)
],
offset: [
randomRange(-1, 1),
randomRange(-1, 1),
randomRange(-1, 1)
randomRange(-0.5, 0.5),
randomRange(-0.5, 0.5),
randomRange(-0.5, 0.5)
],
t: randomRange(0, 2 * Math.PI),
})),
Expand Down Expand Up @@ -508,7 +508,7 @@
const translate = [
randomRange(-3, 3),
randomRange(-3, 3),
randomRange(-4, 0)
randomRange(-3, 0)
];
const rotate = [
randomRange(0, 2 * Math.PI),
Expand Down Expand Up @@ -585,7 +585,7 @@
return position;
}
const lightDampening = 0.08;
const lightDampening = 0.3;
@group(0) @binding(0) var<uniform> eyePosition: vec4f;
@group(0) @binding(1) var<uniform> lightPositions: array<vec4f, ${NUM_LIGHTS}>;
Expand Down Expand Up @@ -871,8 +871,8 @@
///////////////////////////

for (const box of boxes) {
box.rotate[0] += 0.0001 * dt;
box.rotate[1] += 0.0002 * dt;
box.rotate[0] += 0.0003 * dt;
box.rotate[1] += 0.0004 * dt;

xformMatrix(box.modelMatrix, box.translate, box.rotate, box.scale);

Expand All @@ -885,7 +885,7 @@
///////////////////////////

lights.data.forEach((light, i) => {
light.t = (light.t + 0.0004 * dt) % (2 * Math.PI);
light.t = (light.t + 0.0006 * dt) % (2 * Math.PI);
const position = lights.positionData.subarray(i * 4, i * 4 + 3);
vec3.scale(position, light.offset, Math.sin(light.t));
vec3.add(position, light.position, position);
Expand Down

0 comments on commit 1c814ff

Please sign in to comment.