[video output=day405 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Crashing the Stream with a Fragment Shader" vod_platform=youtube id=0b28L6WnqmI annotator=Miblo]
[0:04][Recap and set the stage for the day]
[1:17][Determine to handle the "Unable to compile Z Bias program on GTX 1070" issue[ref
    site="GitHub"
    page="HandmadeHero/cpp Issues"
    url="https://github.com/HandmadeHero/cpp/issues"]]
[4:17][Run the game to see the current voxel-based lighting solution]
[5:00][handmade_opengl.cpp: Change all the shaders to use GLSL version 3.30[ref
    site="Khronos"
    page="Core Language (GLSL)"
    url=https://khronos.org/opengl/wiki/Core_Language_(GLSL)]]
[7:30][Run the game to see everything working as before]
[8:10][Close that issue]
[12:19][Determine to fix the "Shader layout issue" issue[ref
    site="GitHub"
    page="HandmadeHero/cpp Issues"
    url="https://github.com/HandmadeHero/cpp/issues"]]
[13:22][win32_handmade.cpp: Set GLSL version 3.30 in Win32OpenGLAttribs, run the game, and close that issue]
[14:26][Close the "Not compiling under VS2015" issue[ref
    site="GitHub"
    page="HandmadeHero/cpp Issues"
    url="https://github.com/HandmadeHero/cpp/issues"]]
[16:28][Run the game, describe the voxel lookup scheme and determine to transfer this lighting solution to the GPU]
[20:23][handmade_world_mode.h: Consider how to specify the lighting_textures to the GPU]
[23:26][handmade_render_group.h: Introduce render_entry_lighting_transfer]
[25:41][handmade_render_group.cpp: Introduce PushLighting()]
[29:05][handmade_render_group.cpp: Make OutputLighting() call PushLighting()]
[30:05][Run the game and hit the InvalidDefaultCase in OpenGLRenderCommands()]
[30:33][handmade_opengl.cpp: Add a case in OpenGLRenderCommands() for the lighting_transfer[ref
    site=docs.GL
    page="glTexSubImage1D"
    url=http://docs.gl/gl3/glTexSubImage1D][ref
    site=docs.GL
    page="glTexSubImage3D"
    url=http://docs.gl/gl3/glTexSubImage3D]]
[40:17][handmade_platform.h: Move in lighting_texel and lighting_textures from handmade_opengl.h]
[40:52][win32_handmade.cpp: Pull in glTexImage3D() and glTexSubImage3D() from corearb.h[ref
    site="Khronos"
    page="glcorearb.h"
    url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[43:37][Run the game and hit an error, presumably because we haven't bound our lighting texture]
[44:43][handmade_opengl.cpp: Make OpenGLChangeToSettings() bind and free the lighting textures[ref
    site=docs.GL
    page="glTexImage1D"
    url=http://docs.gl/gl3/glTexImage1D][ref
    site=docs.GL
    page="glTexImage3D"
    url=http://docs.gl/gl3/glTexImage3D]]
[54:33][Run the game without error]
[55:04][handmade_render_group.cpp: Make OutputLightingTextures() call PushLighting()]
[56:44][Run the game under the assumption that our lighting solution is now available on the GPU]
[57:07][handmade_opengl.cpp: Remove the old lighting code from CompileZBiasProgram(), and enable it to lookup into our voxel-based lighting solution[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"]]
[1:17:09][handmade_opengl.cpp: Make CompileZBiasProgram() and its UseProgramBegin() set up the voxels and link the samplers]
[1:20:45][handmade_render_group.cpp: Make PushLighting() take the voxel data]
[1:22:23][Run the game and see black]
[1:22:53][handmade_opengl.cpp: Make OpenGLRenderCommands() bind the lighting textures]
[1:25:13][Run the game and see no obvious errors, but still black]
[1:26:00][handmade_opengl.cpp: Investigate what CompileZBiasProgram() is drawing]
[1:28:57][Run the game and see red]
[1:29:00][handmade_opengl.cpp: Investigate why we are always getting an index value of 0]
[1:33:36][Run the game, toggle to the lighting view and inspect the values produced by OutputLightingTextures()]
[1:37:28][handmade_render_group.cpp: Temporarily add volatile global variables for DebugX, DebugY, DebugZ and DebugColor]
[1:39:46][Run the game and inspect those debug lighting values]
[1:40:11][handmade_opengl.cpp: Force CompileZBiasProgram() to lookup into those debug values]
[1:40:58][Run the game, toggle to the lighting view and determine that we are not getting valid values from the texture]
[1:42:28][handmade_opengl.cpp: Change CompileZBiasProgram() to use usampler3D rather than sampler3D for the lookup sampler[ref
    site="Khronos"
    page="glcorearb.h"
    url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[1:52:55][handmade_opengl.cpp: Revert CompileZBiasProgram() to use sampler3D, and itself convert the incoming colour to the 0 to 65535 range]
[1:54:11][Run the game and crash the stream, to be lost forever were it not for the magic of [@mmozeiko Mārtiņš Možeiko]]
[/video]
