From 007bc25fd5a856e459fb21a077cf8e5414236567 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sat, 6 Jan 2018 19:20:58 +0000 Subject: [PATCH] Annotate hero/code417 Also fix typos in hero/code410 --- cmuratori/hero/code/code410.hmml | 2 +- cmuratori/hero/code/code417.hmml | 82 ++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 cmuratori/hero/code/code417.hmml diff --git a/cmuratori/hero/code/code410.hmml b/cmuratori/hero/code/code410.hmml index fcc5e7c..0733813 100644 --- a/cmuratori/hero/code/code410.hmml +++ b/cmuratori/hero/code/code410.hmml @@ -17,7 +17,7 @@ [55:50][handmade_render_group.cpp: Implement ComputeLightPropagation() casting from emitters to reflectors] [1:00:42][Consider prohibiting ourselves from hitting the same reflector twice] [1:04:19][handmade_render_group.cpp: Continue to implement ComputeLightPropagation() weighting the emission contribution] -[1:14:25][handmade_render_group.cpp: Enable ExtractRelectorsFromQuads() and ExtractRelectorsFromVerts() to use our newly computed emittance] +[1:14:25][handmade_render_group.cpp: Enable ExtractReflectorsFromQuads() and ExtractReflectorsFromVerts() to use our newly computed emittance] [1:20:06][Run the game to see the trippy disco lights] [1:21:39][handmade_world_mode.cpp: Prevent AddSnakeSegment() from emitting light] [1:22:18][Run the game to see our current lighting solution with just our hero's light source] diff --git a/cmuratori/hero/code/code417.hmml b/cmuratori/hero/code/code417.hmml new file mode 100644 index 0000000..674d7f6 --- /dev/null +++ b/cmuratori/hero/code/code417.hmml @@ -0,0 +1,82 @@ +[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Adding a Debug View for Lighting Points" vod_platform=youtube id=vm3XRQI7nrs annotator=Miblo] +[0:13][Recap and set the stage for the day][:speech] +[2:26][:Run the game to see our current :lighting solution][:rendering] +[6:34][Read through ExtractReflectorsFromQuads()][:research :lighting :rendering] +[8:32][:Run the game to illustrate the need for some :"debug visualisation"][:lighting :rendering] +[10:01][Note that SampleHemisphere() is not uniform as mentioned on the forums[ref + site="Handmade Hero Forums" + page="SampleHemisphere is not uniform" + url=https://hero.handmade.network/forums/code-discussion/t/2799-samplehemisphere_is_not_uniform]][:lighting :rendering :speech] +[11:22][Remove OutputLightingQuads() and clean up :lighting structs and dependent functions][:hardware :rendering] +[19:21][Wish for the ability to fetch from a buffer in a fragment shader[ref + site="OpenGL Registry" + page="The OpenGL Shading Language 1.50 Quick Reference Card" + url=https://www.khronos.org/files/opengl-quick-reference-card.pdf][ref + site="OpenGL Wiki" + page="Shader Storage Buffer Object" + url=https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object]][:hardware :research] +[24:14][Pack lighting_textures differently, remove DecodePower() and trim down OutputLightingTextures()][:lighting :rendering] +[32:22][Propagate the new lighting_textures to the OpenGL side of things][:hardware :lighting :rendering] +[37:12][Z-Value Reconstruction][:blackboard :geometry] +[39:08][Enable CompileZBiasProgram() to reconstruct the Z-value][:hardware :lighting :rendering] +[43:05][:Run the game to see colour washes][:lighting :rendering] +[44:05][Determine to draw :lighting sample points][:"debug visualisation" :rendering :speech] +[46:19][:Run the game, try adjusting the :lighting iteration count and note our apparent power leakage problem][:rendering] +[50:06][Replace OutputLightingQuads() with OutputLightingPoints()][:lighting :rendering] +[52:59][:Run the game and try toggling between the regular view and :"debug visualisation"][:lighting :rendering] +[53:30][Enable OutputLightingPoints() to output the :lighting sample points][:"debug visualisation" :rendering] +[1:00:55][:Run the game to see our :lighting sample points][:"debug visualisation" :rendering] +[1:01:30][Try to enable UpdateAndRenderWorld() to perform the :simulation even in the :"debug visualisation"][:lighting :rendering] +[1:05:57][:Run the game to see that this doesn't quite work][:lighting :rendering :simulation] +[1:06:10][Revert our :simulation update attempt][:lighting :rendering] +[1:07:29][:Run the game to see our :lighting sample points][:"debug visualisation" :rendering] +[1:09:43][Read through ComputeLightPropagation()][:lighting :rendering :research] +[1:12:47][Make RayCast() account for the Source Position in the Position computation][:lighting :rendering] +[1:13:55][:Run the game to see that it looks much more correct][:lighting :rendering] +[1:15:47][Temporarily increase the RayCount in ComputeLightPropagation()][:lighting :rendering] +[1:16:01][:Run the game to see the :lighting solution with more rays[:rendering]] +[1:17:05][Determine to make the light sampling more unbiased][:lighting :rendering :speech] +[1:18:58][:Run the game and determine to enable :lighting recomputation while showing the :"debug visualisation"][:"debug system" :rendering] +[1:19:34][Enable UpdateAndRenderWorld() to recompute the :lighting while showing the :"debug visualisation"][:"debug system" :rendering] +[1:20:18][:Run the game and try out our new ability][:"debug visualisation" :lighting :rendering] +[1:20:41][Increase sample point size in OutputLightingPoints()][:"debug visualisation" :lighting :rendering] +[1:21:01][:Run the game to see our bigger sample points][:"debug visualisation" :lighting :rendering] +[1:22:06][Toggle off the snake in PlayWorld()][:"entity system"] +[1:22:29][:Run the game to see our current :lighting solution][:"debug visualisation" :rendering] +[1:23:06][Consider how to get the :lighting bounce to work better][:rendering :speech] +[1:25:13]["Energy Conservation"][:blackboard :lighting :rendering] +[1:28:33][Introduce the notion of LightRetention in ComputeLightPropagation() to only retain 50% of the light][:lighting :rendering] +[1:31:31][:Run the game to see that the light gets dimmer and dimmer][:lighting :rendering] +[1:32:14][Enable ComputeLightPropagation() to retain light if rays do not hit][:lighting :rendering] +[1:34:57][:Run the game to see that the light still gets dimmer][:lighting :rendering] +[1:36:10][Read through ComputeLightPropagation()][:lighting :rendering :research] +[1:37:17][][:speech][quote 607] +[1:37:29][Change AccumulateSample() to return the Power for ComputeLightPropagation() to use][:lighting :rendering] +[1:38:29][:Run the game to see that it's better but still not right] +[1:38:51][Read closely through ComputeLightPropagation() to try and see where we lose power][:lighting :rendering :research] +[1:40:28][Make ComputeLightPropagation() compute the DestEmitC from the SourceEmitC][:lighting :rendering] +[1:40:49][:Run the game to see that we are so close][:lighting :rendering] +[1:41:31][Thoroughly consider how to correctly retain light][:lighting :rendering :research] +[1:44:54][Describe the problem][:lighting :rendering :speech] +[1:45:33][Introduce the notion of a retention coefficient in ComputeLightPropagation()] +[1:46:41][:Run the game to see that it still gets down to zero eventually][:lighting :rendering] +[1:47:00][Make AccumulateSample() return the full colour for ComputeLightPropagation() to use as the retainer][:lighting :rendering] +[1:49:01][:Run the game to see that we're still losing power][:lighting :rendering] +[1:49:37][Read through ComputeLightPropagation() one last time][:lighting :rendering :research] +[1:50:32][:Run the game and look at our :lighting samples][:"debug visualisation" :rendering] +[1:52:39][Q&A] +[1:53:41][@pseudonym73][@cmuratori Am I right in thinking that you're taking into account the geometric (cos theta) factor on the receiving surface, but not on the emitting surface?][:lighting :rendering] +[1:53:55][@groggeh][Q: In a trade like blacksmithing, you use your tools to make better tools over time. Do you think programming should be like this, where you build tools that you reuse every project? Or should you rebuild most of your code every project?] +[1:56:48][@pseudonym73][Q: That may explain why it wasn't energy preserving][:lighting :rendering] +[1:57:19][@m0re85][Q: Could you explain the purpose of multiple pointer levels like void *****whatever? Is it just an array of array of array of array... I can't think of a viable example, can you give one?][:language] +[1:58:01][@mtsmox][Q: Is the direction of the light correctly recalculated if you only take positive z into account, negative z is also a correct normal, right?][:lighting :rendering] +[1:58:48][Make OutputLightTextures() and CompileZBiasProgram() correctly recalculate the light for both positive and negative Z values][:hardware :lighting :rendering] +[2:01:00][:Run the game to see the :lighting solution][:rendering] +[2:01:29][@longboolean][Q: In the case of the red wall only being lit by the 3rd or 4th bounce, shouldn't the red wall not reflect any red light because the blue wall is mostly only reflecting blue light?][:lighting :rendering] +[2:02:26][@pseudonym73][Q: Yeah, but think back. The original problem was that the solution was blowing up, wasn't it?][:lighting :rendering] +[2:03:26][@m0re85][Q: void ** is clear, everything above is bogus][:language] +[2:03:40][Pointers to Pointers][:blackboard :language] +[2:05:59][@pseudonym73][Q: Just as a suggestion, the ultimate solution might be to use temporal coherence. Do one bounce per frame, and use the previous frame's solution for the indirect :lighting term][:rendering] +[2:07:01][@darkenderio][Q: Two weeks ago I asked about sound input. I just want to specify that I was thinking about the data structure to store the sound input. So like you have it setup with the :"platform layer" handling the sound input and passing it to the game][:audio] +[2:07:51][Shut it down][:speech] +[/video]