From 0a509f38852eec16f6c7d12a7108131a6e1b2069 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Mon, 1 Jun 2020 19:37:43 +0100 Subject: [PATCH] Index hero/code606 --- cmuratori/hero/code/code606.hmml | 101 +++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 cmuratori/hero/code/code606.hmml diff --git a/cmuratori/hero/code/code606.hmml b/cmuratori/hero/code/code606.hmml new file mode 100644 index 0000000..9c1d16c --- /dev/null +++ b/cmuratori/hero/code/code606.hmml @@ -0,0 +1,101 @@ +[video output=day606 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Debugging Grid Raycasting with Visualizations" vod_platform=youtube id=mIE2VDut6fg annotator=Miblo] +[0:01][Recap and set the stage for the day with a few words on indirect :lighting][:speech] +[2:05][Demo the old AABB ray cast :lighting][:run] +[2:56][Toggle on LIGHTING_USE_GRID and fix compile errors][:lighting] +[3:27][Demo the new, unfinished grid ray cast :lighting][:run] +[4:56][Grid ray casting: 1) Spatial partitioning][:lighting :run] +[5:35][Grid ray casting: 2) Walk table, which tells you which grid squares to sample][:lighting :run] +[5:58][Grid ray casting: 3) The ray cast routine itself][:lighting :run] +[6:25][Grid ray casting: 1a) :SIMD packing of the AABB units][:lighting :run] +[7:23][Determine to debug the spatial partitioning using visualisation, with a few words on unit testing][:"debug visualisation" :lighting :speech] +[14:08][Make GridRayCast() draw the rays from one grid location, introducing DimIndexFrom()][:"debug visualisation" :lighting] +[22:29][Introduce a version of PushDebugBox() that takes a rectangle3][:"debug visualisation"] +[23:03][Hunt the scene for the debug box][:"debug visualisation" :lighting :run] +[23:16][Change GridRayCast() to draw the rays from grid location 200][:"debug visualisation" :lighting] +[23:55][Hunt the scene for the newly located debug box][:"debug visualisation" :lighting :run] +[24:25][Try unsuccessfully to break on our PushDebugBox() call in GridRayCast(), and find an InitialGridIndex of 4677][:"debug visualisation" :lighting :run] +[25:25][Change GridRayCast() to draw the rays from grid location 4677][:"debug visualisation" :lighting] +[25:39][Break on our PushDebugBox() call in GridRayCast()][:"debug visualisation" :lighting :run] +[26:06][Note that PushDebugLine() is not thread-safe, which is fine for the grid ray caster][:lighting :research] +[27:08][Check out the debug box][:"debug visualisation" :lighting :run] +[27:55][Make GridRayCast() draw the ray origin, hit and synthetic destination locations][:"debug visualisation" :lighting] +[31:47][Check out the rays cast from our 4677 grid location, to see that we are not casting spherically][:"debug visualisation" :lighting :run] +[33:27][Scour OutputSphereINL() for bugs][:lighting :research] +[36:21][Note the area untouched by the ray cast][:"debug visualisation" :lighting :run] +[36:41][Consider there to be something wrong other than the SampleDirectionTable values][:lighting :research] +[37:08][Note the black colouration of the rays, themselves lit by the :lighting system][:"debug visualisation" :run] +[38:46][Scour FullCast() for :sampling bugs][:lighting :research] +[40:26][Fix FullCast() to stride through the SampleDirectionTable in fours][:lighting :sampling] +[40:37][Admire our more spherical ray distribution][:"debug visualisation" :lighting :run] +[41:28][Note that our rays never hit anything][:"debug visualisation" :lighting :run] +[42:05][May GridRayCast() limit the drawing of rays to those pointing upwards][:"debug visualisation" :lighting] +[43:50][Admire our upward pointing rays][:"debug visualisation" :lighting :run] +[44:22][Make GridRayCast() draw the boxes visited by our rays][:"debug visualisation" :lighting] +[45:03][See no boxes visited by our rays][:"debug visualisation" :lighting :run] +[46:03][Make GridRayCast() shrink the ray origin box][:"debug visualisation" :lighting] +[46:34][See both the origin box and the initial walk box][:"debug visualisation" :lighting :run] +[47:05][Note that GridRayCast() terminates prematurely][:lighting :research] +[47:55][Step in to GridRayCast()][:"debug visualisation" :lighting :run :threading] +[48:21][Disable multithreading of the :lighting][:threading] +[49:00][Wonder why a second thread apparently hit the RayDebugging branch][:"debug visualisation" :lighting :run :threading] +[50:09][Step through GridRayCast()][:"debug visualisation" :lighting :run :threading] +[50:44][Fix the CostMetric test in GridRayCast() to let it actually proceed through the walk][:lighting] +[51:09][Step through GridRayCast()][:"debug visualisation" :lighting :run :threading] +[51:26][Switch to -O2 and re-enable multithreading of the :lighting][:threading] +[51:49][See that the ray cast is walking through the grid in the wrong direction][:"debug visualisation" :lighting :run] +[52:48][Scour ComputeWalkTable() for a sign bug][:lighting :research] +[56:02][Fix ComputeWalkTable() to recentre the test At location within the cell as it proceeds][:lighting] +[57:29][See that the ray cast continues to walk in the wrong direction][:"debug visualisation" :lighting :run] +[57:53][Continue to scour ComputeWalkTable() for a sign bug][:lighting :research] +[59:20][Follow the WalkTable through GridRayCast()][:lighting :research] +[1:01:00][Switch to -Od and disable multithreading of the :lighting][:threading] +[1:01:58][Step in to GridRayCast() to find a WalkTableOffset of 0 for everybody][:lighting :run] +[1:03:22][Fix ComputeWalkTable() to increment the DestIndex][:lighting] +[1:03:40][:Run (or walk?) a single-threaded -Od build of the game][:lighting] +[1:03:54][Switch to -O2 and re-enable multithreading of the :lighting][:threading] +[1:04:29][Compiler feature request: Swappable optimised and debug versions of routines][:admin :language] +[1:05:30][See that the ray cast now walks in the correct general direction, but never diverges from the vertical][:"debug visualisation" :lighting :run] +[1:05:49][Fix GridRayCast() to increment the WalkTable][:lighting] +[1:06:31][Admire our nice walk table stepping][:"debug visualisation" :lighting :run] +[1:07:56][Try to limit GridRayCast() to draw only one ray][:"debug visualisation" :lighting] +[1:09:09][See our single ray][:"debug visualisation" :lighting :run] +[1:09:31][Make FullCast() pass a designated debug ray to GridRayCast()][:"debug visualisation" :lighting] +[1:13:23][See our single ray, which sadly does not hit][:"debug visualisation" :lighting :run] +[1:13:35][Make FullCast() pass different rays to GridRayCast() using trial and error][:"debug visualisation" :lighting :programming :run] +[1:16:16][Reacquaint ourselves with GenerateOctahedralLightingPattern() from hhsphere][:lighting :research] +[1:17:40][Make FullCast() pass ray 36, the central one in the map, to GridRayCast()][:"debug visualisation" :lighting :programming :run] +[1:17:49][Admire our single ray, which hits][:"debug visualisation" :lighting :run] +[1:18:31][Rerun the game to regenerate the WalkTable, and admire our ray][:"debug visualisation" :lighting :run] +[1:20:01][Try and make GridRayCast() colour the boxes differently][:"debug visualisation" :lighting] +[1:21:04][See that the boxes remain the same colour][:"debug visualisation" :lighting :run] +[1:21:12][Embark on systemically disabling the :lighting for CompileZBiasProgram()][:"debug visualisation" :hardware :lighting :research] +[1:22:15][Demo the unlit debug :UI][:hardware :lighting :run] +[1:22:28][Make CompileZBiasProgram() use a passed in Emission value to apply :lighting to the texture, augmenting opengl_program_common with a VertEmission][:"data structure" :"debug visualisation" :hardware] +[1:33:06][Hit OpenGL error: Index out of range][:hardware :lighting :run] +[1:33:47][Make OpenGLCreateProgram() set the VertEmission][:hardware :lighting] +[1:35:03][Hit OpenGL error: Undefined variable "Emission"][:hardware :lighting :run] +[1:35:45][Fix naming of FragEmission in CompileZBiasProgram()][:hardware :lighting] +[1:35:54][Hit a read access violation inside the OpenGL driver][:hardware :lighting :run] +[1:36:37][Fix the Emission texture binding in UseProgramBegin()][:hardware :lighting] +[1:37:02][See that the debug :UI is now being lit][:hardware :lighting :run] +[1:37:15][Make WriteQuad() set Emission to 0, and PushQuad() set it to black or white depending on whether :lighting is enabled][:"debug visualisation" :lighting] +[1:41:01][See that the debug :UI is correctly unlit again][:hardware :lighting :run] +[1:41:21][Make PushLineSegment() pass to PushQuad() an Emission value of 1.0f][:"debug visualisation" :lighting] +[1:44:02][See that our ray walk boxes are now coloured differently][:"debug visualisation" :lighting :run] +[1:44:46][Make GridRayCast() colour the leaf and edge nodes differently][:"debug visualisation" :lighting] +[1:46:13][Check out our differently coloured ray walk boxes][:"debug visualisation" :lighting :run] +[1:46:40][Make GridRayCast() colour the leaf and edge nodes even more differently][:"debug visualisation" :lighting] +[1:46:58][Check out our differently coloured ray walk boxes][:"debug visualisation" :lighting :run] +[1:47:49][Q&A][:speech] +[1:48:03][@sagian2005][[@cmuratori Casey]'s hair is starting to look a little cartoonish[ref + site="Villains Wiki" + page="Heat Miser" + url=https://villains.fandom.com/wiki/Heat_Miser]] +[1:48:33][Tease a Wilson cosplay attempt[ref + site="Don't Starve Wiki" + page=Characters + url=https://dontstarve.gamepedia.com/Characters]][:research] +[1:48:52][@insobot][Q: 5+ hour Majora's Mask?] +[1:49:08][@uplinkcoder][Q: :Performance might have changed since you removed the early-out][:lighting] +[1:50:36][Wrap it up][:speech] +[/video]