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: Thy (Tea) Tran #24

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2f9f295
near clip and far clip furstum correct
Oct 27, 2020
3cf4a57
implemented and tested subfrustum. implemented (not tested) storing l…
Oct 27, 2020
f3355be
adjusting shader
Oct 28, 2020
85661ba
fixed shader for forward +
Oct 29, 2020
2c2ee16
fixed bugs in base.js. Still slow in forward+
Oct 29, 2020
4e0dc34
fixed bugs related to calculating frustum.z
Oct 29, 2020
7b2e5c7
changed how light is updated in buffer. suspect that frustum sphere i…
Oct 29, 2020
cff4955
before re-doing updateClusters
Oct 29, 2020
b9d9e2b
slicing x and y incorrectly for forward +
Nov 1, 2020
9d4c67a
shows up but slow
Nov 2, 2020
ffb9c6f
adjusted but still slow
Nov 2, 2020
f09f9c5
added another way to do update cluster but still slower than forward
Nov 2, 2020
275d6f8
refactored base.js
Nov 3, 2020
be745e4
updated deferred to texture
Nov 3, 2020
fd15cf2
fixed updateclusters within clusterredDeferred
Nov 3, 2020
00a5452
finished deferred
Nov 3, 2020
0a5ba62
updated shaders to not use last g-buffer data
Nov 3, 2020
c867d58
try offseting/scaling uv
Nov 3, 2020
afbfd4b
packed normal, got rid of another buffer
Nov 3, 2020
d4f46b5
added recording
Nov 5, 2020
b30b74f
added graph for performance analysis
Nov 5, 2020
2b80559
added pictures and recordings
Nov 5, 2020
4a9ea89
updated link
Nov 5, 2020
6fd9dc9
update readme to include more info on optimization
Nov 5, 2020
6a61fbd
updated images
Nov 5, 2020
e9948a6
added images for deferred shading
Nov 5, 2020
924473f
added images for deferred shading
Nov 5, 2020
1a530be
added images for deferred shading
Nov 5, 2020
0d71693
added images for deferred shading
Nov 5, 2020
7e376ba
fixed images for deferred shading
Nov 5, 2020
a5f3004
fixed images for deferred shading
Nov 5, 2020
116681e
deleted problematic images
Nov 5, 2020
73957a5
fixed and added images for deferred shading
Nov 5, 2020
ea863d9
added images
Nov 5, 2020
426fbfe
added images
Nov 5, 2020
08653cc
fixed images
Nov 5, 2020
e118e8e
fixed image hanges
Nov 5, 2020
10eb0a4
resize images
Nov 5, 2020
3978b8a
resize images
Nov 5, 2020
b357619
resize images
Nov 5, 2020
2a41ee4
deleted problematic image
Nov 5, 2020
e3b5458
added cluster shader x image
Nov 5, 2020
3140e3a
deleted problematic image
Nov 5, 2020
999bc82
added cluster image
Nov 5, 2020
251dbe4
deleted problematic image
Nov 5, 2020
a5a43ef
added cluster shader x
Nov 5, 2020
ab17f2e
added pictures of effects
Nov 5, 2020
761f809
added analysis
Nov 5, 2020
640a75f
added a test option in gui Cluster - blinn phong
Nov 21, 2020
9f04900
added toon shader
Nov 22, 2020
684c853
added toon shader
Nov 22, 2020
1dea51b
change from debug mode to normal mode
Nov 22, 2020
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
packed normal, got rid of another buffer
Thy Tran (Tea) committed Nov 3, 2020
commit afbfd4b3e24ef507ac8fbd425dfc273761980d89
7 changes: 5 additions & 2 deletions src/renderers/clusteredDeferred.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import TextureBuffer from './textureBuffer';
import BaseRenderer from './base';
import { MAX_LIGHTS_PER_CLUSTER } from './base';

export const NUM_GBUFFERS = 3;
export const NUM_GBUFFERS = 2;
export const NUM_COMBINED_GBUFFERS = 1;

export default class ClusteredDeferredRenderer extends BaseRenderer {
@@ -49,7 +49,7 @@ export default class ClusteredDeferredRenderer extends BaseRenderer {
setupDrawBuffers(width, height) {
this._width = width;
this._height = height;
this._bufferwidth = width * NUM_GBUFFERS;
this._bufferwidth = width;
this._bufferheight = height;

this._fbo = gl.createFramebuffer();
@@ -99,6 +99,9 @@ export default class ClusteredDeferredRenderer extends BaseRenderer {
this._width = width;
this._height = height;

this._bufferwidth = width;
this._bufferheight = height;

gl.bindTexture(gl.TEXTURE_2D, this._depthTex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, width, height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, null);
for (let i = 0; i < NUM_GBUFFERS; i++) {
15 changes: 11 additions & 4 deletions src/shaders/deferred.frag.glsl.js
Original file line number Diff line number Diff line change
@@ -75,11 +75,18 @@ export default function(params) {

void main() {
// TODO: extract data from g buffers and do lighting
vec2 v_uvAdjusted = vec2((gl_FragCoord.x + 1.0) / (u_resolution[0] * 3.0 + 1.0), v_uv.y);
vec3 albedo = (texture2D(u_gbuffers[0], v_uvAdjusted)).xyz;
vec3 normal = (texture2D(u_gbuffers[1], v_uvAdjusted)).xyz;
vec4 gb0 = texture2D(u_gbuffers[0], v_uv);
vec4 gb1 = texture2D(u_gbuffers[1], v_uv);

vec3 albedo = (gb0).xyz;

vec3 normal = vec3(0.0);
normal.x = gb0.w;
normal.y = gb1.w;
normal.z = sqrt(1.0 - normal.x * normal.x - normal.y * normal.y);

vec4 v_positionV4 = vec4(gb1.xyz, 1.0);

vec4 v_positionV4 = texture2D(u_gbuffers[2], v_uvAdjusted);
vec3 v_position = v_positionV4.xyz;
vec3 v_positionNonNDC = (u_viewProjectionMatrix * v_positionV4).xyz;
vec3 fragColor = vec3(0.0);
10 changes: 4 additions & 6 deletions src/shaders/deferredToTexture.frag.glsl
Original file line number Diff line number Diff line change
@@ -18,12 +18,10 @@ vec3 applyNormalMap(vec3 geomnor, vec3 normap) {
}

void main() {
vec3 norm = applyNormalMap(v_normal, vec3(texture2D(u_normap, v_uv)));
vec3 norm = normalize(applyNormalMap(v_normal, vec3(texture2D(u_normap, v_uv))));
vec3 col = vec3(texture2D(u_colmap, v_uv));



// TODO: populate your g buffer
gl_FragData[0] = vec4(col, 1.0);
gl_FragData[1] = vec4(norm, 1.0);
gl_FragData[2] = vec4(v_position, 1.0);
gl_FragData[0] = vec4(col, norm.x);
gl_FragData[1] = vec4(v_position, norm.y);
}