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

117 lines
8.8 KiB
Plaintext
Raw Normal View History

[video output=day561 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Sampling Light Voxels with a Reflection Vector" vod_platform=youtube id=6m3xD5Gm9DA annotator=Miblo]
2019-10-15 00:21:07 +00:00
[0:01][Recap and set the stage for the day][:speech]
[0:34][Demo our tartan world with a view to :sampling all of our voxels][:lighting :run]
[2:19][Consider optimising CompileZBiasProgram() to only sample from three voxels][:lighting :research]
[3:36][Toggle off BuildSpatialPartitionForLighting() and ComputeLightPropagation() in EndLightingComputation()][:lighting]
[4:08][Nsight :rendering time: 22ms / frame][:lighting :run]
[5:00][Capture a frame to see that the glTexSubImage3D() call takes most of our frame time, at 15.13ms][:lighting :rendering :run]
[8:43][Make OpenGLInit() rather than OpenGLEndFrame() set the texture parameters for each voxel][:lighting]
[9:39][Ensure that that has done nothing adverse][:lighting :run]
[9:58][Temporarily make OpenGLEndFrame() only submit the light probe textures ten times][:lighting]
[10:57][Nsight :rendering time: 8ms / frame][:lighting :run]
[12:04][A few words on structured art, credited to Mike Biddlecombe][:speech]
[13:32][Make EndLightingComputation() stuff structured art into all faces of our light probe voxels, with Green in the East][:lighting]
[15:56][See our red-striped world][:lighting :run]
[16:38][Enable CompileZBiasProgram() apply the colour of our East faces][:lighting]
[18:01][Demo ~RemedyBG's new .str feature][:run]
[19:47][Fix our typo in CompileZBiasProgram()][:lighting]
[19:58][See our red- and green-striped world][:lighting :run]
[20:13][Make EndLightingComputation() stuff structured art into the South, North, Down and Up faces of our light probe voxels][:lighting]
[22:17][See that our green striping is not as expected][:lighting :run]
[22:39][Make EndLightingComputation() increase the spacing of our stripes][:lighting]
[24:27][See our distantly-spaced stripes][:lighting :run]
[24:41][Enable our closer-spaced stripes in EndLightingComputation()][:lighting]
[24:48][See our closer-spaced stripes][:lighting :run]
[25:08][Nsight :rendering time: 18ms / frame][:lighting :run]
[25:29][Capture a frame to determine that we must be CPU-bound][:lighting :run]
[26:10][Toggle off the structured art code in EndLightingComputation()][:lighting]
[26:21][Nsight :rendering time: 6 to 14ms / frame][:lighting :run]
[27:22][Check our GPU model: NVIDIA GeForce GTX 1080][:admin]
[27:51][Consider how best to fill our pixels, not using GPU Voxelisation because of its unordered access view][:lighting :rendering :speech]
[35:24][Disable voxel blending in OpenGLInit(), so we can see their boundaries][:lighting]
[36:15][Gauge the width of our voxels][:lighting :run]
[37:00][Make UpdateAndRenderWorld() set the WorldCameraRect based on the ExpectedFocus][:camera]
[39:59][See that our entire viewable region is fully lit][:camera :lighting :run]
[41:07][Consider our voxel grid to be too detailed][:lighting :run]
[41:35][Reduce our LIGHT_LOOKUP_VOXEL_DIM from 128 to 64][:lighting]
[41:59][Consider our voxel grid to be more reasonably detailed][:lighting :run]
[42:16][Reduce our LIGHT_LOOKUP_VOXEL_DIM from 64 to 32][:lighting]
[42:28][Consider our voxel grid to be roughly the right size, but the Y-band to be too thick][:lighting :run]
[44:07][Scan through CompileZBiasProgram() and EndLightingComputation() for possible bugs][:lighting :research]
[46:48][See eight narrow stripes along the X axis][:lighting :run]
[47:06][Understanding modulo operation][:lighting :mathematics :research]
[47:43][Toggle off the extraneous stripes EndLightingComputation()][:lighting]
[47:56][See four red stripes along X][:lighting :run]
[48:47][Try to apply Green to the LightWest in EndLightingComputation()][:lighting]
[49:26][See no difference, to determine that our problem is in the filling / :sampling of all faces of the voxels][:lighting :run]
[49:47][Disable the LightBounds resizing and positioning code in UpdateAndRenderWorld()][:lighting]
[51:46][Traverse the world with the determination to work on our spatial query][:lighting :run]
[52:37][Scan the code for any problems in our voxel specifications][:lighting :research]
[53:53][See no green stripes in Y, step in to UpdateAndRenderWorld() and inspect our InvLightDim][:lighting :run]
[56:11][Break in to a voxel submission in OpenGLEndFrame() and inspect the LightData][:lighting :run]
[59:41][Scrutinise our test striping code in EndLightingComputation(), and the voxel initialisation code in OpenGLBeginFrame()][:lighting :research]
[1:02:46][Excise stale OpenGL light values, and size the LightData in open_gl by the LIGHT_LOOKUP_VOXEL_DIM][:"data structure" :lighting]
[1:05:13][See our expected green stripes in Y][:lighting :run]
[1:05:32][Make EndLightingComputation() colour our :lighting bounds]
[1:06:30][See our four stripes in X and Y][:lighting :run]
[1:07:21][Consider using non-uniform voxel bounds, e.g. 64 × 64 × 32][:lighting :run]
[1:09:05][Make UpdateAndRenderWorld() form a square LightBounds][:lighting]
[1:10:18][See our square light bounds][:lighting :run]
[1:11:06][Make EndLightingComputation() stripe every other voxel][:lighting]
[1:11:32][See that our light probes tend to span two voxels][:lighting :run]
[1:12:43][Decrease the LIGHT_LOOKUP_VOXEL_DIM from 32 to 16][:lighting]
[1:12:55][See that we have roughly one voxel per light probe][:lighting :run]
[1:14:18][Increase the LIGHT_LOOKUP_VOXEL_DIM from 16 to 32][:lighting]
[1:14:36][Determine to light our world][:lighting :run]
[1:14:45][Nuke our striped :lighting, and stuff the West face of all voxels with white][:lighting]
[1:15:42][See our uniformly lit world][:lighting :run]
[1:16:05][Consider our :lighting equation][:lighting :research]
[1:20:57][Simple Fragment :Lighting][:blackboard]
[1:25:59][Reflection Vector][:blackboard :mathematics]
[1:28:52][HOWTO search "reflection" in the episode guide[ref
site="Handmade Hero"
page="Episode Guide"
url=https://handmadehero.org/watch#EpisodeGuide]][:research]
[1:29:19][Compute our reflection vector in CompileZBiasProgram()[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]][:lighting]
[1:32:36][:Run successfully][:lighting]
[1:32:38][Make CompileZBiasProgram() sample the :lighting specularly from the direction of the reflection vector, introducing GetIrradiance()]
[1:37:31][See our west-lit world][:lighting :run]
[1:37:46][Check our :lighting equation in CompileZBiasProgram()][:research]
[1:39:30][Consider our :lighting to be exactly right, except for the falloff][:run]
[1:40:58][Try making EndLightingComputation() light from the East][:lighting]
[1:41:22][See our east-lit world][:lighting :run]
[1:41:44][Note that we're computing the :lighting based on the debug :camera][:run]
[1:42:29][Try making EndLightingComputation() light from the South][:lighting]
[1:42:49][See our south-lit world, and wonder if the reflection is wrong][:lighting :run]
[1:44:07][Scrutinise our :lighting normals in CompileZBiasProgram()][:research]
[1:46:06][Note that our sprite normals are probably wrong][:lighting :run]
[1:47:14][Try making EndLightingComputation() light from the North][:lighting]
[1:47:32][See our north-lit world][:lighting :run]
[1:47:40][Try making EndLightingComputation() light from Below][:lighting]
[1:47:55][See our below-lit world][:lighting :run]
[1:48:04][Try making EndLightingComputation() light from Above][:lighting]
[1:48:14][See our above-lit world][:lighting :run]
[1:48:27][Make EndLightingComputation() light purple from above and yellow from below][:lighting]
[1:49:05][See our colourfully-lit world][:lighting :run]
[1:50:13][Q&A][:speech]
[1:50:47][@somebody_took_my_name][Q: Shouldn't it be R = I + 2*…, adding instead of subtracting the vectors?][:lighting]
[1:51:42][Flip the reflection vector computation in CompileZBiasProgram()][:lighting]
[1:52:10][See our (in)correctly lit world][:lighting :run]
[1:53:52][@xxthebigfoxx][Q: I think subtraction is right, actually, isn't it?][:mathematics]
[1:54:01][Reflection Vector Direction][:blackboard :mathematics]
[1:56:27][Flip back the reflection vector computation in CompileZBiasProgram()][:lighting]
[1:56:42][Reflection Vector Direction, continued][:blackboard :mathematics]
[1:58:09][See our purple sky reflection][:lighting :run]
[1:58:37][@vaualbus][Q: So where would you put material information for the :lighting? In the ray tracing part of the algorithm, that we still have not plugged in, or in the shader?]
[2:03:30][@xxthebigfoxx][Q: Are the AVX load instructions actually fast? Have you tested them?]
[2:04:31][@vaualbus][Q: Like this photo?[ref
site="Real World Tech"
page="NVIDIAs GT200: Inside a Parallel Processor"
url=https://www.realworldtech.com/gt200/11/]]
[2:06:16][@vaualbus][Q: Were the PS3's SPUs good at texture :sampling?]
[2:09:41][Wrap it up][:speech]
[/video]