Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project 5: Ishan Ranade #6

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
weird artifact
IshanRanade committed Oct 26, 2018
commit e76ecee84af71dd9aa47834204003ee5c11be82e
4 changes: 2 additions & 2 deletions src/renderers/base.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { Vector3 } from "three"
import { vec3, vec4, mat4 } from "gl-matrix"


export const MAX_LIGHTS_PER_CLUSTER = 100;
export const MAX_LIGHTS_PER_CLUSTER = 500;


export default class BaseRenderer {
@@ -57,7 +57,7 @@ export default class BaseRenderer {
if (c < MAX_LIGHTS_PER_CLUSTER)
{
this._clusterTexture.buffer[countIndex] = c;
let nextLightIndex = this._clusterTexture.bufferIndex(i, c / 4) + (c % 4);
let nextLightIndex = this._clusterTexture.bufferIndex(i, Math.floor(c / 4)) + (c % 4);
this._clusterTexture.buffer[nextLightIndex] = lightIndex;
}
}
2 changes: 1 addition & 1 deletion src/scene.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ export const LIGHT_RADIUS = 5.0;
export const LIGHT_DT = -0.03;

// TODO: This controls the number of lights
export const NUM_LIGHTS = 100;
export const NUM_LIGHTS = 500;

class Scene {
constructor() {
16 changes: 3 additions & 13 deletions src/shaders/forwardPlus.frag.glsl.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ export default function(params) {
uniform sampler2D u_colmap;
uniform sampler2D u_normap;
uniform sampler2D u_lightbuffer;
uniform sampler2D u_clusterBuffer;

uniform float u_farClip;
uniform float u_nearClip;
@@ -104,16 +103,15 @@ export default function(params) {

// Get the count from the clusterBuffer of this element index
int colIndex = cellX + cellY * int(u_xSlices) + cellZ * int(u_xSlices) * int(u_ySlices);
int numLights = int(ExtractFloat(u_clusterBuffer, ${params.clusterTextureWidth}, int(${params.clusterTextureHeight}), colIndex, 0));

int numLights = int(ExtractFloat(u_clusterbuffer, ${params.clusterTextureWidth}, int(${params.clusterTextureHeight}), colIndex, 0));

// For loop range of count extracting one light at a time
for (int i = 1; i < int(${params.clusterTextureHeight}) * 4 - 1; ++i) {
if(i > numLights) {
if(i >= numLights) {
break;
}

int lightIndex = int(ExtractFloat(u_clusterBuffer, ${params.clusterTextureWidth}, int(${params.clusterTextureHeight}), colIndex, i));
int lightIndex = int(ExtractFloat(u_clusterbuffer, ${params.clusterTextureWidth}, int(${params.clusterTextureHeight}), colIndex, i));

Light light = UnpackLight(i);
float lightDistance = distance(light.position, v_position);
@@ -129,14 +127,6 @@ export default function(params) {
fragColor += albedo * ambientLight;

gl_FragColor = vec4(fragColor, 1.0);

//gl_FragColor = vec4(colIndex, colIndex, colIndex, 1.0);
//gl_FragColor = vec4(abs(v_viewPosition.z) / (300.0 - u_nearClip), abs(v_viewPosition.z) / (300.0 - u_nearClip), abs(v_viewPosition.z) / (300.0 - u_nearClip), 1.0);
//gl_FragColor = vec4(-1.0,-1.0,-1.0,1.0);
//gl_FragColor = vec4(abs(v_viewPosition), 1.0);
gl_FragColor = vec4(numLights, numLights, numLights, 1.0);
//float cellCount = u_xSlices * u_ySlices * 2.0;
//gl_FragColor = vec4(float(colIndex) / cellCount, float(colIndex) / cellCount, float(colIndex) / cellCount, 1.0);
}
`;
}