cinera_handmade.network/cmuratori/hero/code/code608.hmml

114 lines
10 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[video output=day608 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Visualizing Lighting Values" vod_platform=youtube id=rVJw10RkR9c annotator=Miblo]
[0:01][Note Twitch's latest twitchiness[ref
site="Handmade Hero"
page=Watch
url=https://handmadehero.org/watch]][:speech]
[1:26][Determine to do a :lighting quality pass][:speech]
[4:50][Debugging the :lighting: 1) Trial-and-error eyeballing][:speech]
[5:28][Debugging the :lighting: 2) Create and validate against our own definition of correct lighting behaviour][:speech]
[7:48][Regret not having gained much experience with :lighting][:speech]
[8:27][Demo our ability to debug the raycaster][:"debug visualisation" :lighting :run]
[10:19][ComputeLightPropagationWork cycle use: 82%][:lighting :performance :run]
[11:23][Approaching :lighting transfer][:run]
[13:52][Approaching :lighting transfer: Draw lines through the centre of each grid cube, derived from the octahedral map, with brighter directions drawn longer][:"debug visualisation" :run]
[15:59][Try increasing the W modification from ×0.75 to ×0.1 in BuildDiffuseLightMaps()][:lighting]
[16:23][Demo the slow, but feeding back, :lighting transfer, with the determination to step the lighting frame-by-frame][:run]
[17:49][Determine to draw those octahedral lines in a smaller secondary debug bounds][:"debug visualisation" :lighting :run]
[19:34][Introduce DebugDrawOctahedralValues() for UpdateLighting() to call][:"debug visualisation" :lighting]
[21:05][Note that the diffuse blur is probably providing too much power to the system][:lighting :speech]
[22:23][Make DebugDrawOctahedralValues() draw out our desired debug bounds][:"debug visualisation" :lighting]
[29:44][Introduce a version of * that takes a v3s and s32, and fix compile errors][:"debug visualisation" :lighting :mathematics]
[31:00][Check out our debug boxes][:"debug visualisation" :lighting :run]
[31:37][Make DebugDrawOctahedralValues() draw our octahedral lines][:"debug visualisation" :lighting]
[39:13][Check out our octahedral lines][:"debug visualisation" :lighting :run]
[40:00][Make PushLightingRenderValues() Clamp01() the Color][:lighting]
[42:46][The octahedral lines do not remain white][:"debug visualisation" :lighting :run]
[43:10][Fix PushLightingRenderValues() to Clamp01() the Line->Color and pass the resulting Color to PushLineSegment()][:"debug visualisation" :lighting]
[43:24][Our octahedral lines still do not remain white][:"debug visualisation" :lighting :run]
[43:49][Fix PushLightingRenderValues() to pass the clamped Color to PushLineSegment() for both ends][:"debug visualisation" :lighting]
[44:01][Our octahedral lines now remain white][:"debug visualisation" :lighting :run]
[44:20][Determine to support stepping the lighting frame-by-frame][:run]
[44:58][Prevent UpdateAndRenderWorld() from calling UpdateLighting()][:lighting]
[46:08][We get no :lighting][:run]
[46:19][Make UpdateAndRenderWorld() call UpdateLighting() when we press F9][:"input handling" :lighting]
[47:58][Step the :lighting frame-by-frame with F9][:"input handling" :lighting :run]
[49:25][Delete moonlight variables from GridRayCast()][:lighting]
[50:41][Our system contains no moonlight, yet our octahedral maps are seeing more light from above][:"debug visualisation" :lighting :run]
[52:11][Make PushLight() draw the light][:"debug visualisation" :lighting]
[53:55][Check out our lights, and see that our octahedral maps are not really responding to them][:"debug visualisation" :lighting :run]
[55:38][Move the DebugGridIndex and DebugRayIndex DEBUG_VALUE() initialisers from UpdateLighting() to PushLightingRenderValues()][:"debug system" :lighting]
[56:43][Edit our DebugGridIndex and DebugRayIndex to 17912 and 100][:"debug system" :"debug visualisation" :lighting :run]
[58:30][Make UpdateLighting() set DebugGridIndex and DebugRayIndex to 17912 + (SpatialGrid.CellCount.x × SpatialGrid.CellCount.y) and 100][:"debug system" :lighting]
[58:55][Edit our DebugGridIndex and DebugRayIndex to 17912 and 99][:"debug system" :"debug visualisation" :lighting :run]
[1:02:10][Make UpdateLighting() set DebugGridIndex to 17912][:"debug system" :lighting]
[1:02:31][Edit our DebugRayIndex to 156, and wonder if we are writing back into the wrong parts of the octahedral map][:"debug system" :"debug visualisation" :lighting :run]
[1:04:21][Make UpdateLighting() set DebugRayIndex to 156][:"debug system" :lighting]
[1:04:30][Edit our DebugRayIndex to 155][:"debug system" :"debug visualisation" :lighting :run]
[1:05:35][Make UpdateLighting() set DebugRayIndex to 155][:"debug system" :lighting]
[1:05:42][Try making FullCast() pass an Ignored buffer to GridRayCast(), to rule out the :"debug system" interfering with the SpecAtlas][:lighting]
[1:08:57][Our problem remains][:"debug visualisation" :lighting :run]
[1:09:38][Make FullCast() draw the ExpectedDirection that our rays point into their octahedral map][:lighting]
[1:15:38][Our rays and octahedral directions are closely aligned][:"debug visualisation" :lighting :run]
[1:16:52][Try increasing the W modification from ×0.1 to ×0.75 in BuildDiffuseLightMaps()][:lighting]
[1:17:16][Step through the :lighting][:"debug visualisation" :run]
[1:17:43][Make DebugDrawOctahedralValues() increase the length of our octahedral lines][:"debug visualisation" :lighting]
[1:18:34][Step through the :lighting][:"debug visualisation" :run]
[1:19:07][Make DebugDrawOctahedralValues() draw the diffuse atlas lines, introducing DebugDrawColorDir()][:"debug visualisation" :lighting]
[1:22:03][Step through the :lighting, to see that the diffuse atlas grows quickly][:"debug visualisation" :run]
[1:23:06][Temporarily prevent DebugDrawOctahedralValues() from drawing the diffuse atlas lines][:"debug visualisation" :lighting]
[1:23:19][Step through the :lighting, and note the upwards bias][:"debug visualisation" :run]
[1:23:54][Prevent GridRayCast() from transferring the light for non-hits][:lighting]
[1:27:16][Our SpecAtlas is getting light from the wrong directions][:"debug visualisation" :lighting :run]
[1:28:14][Prevent GridRayCast() from transferring the light for hits][:lighting]
[1:28:32][We correctly see no light][:"debug visualisation" :lighting :run]
[1:29:00][Our bug possibilities: 1) False hit reports; 2) Incorrectly writing the direction; 3) Incorrect debug drawing][:lighting :speech]
[1:30:41][Scrutinise FullCast() for write-back errors][:lighting :research]
[1:33:38][Check out our apparent ray hit][:"debug visualisation" :lighting :run]
[1:33:56][Prevent GridRayCast() from transferring the light for non-hits][:lighting]
[1:34:21][Our target ray is correctly not drawn][:"debug visualisation" :lighting :run]
[1:34:55][Move the debug line drawing branch in GridRayCast() outside of the SomethingHit condition][:"debug visualisation" :lighting]
[1:35:25][Check out our misinformed octahedral lines][:"debug visualisation" :lighting :run]
[1:37:00][Edit our DebugGridIndex to 17788][:"debug system" :"debug visualisation" :lighting :run]
[1:38:08][Make UpdateLighting() set DebugGridIndex to 17788][:"debug system" :lighting]
[1:38:29][Edit our DebugRayIndex, hopefully towards a light][:"debug system" :"debug visualisation" :lighting :run]
[1:42:01][Try decreasing the W modification from ×0.75 to ×0.1 in BuildDiffuseLightMaps()][:lighting]
[1:42:51][Edit our DebugRayIndex to 325, directly towards a light][:"debug system" :"debug visualisation" :lighting :run]
[1:43:31][Make UpdateLighting() set DebugRayIndex to 325][:"debug system" :lighting]
[1:44:16][Check out our direct hit][:"debug visualisation" :lighting :run]
[1:45:16][Rename ControlMask to FPControlMask in SetDefaultFPBehavior()[ref
site=GitHub
page="HandmadeHero / cpp / ControlMask in SetDefaultFPBehaviour"
url=https://github.com/HandmadeHero/cpp/issues/118]][:"platform layer"]
[1:46:40][@uplinkcoder][Q: Maybe just have one light source?][:lighting]
[1:47:07][Temporarily prevent GenerateRoom() from adding lamps][:lighting :"procedural generation"]
[1:47:26][Check out our one light][:lighting :run]
[1:47:53][Try increasing the W modification from ×0.1 to ×0.75 in BuildDiffuseLightMaps()][:lighting]
[1:48:00][Our octahedral maps are still seeing light from the wrong directions][:"debug visualisation" :lighting :run]
[1:48:38][A few words on languages with non-helpful "error-catching" features][:language :run]
[1:50:56][Consider our problem to be an indexing one][:"debug visualisation" :lighting :run]
[1:53:12][Q&A][:speech]
[1:53:29][@uplinkcoder][Q: Try moving the light][:lighting]
[1:53:42][Step through the :lighting][:"debug visualisation" :run]
[1:53:57][Make UpdateAndRenderWorld() offset the debug light in X][:lighting]
[1:54:23][See how that affects our octahedral lines][:"debug visualisation" :lighting :run]
[1:55:01][Make UpdateAndRenderWorld() offset the debug light the opposite direction in X][:lighting]
[1:55:17][See how that affects our octahedral lines][:"debug visualisation" :lighting :run]
[1:56:32][Prevent UpdateAndRenderWorld() from offsetting the debug light][:lighting]
[1:57:02][@miltondts][Q: Why are there two lit areas in the map with only one light source?][:lighting]
[1:57:14][The :lighting gets tiled around the world][:run]
[1:58:37][Disable LIGHTING_USE_GRID][:lighting]
[1:58:53][Our :"debug visualisation" is wrong][:lighting :run]
[1:59:27][Let UpdateAndRenderWorld() call UpdateLighting() every frame][:lighting]
[1:59:40][Our :"debug visualisation" is wrong][:lighting :run]
[2:00:01][Scrutinise DebugDrawOctahedralValues() and related functions for bugs][:"debug visualisation" :lighting :research]
[2:06:11][Check out our octahedral lines while moving the light][:"debug visualisation" :lighting :run]
[2:07:41][Let LIGHT_ATLAS_ASSERT() actually Assert()][:language]
[2:09:51][Happily fail to hit any LIGHT_ATLAS_ASSERT()][:"debug visualisation" :lighting :run]
[2:11:03][@uplinkcoder][Q: PushDebugLine() parameter order maybe?][:"debug visualisation" :lighting]
[2:12:05][@uplinkcoder][Q: Direction inverted?][:"debug visualisation" :lighting]
[2:12:11][Eyeball the octahedral lines, not seeing inversion][:"debug visualisation" :lighting :run]
[2:13:35][Briefly scrutinise DirectionFromTxTy() for bugs][:lighting :research]
[2:14:29][@vaualbus][Q: Does this not pass through the thing we did for having the 3D texture? Maybe we are tilting the line in the shader][:"debug visualisation" :lighting]
[2:15:17][Thank you, everyone][:speech]
[/video]