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

121 lines
12 KiB
Plaintext
Raw Permalink Normal View History

[video output=day588 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Aligning Light Voxels with the Camera" vod_platform=youtube id=S3JutszP9fg annotator=Miblo]
2020-03-26 00:55:54 +00:00
[0:03][Welcome to the stream][:speech]
[0:08][12% frame time (64ms per frame) spent in ComputeLightPropagationWork()][:lighting :performance :run]
[1:13][Consider shrinking the :lighting box][:run]
[1:46][Decrease the LIGHT_LOOKUP_VOXEL_DIM_Y from 32 to 24][:lighting]
[3:04][11% frame time (50ms per frame) spent in ComputeLightPropagationWork()][:lighting :performance :run]
[3:54][Consider aligning the light voxel with the :camera][:lighting :run]
[4:38][Make UpdateAndRenderWorld() draw the :camera bounds][:"debug visualisation"]
[6:40][Check out the :camera bounds][:"debug visualisation" :run]
[7:56][Respecify BeginLightingComputation() to take (and use) the CameraCenterOffset rather than CameraOffsetFromOrigin][:camera :lighting]
[9:03][Prepare to align the light voxel with the :camera, moving by the more fine-grained world tiles][:lighting :research]
[11:09][Set up BeginLightingComputation() to align the light voxel in two stages: by chunk, then around the :camera position][:lighting]
[14:11][The :lighting remains stable across chunks][:camera :run]
[15:01][Make BeginLightingComputation() align the light voxel around the :camera, introducing RoundToV3S() and augmenting lighting_solution with VoxelCameraOffset][:"data structure" :lighting :mathematics]
[21:08][The :lighting is almost copying backwards][:camera :run]
[21:53][Check the :lighting in a scrolling room][:camera :run]
[22:54][Check the copying in BeginLightingComputation() for bugs][:camera :lighting :research]
[24:28][Make BeginLightingComputation() factor in the VoxelCameraOffset to the VoxMinCornerHot][:camera :lighting]
[26:09][The :lighting copy remains broken][:camera :run]
[26:23][Pull out the OriginOffsetForCamera part of the VoxMinCornerHot() computation in BeginLightingComputation()][:camera :lighting]
[27:10][The :lighting is indeed copying backwards][:camera :run]
[27:33][Invert the computation of VoxMinCornerHot in BeginLightingComputation()][:camera :lighting]
[27:58][The :lighting now copies correctly][:camera :run]
[28:26][The :lighting does not centre correctly][:camera :run]
[29:39][Try zeroing out the VoxelCameraOffset in BeginLightingComputation()][:camera :lighting]
[30:59][The :lighting centring is worse, as hoped][:camera :run]
[31:16][Prevent BeginLightingComputation() from zeroing out the VoxelCameraOffset][:camera :lighting]
[31:19][Reacquaint ourselves with BlockCopyAtlas()][:lighting :research]
[33:19][Make BlockCopyAtlas() self-documenting][:lighting]
[35:13][Prepare to respecify BeginLightingComputation() to offset the light voxel in the correct direction][:camera :lighting :research]
[36:38][Consider aligning the light voxel by re-canonicalising its coordinates][:lighting :research]
[38:00][Revert BeginLightingComputation() to align the light voxel to the OriginP, making UpdateAndRenderWorld() pass as this value the Camera.SimulationCenter mapped into chunk space][:camera :lighting]
[40:10][The light brightens and moves in the opposite direction][:camera :lighting :run]
[40:39][Try making UpdateAndRenderWorld() pass the Camera.SimulationCenter directly to BeginLightingComputation()][:camera :lighting]
[41:12][The :lighting is normal][:camera :run]
[41:17][Make UpdateAndRenderWorld() pass to BeginLightingComputation() the Camera.SimulationCenter mapped into chunk space][:camera :lighting]
[41:26][The :lighting is nuts][:camera :run]
[41:41][Remove VoxelCameraOffset from lighting_solution][:camera :"data structure" :lighting]
[41:54][The light brightens][:camera :lighting :run]
[42:05][Toggle off the BlockCopyAtlas() calls in BeginLightingComputation()][:camera :lighting]
[42:25][The light still brightens][:camera :lighting :run]
[42:31][Reinstate the BlockCopyAtlas() calls in BeginLightingComputation()][:camera :lighting]
[43:12][The light brightens][:camera :lighting :run]
[43:27][Remove the light probe data from lighting_solution, and make UpdateAndRenderWorld() pass the Camera.SimulationCenter directly to BeginLightingComputation()][:camera :"data structure" :lighting]
[43:40][The :lighting is normal][:camera :run]
[44:01][Make UpdateAndRenderWorld() pass to BeginLightingComputation() the Camera.SimulationCenter mapped into chunk space][:camera :lighting]
[44:09][The light voxel moves, but barely][:camera :lighting :run]
[44:28][Scour BeginLightingComputation() for bugs that may affect the :lighting accumulation][:camera :research]
[46:08][The :lighting region moves in the opposite direction][:camera :run]
[46:51][Scour BeginLightingComputation() for :lighting region movement bugs][:camera :research]
[48:02][Try making BeginLightingComputation() invert the dChunk][:camera :lighting]
[48:47][The :lighting moves oddly][:camera :run]
[48:57][Revert the :lighting movement code in BeginLightingComputation()][:camera]
[49:27][What Is Happening??? \[Light voxel alignment\]][:blackboard :camera :lighting]
[55:06][Focus on the VoxMinCornerHot in BeginLightingComputation()][:camera :lighting :research]
[57:26][Make UpdateAndRenderWorld() pass the Camera.SimulationCenter directly to BeginLightingComputation()][:camera :lighting]
[57:32][The :lighting is normal][:camera :run]
[57:54][Make UpdateAndRenderWorld() draw the SimBounds][:camera :"debug visualisation" :lighting]
[58:16][The :lighting bounds are not centred about the simulation region][:camera :"debug visualisation" :run]
[59:05][Try making UpdateAndRenderWorld() set the SimBounds from the Camera.SimulationCenter][:camera :lighting]
[1:01:56][The :lighting bounds remain not centred about the simulation region][:camera :run]
[1:02:01][Scour UpdateAndRenderWorld() for :lighting bounds centring bugs][:camera :research]
[1:03:13][Try making BeginLightingComputation() draw a centred 1³ HotVoxelRect][:camera :"debug visualisation" :lighting]
[1:03:50][See nothing][:camera :lighting :run]
[1:03:54][Increase the HotVoxelRect size from 1³ to 10³ in BeginLightingComputation()][:camera :lighting]
[1:04:06][The :lighting bounds are not centred about the simulation region][:camera :run]
[1:04:24][Try making UpdateAndRenderWorld() draw a centred 10³ rectangle from the same Camera.SimulationCenter][:camera :"debug visualisation" :lighting]
[1:05:22][This Camera.SimulationCenter rectangle is also in the wrong place][:camera :"debug visualisation" :lighting :run]
[1:05:39][Make UpdateAndRenderWorld() draw the SimBounds, and BeginLightingComputation() invert the centring of the HotVoxelRect][:camera :"debug visualisation" :lighting]
[1:06:27][The HotVoxelRect is centred][:camera :"debug visualisation" :lighting :run]
[1:06:33][Make BeginLightingComputation() invert the VoxMinCornerHot offset][:camera :lighting]
[1:07:23][The light voxel is now aligned to the simulation region][:camera :"debug visualisation" :lighting :run]
[1:08:26][Make UpdateAndRenderWorld() pass to BeginLightingComputation() the Camera.SimulationCenter mapped into chunk space][:camera :lighting]
[1:08:45][The light voxel moves with the :camera, but not centred][:lighting :run]
[1:09:35][Make BeginLightingComputation() take a SimOriginP from which to offset the VoxMinCornerHot][:camera :lighting]
[1:12:21][The light voxel moves with the :camera, centred][:lighting :run]
[1:13:49][Increase the SimBounds size in UpdateAndRenderWorld()][:camera]
[1:14:25][Check out our expanded SimBounds][:camera :run]
[1:15:36][Make BeginLightingComputation() move the :lighting bounds by the more coarse-grained chunk][:camera]
[1:16:21][The :lighting bounds moves by the more coarse-grained chunk][:camera :run]
[1:17:05][Consider voxel centres][:camera :lighting :research]
[1:17:23][The :lighting copy looks roughly correct][:camera :run]
[1:18:48][Set up BeginLightingComputation() to move the :lighting bounds by the more fine-grained voxel][:camera]
[1:21:38][Check out the :lighting][:camera :run]
[1:21:49][Make BeginLightingComputation() account for the :camera offset when moving the :lighting bounds]
[1:23:20][The :lighting bounds are drawn properly positioned][:camera :run]
[1:24:01][Make BeginLightingComputation() copy the :lighting into position as the bounds move, augmenting lighting_solution with VoxCameraOffset][:camera :"data structure"]
[1:26:52][The :lighting is entirely correct][:camera :run]
[1:27:16][Toggle off the light map viewers in OpenGLEndFrame()][:"debug visualisation" :lighting]
[1:27:30][Admire the :lighting][:camera :run]
[1:27:36][Toggle off the :lighting :"debug visualisation" in BeginLightingComputation() and UpdateAndRenderWorld()][:camera]
[1:27:54][Traverse the world admiring the :lighting, and note light transmission problems][:camera :run]
[1:31:13][Determine to optimise the ray caster, improve the light quality, add collectors for trees and colour the walls correctly][:lighting :optimisation :run]
[1:33:42][Q&A][:speech]
[1:34:08][@vaualbus][Q: How can we disable :lighting for the debug :UI?]
[1:35:00][@futuremillennium][Looks like OBS is skipping a lot of frames due to encoding lag. Even the webcam is low FPS when you move in-game]
[1:36:16][@futuremillennium]["Dropped frames" are due to network only, you need to go to View → Stats to see skipped frames, @handmade_hero]
[1:37:13][@futuremillennium][The game is probably fighting OBS for the GPU]
[1:39:33][@ormone88][Q: I read a twitter conversation from an engine programmer at id software, about the engine for the new Doom game not having a main thread or render thread, only tasks and queues. Could you comment on this architecture?][:threading]
[1:41:03][@vaualbus][Q: I think that is a twitch problem on the servers because [@naysayer88 Jon] on his stream got the same problem where the frame rate on the game gets lower while streaming, and only on twitch it looks laggy. So maybe backend stuff on twitch]
[1:45:40][@internationalizationist][Q: You once mentioned that there are two types of GPU: tiled and non tiled, and mobiles use the tiled method. But why? What are the benefits for mobiles of using it?][:caching :hardware :rendering]
[1:51:36][@jessem3y3r][Q: [@rygorous Fabian] recently described GPUs as possessing throughput caches as opposed to latency caches. How does a throughput cache operate differently than a latency cache?][:caching :hardware :rendering]
[1:56:02][@internationalizationist][Q: But why are desktops using non-tiled method then? It looks like a clear benefit, including the fact that there are lots of units nowadays][:caching :hardware :rendering]
[1:58:38][@euphius][Q: The new COD Battle Royale installs a shader for better game performance when being in the game. I thought shaders are "GPU programs". Can you imagine what might be behind that? It takes quite a while to install][:hardware :language]
[2:01:18][@vaualbus][Q: But on OpenGL I think there is now a way to compile the shader and read it back?][:hardware :language]
[2:03:45][@teamrandb][Q: Pardon me for I did not catch the end of the stream; but, what frame rate (time per frame) are we at now? I believe at the start we were at roughly 60 ms][:performance]
[2:03:51][68ms per frame][:performance :run]
[2:05:02][Decrease the LIGHT_LOOKUP_VOXEL_DIM_X and Y from 32 / 24 to 24 / 16 respectively][:lighting]
[2:05:27][Check out the :lighting][:run]
[2:05:37][Make BeginLightingComputation() offset the light voxel two cells into the distance][:lighting]
[2:06:03][33ms per frame][:lighting :performance :run]
[2:07:14][@internationalizationist][Q: Could you recommend some literature / resources etc. to dig deeper?][:caching :hardware :rendering]
[2:07:24][@vaualbus][Q: So could it be easier to not have this dimension in a define? So that maybe the world gen can produce per-room voxel dim? That would result in optimized light system in general, I guess?][:lighting]
[2:07:39][@philoez98][Q: What do you think about the new kind of pipeline that NVIDIA is pushing with mesh and task shaders?]
[2:08:01][@teamrandb][Q: If we had a major light source from behind and we had, say, a large tree / house behind us, if this light box is too small, would it mean we would not get the shadow of whatever is behind us?][:lighting]
[2:09:18][@czapa10][Q: Is it possible to make these 2D trees cast shadows in the shape of a tree on the ground? If yes, can you tell what keyword should I write in google to find out more about that? I wanna use it in my own 2D game][:lighting]
[2:11:08][@relvet][Q: Would solving the :lighting wrapping in X reduce CPU load to significant extent?][:performance]
[2:11:20][@socraticfallacy][Q: Would you consider using compute shaders for some of these :lighting calculations?]
[2:12:18][Wrap it up][:speech]
[/video]