[video output=day577 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Adding Octahedral Light Atlases" vod_platform=youtube id=1GqCmW_1BCw annotator=Miblo]
[0:04][Recap last stream's Octahedral Encoding paper research and set the stage for the day][:speech]
[1:58][Consider Octahedral Encoding: Texture Array vs Atlas[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :research]
[7:03][Skim read 'Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields'[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :research]
[10:55][Consult IrradianceField.cpp from the Code and Video supplement of 'Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields'[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields: Code and Video (589.8 MiB)"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/supplement.zip]][:lighting :research]
[14:16][Embark on Octahedral Encoding: 1) Setup Texture Atlas; 2) Draw Texture Atlas; 3) Place Octahedral Unwrapped Quads into the World][:lighting :speech]
[16:39][Build and :run the game]
[16:56][Augment open_gl with LightAtlasHandle][:"data structure" :lighting]
[19:18][Note the use of depth textures in 'Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields'[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :research]
[22:03][Modify open_gl replacing the texture array with Color and Depth texture atlases for Octahedral Encoding][:"data structure" :lighting]
[27:33][Consider our Octahedral Texture Atlas storage in open_gl][:"data structure" :lighting]
[28:45][Update OpenGLInit() to set up our new Octahedral Texture Atlases][:lighting]
[31:14][Calculate the storage (and GPU-submission) requirements of our Octahedral Texture Atlas: 32^3*10^2*4 = 13,107,200 bytes][:admin :lighting]
[35:31][Continue updating OpenGLInit() to set up our Octahedral Texture Atlases[ref
    site="docs.GL"
    page="glTexImage2D"
    url=http://docs.gl/gl3/glTexImage2D]][:lighting]
[39:52][Update OpenGLBeginFrame() and game_render_commands in line with our new Octahedral Texture Atlases][:"data structure" :lighting]
[41:21][Update OpenGLEndFrame() to bind and use our new Octahedral Texture Atlases, doubling the X dimension][:lighting]
[47:43][Set up CompileZBiasProgram() to use our new Octahedral Texture Atlases][:lighting]
[51:26][Update EndLightingComputation() in line with our new Octahedral Texture Atlases][:"data structure" :lighting]
[51:56][Hit OpenGL Error "GL_INVALID_ENUM"][:lighting :run]
[53:15][Fix GL_TEXTURE_3D to GL_TEXTURE_2D in OpenGLInit()][:lighting]
[54:04][Hit OpenGL Error "GL_INVALID_ENUM"][:lighting :run]
[54:48][Fix GL_R to GL_RED in OpenGLInit()][:lighting]
[54:58][Hit exception "Access violation reading location"][:lighting :run]
[55:41][Step through to OpenGLEndFrame()][:lighting :run]
[57:13][Fix OpenGLEndFrame() to pass GL_RED rather than (the larger) GL_RGB to glTexSubImage2D()][:lighting]
[57:34][:Run the game without :lighting, with the determination to output standard spherical lighting into octahedrons]
[58:30][Introduce OctahedralFromUnitVector() and UnitVectorFromOctahedral()][:lighting :mathematics]
[1:04:31][Explain the Octahedral wrap / unwrap[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :mathematics :research]
[1:05:55][Continue to implement OctahedralFromUnitVector() and UnitVectorFromOctahedral()[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :mathematics :research]
[1:11:50][Octahedral to Unit][:blackboard :mathematics]
[1:17:25][Solving the Octahedral to Unit equation][:blackboard :mathematics]
[1:20:28][Understanding the Octahedral to Unit mapping diagrammatically][:blackboard :mathematics]
[1:24:12][How to solve the Octahedral to Unit equation if we know Oz²][:blackboard :mathematics]
[1:26:17][Finish implementing UnitVectorFromOctahedral()][:lighting :mathematics]
[1:31:55][Check our implementation with 'Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields'[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :research]
[1:33:26][Fix the swizzle in UnitVectorFromOctahedral() in line with 'Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields'[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting]
[1:34:55][Modify light_voxel_cell for Octahedral Encoding][:"data structure" :lighting]
[1:38:02][Stub out ComputeVoxelIrradianceAt(), SpamVoxelSlice(), GetLightAmount() and EndLightingComputation() for Octahedral Encoding][:lighting]
[1:41:41][Toggle to TEST_LIGHT_SPHERE in EndLightingComputation() and implement that path for Octahedral Encoding][:lighting]
[1:57:02][:Run the game][:lighting]
[1:57:48][Capture a frame in RenderDoc][:lighting :run]
[2:01:14][Fix the ElIndexC and ElIndexD computations in EndLightingComputation()][:lighting]
[2:05:10][Capture a frame in RenderDoc][:lighting :run]
[2:06:14][Q&A][:speech]
[2:06:49][@somebody_took_my_name][Q: Quick note, you overwrite the x value which is used for the y value with encoding / decoding octahedrals][:lighting :mathematics]
[2:07:01][Fix UnitVectorFromOctahedral() to use O.x and O.y in the Ox and Oy settings][:lighting :mathematics]
[2:07:35][@somebody_took_my_name][And I think the Oz doesn't need to be negated in the UnitVectorFromOctahedral() function][:lighting :mathematics]
[2:08:58][@somebody_took_my_name][Q: Does it always have to be positive?][:lighting :mathematics]
[2:09:23][Fix UnitVectorFromOctahedral() to set the Result from Ox, Oy and Oz][:lighting :mathematics]
[2:09:31][Fix OctahedralFromUnitVector() to compute Ox and Oy as temporary variables][:lighting :mathematics]
[2:10:18][@howdydutty][Q: If 1 - SumXY is less than 0, then Oz would already be negative][:lighting :mathematics]
[2:10:49][Prevent UnitVectorFromOctahedral() from negating Oz][:lighting :mathematics]
[2:11:13][@sagian2005][Q: Reference code[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/] uses a "signNotZero" function instead of "signOf"][:lighting :mathematics]
[2:12:00][@xxthebigfoxx][Q: I think you have a typo on the Trilerp code where you index by \[Ty\]\[Ty\] and \[Tx\]\[Tx\] instead of \[Ty\]\[Tx\] in both places][:lighting :mathematics]
[2:12:17][@sagian2005][Q: But it's returning positive for 0][:lighting :mathematics]
[2:12:33][@sagian2005][Q: It should return 0 for 0[ref
    title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
    author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
    url=http://jcgt.org/published/0008/02/01/]][:lighting :mathematics]
[2:15:22][@xxthebigfoxx][Q: I think you have a typo on the Trilerp code where you index by \[Ty\]\[Ty\] and \[Tx\]\[Tx\] instead of \[Ty\]\[Tx\] in both places][:lighting :mathematics]
[2:15:51][@somebody_took_my_name][Q: Another RenderDoc image?]
[2:16:04][Capture a frame in RenderDoc][:lighting :run]
[2:16:59][@somebody_took_my_name][Q: Is Oxy supposed to be mapped between 0 and 1 or -1 and 1 in the setup light code?][:lighting]
[2:17:51][Fix EndLightingComputation() to map Oxy from -1 to 1][:lighting :mathematics]
[2:18:54][Capture a frame in RenderDoc][:lighting :run]
[2:19:48][@tinspin][Q: If it's okay to ask something off-topic? Why aren't more engines using dynamic .dll / .so for hot-deployment of game code?][:"hot reloading" :library]
[2:20:11][@jimdopango][Q: Do you find it annoying to keep hopping between editor and debugger when you are programming? In your ideal environment would these two tools be unified in the same window?]
[2:21:36][@vaualbus][Q: Could be a good idea to add to the :"debug system" a way to look at the OpenGL texture? So we could switch less from the game?][:"debug visualisation"]
[2:21:51][@x1bzzr][Q: Don't you think using a .cpp file instead of a batch file for build setup and configuration would be better since batch files are so bad?]
[2:22:19][@maliusarth][Q: Unreal only does it fairly recently using an external tool which cost them almost zero implementation effort][:"hot reloading" :library]
[2:23:41][Wind it down][:speech]
[/video]
