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

161 lines
15 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=day610 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Removing Incorrect Voxel-Voxel Reflections" vod_platform=youtube id=7w82SyDmyR8 annotator=Miblo]
[0:01][Recap and set the stage for the day][:speech]
[0:51][Demo the current state of our grid-based ray cast :lighting, noting the occasional feedback][:run]
[3:30][Determine to: 1) visualise :lighting energy levels, and 2) interpolate the lighting more diffusely, to avoid the squared artifacting][:"debug visualisation" :run]
[6:41][Prevent DebugDrawColorDir() from factoring the Intensity in to the line length][:"debug visualisation" :lighting]
[7:22][Check out our balled octahedral map DiffuseMap :lighting directions][:"debug visualisation" :run]
[7:37][Let DebugDrawColorDir() factor the 01 clamped Intensity in to the line length][:"debug visualisation" :lighting]
[8:15][Check out our more tractable octahedral map DiffuseMap :lighting directions][:"debug visualisation" :run]
[9:31][Consider our bounce-lighting to be plausible][:"debug visualisation" :lighting :run]
[10:39][Leave our :lighting flicker for later][:"debug visualisation" :run]
[11:38][Determine to establish the notion of :lighting energy levels][:"debug visualisation" :run]
[12:55][Maintaining Constant Energy][:blackboard :lighting]
[16:13][Explain that BuildDiffuseLightMaps() pre-creates incoming :lighting energy values][:research]
[17:18][Specular to Diffuse Blend][:blackboard :lighting]
[19:39][Cosine-falloff Scattering of Photons][:blackboard :lighting]
[22:21][Make BuildDiffuseLightMaps() scatter out only as much light as comes in][:lighting]
[29:54][Our world contains a lot less light][:lighting :run]
[30:15][Let GenerateRoom() add lamps][:lighting :"procedural generation"]
[30:44][Our lamps don't bounce much light][:lighting :run]
[31:13][Increase the lamps' light intensity from 2 to 10 in GenerateRoom()][:lighting :"procedural generation"]
[31:26][Our lamps bounce more light][:lighting :run]
[31:38][Increase the lamps' light intensity from 10 to 100 in GenerateRoom()][:lighting :"procedural generation"]
[31:57][Our world ends up turning red][:lighting :run]
[32:09][Decrease the lamps' light intensity from 100 to 50 in GenerateRoom()][:lighting :"procedural generation"]
[32:23][Our light is not propagating stably][:lighting :run]
[34:16][Scrutinise BuildDiffuseLightMaps() for bugs][:lighting :research]
[35:21][Prevent GridRayCast() from applying the cosine-falloff to ReflectColorFoo][:lighting]
[36:02][Our light is still not propagating stably][:lighting :run]
[37:11][Let GridRayCast() sample the light when our ray also does not hit][:lighting]
[37:49][Our light now propagates][:lighting :run]
[37:59][Decrease the lamps' light intensity from 50 to 10 in GenerateRoom()][:lighting :"procedural generation"]
[38:15][Our light still propagates][:lighting :run]
[38:23][Increase the lamps' light intensity from 10 to 15 in GenerateRoom()][:lighting :"procedural generation"]
[38:26][Our light looks great][:lighting :run]
[38:49][Increase the lamps' light intensity from 15 to 20 in GenerateRoom()][:lighting :"procedural generation"]
[39:04][Our light does seem to leak again great][:lighting :run]
[40:11][Prevent GenerateRoom() from adding lamps, and increase the intensity of the debug light by 10× in UpdateAndRenderWorld()][:lighting :"procedural generation"]
[40:43][Our light is powerful enough to bounce][:lighting :run]
[41:03][Increase the intensity of the debug light from 10 to 20 in UpdateAndRenderWorld()][:lighting :"procedural generation"]
[41:20][Our debug light bounces and leaks][:lighting :run]
[41:47][Scrutinise the termination :sampling in GridRayCast() for bugs][:lighting :research]
[43:24][Test preventing terminator hits from transferring the light in GridRayCast()][:lighting]
[44:29][Our light still leaks][:lighting :run]
[44:59][Test preventing early-outs from transferring the light in GridRayCast()][:lighting]
[45:19][Our light no longer leaks][:lighting :run]
[45:57][Scrutinise the terminator :sampling code in GridRayCast()][:lighting :research]
[48:01][Make ComputeWalkTable() terminate within the current cell, not sample from the next one][:lighting]
[48:42][Our light still leaks][:lighting :run]
[49:34][Add a PieceType_Occluder to entity_visible_piece_flag for UpdateAndRenderEntities() to use][:"entity system"]
[52:22][Our light spreads, not occluded][:lighting :run]
[52:37][Make GenerateRoom() add occluders, introducing AddPieceOccluder()][:"entity system" :"procedural generation"]
[55:43][Check out our occluders][:"debug visualisation" :"entity system" :lighting :"procedural generation" :run]
[56:04][Make GenerateRoom() extend the wall occluders to the top of the tile][:"entity system" :"procedural generation"]
[58:35][Our occluders are not aligned properly][:"entity system" :"procedural generation" :run]
[58:47][Make GenerateRoom() size the occluders relative to their position][:"entity system" :"procedural generation"]
[59:22][Our light leaks less][:lighting :run]
[1:01:20][Our light does leak below from the start][:lighting :run]
[1:01:30][Test preventing apron hits from transferring the light in GridRayCast()][:lighting]
[1:02:45][Our light still leaks][:lighting :run]
[1:03:01][Test preventing terminator hits from transferring the light in GridRayCast()][:lighting]
[1:03:15][Our light no longer leaks][:lighting :run]
[1:03:25][Scrutinise the terminator related code in GridRayCast() and ComputeWalkTable()][:lighting :research :sampling]
[1:07:44][See our non-leaky light][:lighting :run]
[1:08:02][Let terminator hits transfer the light in GridRayCast()][:lighting]
[1:08:10][Our light leaks][:lighting :run]
[1:08:59][Scrutinise the termination code ComputeWalkTable()][:lighting :research :sampling]
[1:10:27][Remove the DEBUG_ZERO code from GridRayCast()][:lighting]
[1:10:50][Edit our DebugGridIndex towards a grid index below our orphanage][:"debug system" :"debug visualisation" :lighting :run]
[1:11:46][Try setting DebugGridIndex to 10788 in UpdateLighting()][:"debug system" :lighting]
[1:12:14][Edit our DebugGridIndex towards a grid index below our orphanage][:"debug system" :"debug visualisation" :lighting :run]
[1:12:35][Try setting DebugGridIndex to 11788 in UpdateLighting()][:"debug system" :lighting]
[1:12:47][Edit our DebugGridIndex towards a grid index below our orphanage][:"debug system" :"debug visualisation" :lighting :run]
[1:13:04][Try setting DebugGridIndex to 13788 in UpdateLighting()][:"debug system" :lighting]
[1:13:23][Edit our DebugGridIndex and DebugRayIndex to 13586 and 335][:"debug system" :"debug visualisation" :lighting :run]
[1:14:40][Make UpdateLighting() set DebugGridIndex and DebugRayIndex to 13586 and 335, and increase the height of our octahedron drawing region in DebugDrawOctahedralValues()][:"debug system" :lighting]
[1:15:45][Hit a LIGHT_ATLAS_ASSERT in GetTileUnclamped()][:"debug system" :lighting :run]
[1:15:57][Fix the VoxStart centering computation in DebugDrawOctahedralValues()][:"debug visualisation" :lighting]
[1:16:35][See our taller octahedron drawing stack][:"debug visualisation" :lighting :run]
[1:16:49][Try making DebugDrawOctahedralValues() draw the entire height's worth of octahedral values][:"debug visualisation" :lighting]
[1:17:06][Hit an assertion in PushQuad()][:"debug system" :lighting :run]
[1:17:09][Make DebugDrawOctahedralValues() originate the octahedral drawing region at 0 in z][:"debug visualisation" :lighting]
[1:17:42][Check out our nonsensical octahedral values down below the orphanage][:"debug visualisation" :lighting :run]
[1:18:06][Note that, while we can only sample from cells inside our :lighting voxel, we may cast outside it][:research :sampling]
[1:18:31][Pick a grid cell to closely observe][:"debug visualisation" :lighting :run]
[1:20:12][Make UpdateLighting() set DebugGridIndex to 0, and remove the AtlasToSpatialGrid expansion (beyond the apron)][:"debug system" :lighting]
[1:21:04][Find the DebugGridIndex (717) and DebugRayIndex (531) for our close observation grid cell and ray][:"debug system" :"debug visualisation" :lighting :run]
[1:25:08][Make UpdateLighting() set DebugGridIndex and DebugRayIndex to 717 and 531][:"debug system" :lighting]
[1:25:19][Take a look at our debug ray][:"debug system" :"debug visualisation" :lighting :run]
[1:25:35][Make DebugDrawOctahedralValues() position the lighting voxel to encompass our ray's target hit][:"debug visualisation" :lighting]
[1:26:28][Our target is indeed receiving light was somewhere][:"debug system" :"debug visualisation" :lighting :run]
[1:28:48][Make ComputeVoxelIrradianceAt() take an OcclusionN which opposes our :sampling direction, until we hit][:lighting]
[1:31:22][Our light no longer leaks][:"debug visualisation" :lighting :run]
[1:32:13][Increase the intensity of the debug light from 20 to 50 in UpdateAndRenderWorld()][:lighting :"procedural generation"]
[1:32:57][Our light leaks a little bit][:"debug visualisation" :lighting :run]
[1:33:10][Decrease the intensity of the debug light from 50 to 30 in UpdateAndRenderWorld()][:lighting :"procedural generation"]
[1:33:18][Our light seems to leak][:"debug visualisation" :lighting :run]
[1:33:53][Decrease the intensity of the debug light from 30 to 10 in UpdateAndRenderWorld(), let UpdateAndRenderEntities() colour occluders like normal and GenerateRoom() add lamps][:lighting :"procedural generation"]
[1:34:29][Check out our :lighting][:run]
[1:35:21][Make GenerateRoom() add occluders for trees][:lighting :"procedural generation"]
[1:36:49][Check out our occluding trees][:lighting :run]
[1:37:10][Make GenerateRoom() add shrunken occluders for trees][:lighting :"procedural generation"]
[1:39:10][Hop towards the outside area][:lighting :run]
[1:39:21][Make UpdateAndRenderEntities() draw occluder outlines][:"debug visualisation" :lighting]
[1:39:35][Our trees lack occluders][:lighting :run]
[1:39:51][Fix GenerateRoom() to use the expanded TreeVol for the occluder][:lighting :"procedural generation"]
[1:40:02][Check out our thinned tree occluders][:lighting :run]
[1:40:09][Make GenerateRoom() further thin the tree occluder, and shrink its height][:lighting :"procedural generation"]
[1:42:43][Check out our thinned and shrunken tree occluders][:lighting :run]
[1:43:37][Decrease the LIGHT_FLOOR_VALUE from 0.2 to 0.0][:lighting]
[1:44:40][Admire our more lit world][:lighting :run]
[1:45:37][Prevent UpdateAndRenderEntities() from drawing occluder outlines, and UpdateLighting() calling DebugDrawOctahedralValues()][:"debug visualisation" :lighting]
[1:46:01][Admire our :lighting][:run]
[1:46:49][Prevent PushLight() from drawing light outlines, and make AddSnake() increase the intensity of the lamps][:"debug visualisation" :lighting]
[1:47:40][Admire our :lighting, and plan for: 1) adapting the power curve; 2) better spreading; and 3) reducing the noise][:run]
[1:49:20][Q&A][:speech]
[1:49:45][@mindmark42][Q: In the diffuse map weighting divide, could you get divide by zero?][:lighting]
[1:51:05][@vaualbus][Q: With this system, how could we give a more physically-based :rendering look to the light?][:lighting]
[1:52:36][@pragmascrypt][Q: Does the diffuse bounce use the albedo of the materials yet to color the bounce light?][:lighting]
[1:53:15][Make trees bounce green light, and everything else bounce blue][:lighting :"procedural generation"]
[1:54:00][See our tinted light][:lighting :run]
[1:54:34][Make trees bounce yellow light][:lighting :"procedural generation"]
[1:54:48][See our tinted light][:lighting :run]
[1:55:35][Make trees bounce red light][:lighting :"procedural generation"]
[1:55:46][See our red-tinted trees][:lighting :run]
[1:56:06][Revert the light tinting][:lighting :"procedural generation"]
[1:56:40][@uplinkcoder][Q: Can you compare with the older raycast?][:lighting]
[1:56:57][Disable LIGHTING_USE_GRID][:lighting]
[1:57:03][Check the old AABB ray cast :lighting][:run]
[1:58:35][@miltondts][Q: After the shader modification, it appears the light is still leaking. Why is that?][:lighting]
[1:59:08][Enable LIGHTING_USE_GRID][:lighting]
[1:59:18][Our light doesn't seem to leak][:lighting :run]
[2:01:12][Increase the intensity of the debug light from 10 to 50 in UpdateAndRenderWorld()][:lighting]
[2:01:39][Our light does leak][:lighting :run]
[2:01:50][Decrease the intensity of the debug light from 50 to 10 in UpdateAndRenderWorld()][:lighting]
[2:02:15][Make GenerateRoom() add ceiling occluders][:lighting :"procedural generation"]
[2:04:29][Check out our ceiling][:lighting :"procedural generation" :run]
[2:04:52][Increase the intensity of the debug light from 10 to 50 in UpdateAndRenderWorld()][:lighting]
[2:05:10][Our light does leak][:lighting :run]
[2:05:25][Decrease the intensity of the debug light from 50 to 10 in UpdateAndRenderWorld()][:lighting]
[2:05:56][Check our regularly non-leaking light][:lighting :run]
[2:06:36][@i_am_seabass][Q: Is it possible to smooth out the :lighting so it's not flickering as much?]
[2:07:14][@sharlock93][Q: From what I have "perceived" watching [~hero Handmade Hero] is that :lighting has taken up a pretty sizeable chunk of the episodes. Is lighting this inherently complex or am I missing something?]
[2:07:57][@toocanzs][Q: What are your plans to fix the square looking interpolation?][:lighting]
[2:08:24][@internationalizationist][Q: Do you think, will there be such topics with which we (you) will spend as much time as with light?][:lighting]
[2:08:47][@billdstrong][Q: Even :"fluid simulation", such as plasma?]
[2:11:27][@ravarix][@handmade_hero I'd argue :networking which has the same issue. Trying to simulate two things which are apart as temporally the same]
[2:12:24][@andrevon][Q: Yet it seems like when you walk you drag the light behind you with inertia, more like a liquid. Is that on purpose or an effect of computation per frame?][:lighting]
[2:13:53][@ravarix][I'm sorry, but that just sounds ignorant to the complexities of game :networking]
[2:16:14][@internationalizationist][Q: What is so special in RTX?][:hardware]
[2:17:04][@equivocatorrr][Q: Is the difficulty of global illumination part of the reason why you're doing it?][:lighting]
[2:18:03][@ttbjm][Q: Even the RTX version of Minecraft has noticeable light lag][:hardware :lighting]
[2:19:06][@philliptrudeau][Q: If someone were making a different game with much sparser scenes containing more complex geometry, would you have any alternative prescriptions? Could the probes be arranged in a sparse grid? Or in camera-frustum-space rather than world-space?][:lighting]
[2:21:36][@andrevon][Q: When you tested the secondary bounces with the red light, it seemed like it only worked in left and down directions. Do you have an explanation for that?][:lighting]
[2:23:13][Scrutinise the obstruction Coefficient array computation code in ComputeVoxelIrradianceAt()][:lighting :research]
[2:24:08][Masking out obstructed light cells][:blackboard :lighting]
[2:25:28][@brimonk][Q: How does an RTX card actually perform ray tracing? Is it similar to what the PS5 can provide, which is hardware to work on a BVH structure to perform ray tracing, or is that different?][:hardware :lighting]
[2:30:18][@mindmark42][Q: Are the probes in the wall still getting cleared to zero?][:lighting]
[2:30:48][@mystran][The "ray incoherence" is really why a regular GPU has trouble with it as well since thread divergence wreaks havoc with traditional SIMT][:lighting :threading]
[2:34:46][Thank you, everyone][:speech]
[/video]