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

75 lines
6.8 KiB
Plaintext
Raw Permalink Normal View History

[video output=day397 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Converting Depth Peel Data to Lighting Data" vod_platform=youtube id=7zSz85fsok0 annotator=Miblo]
[0:08][Recap and set the stage for the day]
[2:05][Consider how to resolve the issue that we're only computing the lighting on the topmost of four depth peels]
[5:41][Mention that multigrid lighting may not work out]
[9:29][Run the game to see the current state of the lighting system]
[12:31][handmade_opengl.cpp: Fix "Minor copy-paste error in handmade_opengl.cpp" issue[ref
site="GitHub"
page="HandmadeHero/cpp Issues"
url="https://github.com/HandmadeHero/cpp/issues"]]
[14:13][handmade_opengl.cpp: Prevent ComputeLightTransport() from pulling the emit colour from the DepthPeelResolveBuffer]
[15:03][Run the game to see the existing fake lighting]
[15:22][handmade_opengl.cpp: Enable ComputeLightTransport() to bind lighting textures that come from the depth peel]
[20:00][handmade_opengl.cpp: Introduce CompileDepthPeelToLighting() based on CompilePeelComposite()]
[29:16][handmade_opengl.cpp: Make CompilePeelComposite() compute the FrontEmit, BackEmit, SurfaceColor and NP]
[32:50][handmade_opengl.cpp: Change CompilePeelComposite() to use the layout(location) syntax and take an opengl_program_common]
[37:55][Run the game and see bright white]
[38:12][Research the OpenGL Layout qualifier[ref
site="Khronos"
page="The OpenGL Shading Language 3.30"
url="https://khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.3.30.pdf"][ref
site=OpenGL
page="Layout Qualifier (GLSL)"
url=https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)]]
[42:35][handmade_opengl.cpp: Revert CompilePeelComposite() to not use the layout(location) syntax, and make all the programs explicit]
[45:20][handmade_opengl.cpp: Make OpenGLCreateProgram() reset the SamplerCount, and introduce OpenGLLinkSamplers()]
[50:15][Run the game to see what we had running before]
[50:31][handmade_opengl.cpp: Make all the shader programs use OpenGLLinkSamplers(), as a partial way towards layout(location)]
[56:00][handmade_opengl.cpp: Make UseProgramBegin() set up all of the samplers for the program]
[56:59][Run the game to see that we're back to normal, view the beautiful depth buffer and investigate why we are seeing it]
[1:01:07][handmade_opengl.cpp: Hard set CompileZBiasProgram() to write red into BlendUnitColor\[0\]]
[1:01:43][Run the game to see that it isn't all red, and determine that some other phase must be wrong]
[1:03:13][handmade_opengl.cpp: Make CompileResolveMultisample() pass the samplers to OpenGLLinkSamplers() in the correct order, and run the game to see that we're back to normal]
[1:03:35][handmade_opengl.h and handmade_opengl.cpp: Remove peel_composite_program, final_stretch_program and multigrid_light_up_program, and their corresponding OpenGLProgramBegin() functions]
[1:06:09][Run the game to see that we're still fine]
[1:06:15][handmade_opengl.cpp: Try and force CompileResolveMultisample() to use layout(location = 8)]
[1:10:45][handmade_opengl.cpp: Toggle back on the depth peel importing in ComputeLightTransport()]
[1:11:17][Run the game to see that this does appear to have imported the lighting values]
[1:13:52][Determine to bounce the light around]
[1:17:30][Blackboard: Multigrid light transport]
[1:20:42][Blackboard: The multigrid dream]
[1:27:54][handmade_opengl.cpp: Consider what we can do in CompileMultiLightDown()]
[1:29:26][Blackboard: Bouncing light]
[1:30:21][Blackboard: Figuring out how aligned light sources are]
[1:31:02][handmade_opengl.cpp: Make CompileMultiLightDown() compute the facing term, the distance between lights and the falloff[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:34:45][Note that we're not reconstructing the light positions]
[1:35:19]["That's gonna be a whole bailiwick in and of itself"][quote 586]
[1:36:08][handmade_opengl.cpp: Make ReconstructPosition() in CompileMultiLightDown() use UV]
[1:36:52][Run the game, crash in ExecuteBrain() and investigate why]
[1:39:02][win32_handmade.cpp: Reduce the resolution in WinMain() and run the game to see that that looks better]
[1:41:06][handmade_opengl.cpp: Make CompileZBiasProgram() create a white light and run the game to see what's happening]
[1:42:49][handmade_opengl.cpp: Investigate why we are not seeing any colour contribution from textures]
[1:44:52][handmade_opengl.cpp: Fix TransferLight() in CompileZBiasProgram() to use the Falloff, and run the game to see colour contributon]
[1:45:13][handmade_opengl.cpp: Make TransferLight() in CompileZBiasProgram() transfer based on the facing direction and run the game to see that that is not working]
[1:47:43][handmade_opengl.cpp: Investigate why the facing direction isn't producing the expected transfer]
[1:52:44][handmade_opengl.cpp: Make CompileMultiGridDown() write the reconstructed normal into our second channel, and run the game to inspect that channel]
[1:55:27][handmade_opengl.cpp: Make ReconstructNormal() in CompileMultiGridDown() overwrite the Z with 0 and run the game to see that upward facing components still contain green]
[1:57:02][handmade_opengl.cpp: Make CompileDepthPeelToLighting() correctly compute the Nx and Ny and run the game to see better values]
[1:57:48][handmade_opengl.cpp: Make ReconstructNormal() in CompileMultiGridDown() use the computed Z and run the game with more confidence that the normals are plausible]
[1:58:28][handmade_opengl.cpp: Continue investigating why we're not getting any light transference]
[2:00:36][handmade_opengl.cpp: Make CompileZBiasProgram() output the negative inner product of the surface normals]
[2:01:20][Run the game to see that negative product]
[2:01:39][handmade_opengl.cpp: Make CompileZBiasProgram() output the non-negative inner product of the surface normals]
[2:01:47][Run the game to see this non-negative product]
[2:04:06][Q&A][:speech]
[2:04:50][@Miblo][Could some of our lighting code end up being used by the audio system to figure out where and how obstructed / reflected sound sources are?]
[2:06:01][@lorto6][Try 1 - clamp()!]
[2:06:27][Blackboard: Clamping normals]
[2:08:03][@asafgartner][Should you add a fake ceiling for lighting (or a non-fake ceiling based on the floor above the current one)?]
[2:08:48][@xyane][Not entirely related to today's stream, but will you perhaps use something like a pipeline state object for binding resources? I personally find that I get a few annoying debug messages telling me about resource hazards and I'd like a better way than randomly throwing in null binds in the middle of my code and would like a better way to bind resources to minimize API calls, and would love to see a good PSO implementation]
[2:11:34][We are done for today][:speech]
[/video]