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

88 lines
6.7 KiB
Plaintext

[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Two-pass Depth Peeling" vod_platform=youtube id=JZIQHygH2cc annotator=Miblo]
[0:08][Recap and set the stage for the day]
[0:41][Note a couple of things in ~milton to fix, syncing and stuttering]
[1:31][Blackboard: Using atomics to write more than one piece of information to a framebuffer]
[5:06][Blackboard: Depth Peeling, as a lighter version of atomics]
[10:40][Could we get rid of multisampling altogether?]
[13:07][Run the game and point out the beautiful fade out]
[15:22][handmade_opengl.cpp: Disable multisampling and alpha to coverage, and run the game to show what it looks like]
[18:14][handmade_opengl.cpp: Determine to implement just the alpha compositing part]
[24:02][handmade_opengl.cpp: Enable the render loop to properly prepare and target the render buffers for depth peeling]
[28:03][Blackboard: Front and Back Pictures]
[28:34][handmade_opengl.cpp: Disable GL_BLEND and write out the values directly into the framebuffer]
[29:18][Run the game to see the front picture]
[30:16][Blackboard: The contents of the Front and Back Pictures]
[32:23][handmade_opengl.cpp: Enable OpenGLRenderCommands() to target a second framebuffer]
[37:11][handmade_opengl.cpp: Enable the textured_quads case to assume that the framebuffer is bound properly]
[38:15][Run the game to see the front buffer still there]
[38:29][handmade_opengl.cpp: Enable UseProgramBegin() to bind the DepthSampler framebuffer]
[42:12][handmade_opengl.cpp: Enable OpenGLRenderCommands() to read from more than one texture[ref
site=docs.GL
page="glActiveTexture"
url=http://docs.gl/gl3/glActiveTexture]]
[47:46][win32_handmade.h: Pull in glActiveTexture() from corearb.h[ref
site="Khronos"
page="glcorearb.h"
url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[48:46][Run the game to see everything working fine]
[49:26][handmade_opengl.cpp: Display GlobalFramebufferHandles\[1\] and run the game to see that back buffer]
[49:49][handmade_world_mode.cpp: Make UpdateAndRenderWorld() call BeginDepthPeel() and EndDepthPeel()]
[52:01][handmade_render_group.h: Introduce BeginDepthPeel() and EndDepthPeel()]
[52:29][Run the game and hit a glActiveTexture error]
[52:57][win32_handmade.h: Pull in the glActiveTexture() enums from corearb.h[ref
site="Khronos"
page="glcorearb.h"
url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[53:43][Run the game to see the depth peel, and note that the depth comparison is not reliable]
[55:45][handmade_opengl.cpp: Enable the FragmentCode to draw the FragZ]
[58:31][Run the game to see the interesting Z values]
[1:00:13][handmade_opengl.cpp: Switch to showing the front buffer and run the game to see that it looks correct]
[1:01:04][Run the game and note that all except the white texture is wrong]
[1:03:19][handmade_opengl.cpp: Investigate where we're sampling from, and how the framebuffer is stored]
[1:09:21][handmade_opengl.cpp: Try to move FragZ into the 0 to 1 range, and make it a floating point depth buffer]
[1:11:07][Run the game and note that it's oddly accurate for the white textured cubes]
[1:12:25][handmade_opengl.cpp: Enable culling[ref
site=docs.GL
page="glCullFace"
url=http://docs.gl/gl3/glCullFace][ref
site=docs.GL
page="glFrontFace"
url=http://docs.gl/gl3/glFrontFace]]
[1:14:46][Run the game and determine that everything in the game is wound backwards]
[1:16:17][Blackboard: Winding]
[1:17:06][handmade_render_group.cpp: Double-check that the code should be winding it properly]
[1:18:31][handmade_opengl.cpp: Try unsuccessfully to switch to using GL_QUADS]
[1:21:50][handmade_opengl.cpp: Switch to GL_TRIANGLES]
[1:22:41][Run the game to confirm that we are binding triangles correctly, but that the triangle strips must be backwards]
[1:23:02][handmade_render_group.cpp: Fix PushQuad() to push the vertices in the right order]
[1:23:42][Run the game to see our culling working properly]
[1:24:44][Determine to ruminate on the incorrect non-white textures]
[1:26:11][handmade_opengl.cpp: Introduce CompilePeelComposite()]
[1:38:23][handmade_opengl.cpp: Enable OpenGLRenderCommands() to composite the depth peels]
[1:44:39][handmade_opengl.cpp: Just a pass a colour to the shader, so we have less variability]
[1:46:49][Run the game to see our composited picture]
[1:48:06][handmade_opengl.cpp: Determine to ensure that the shader is passing the colour without alpha]
[1:50:56][Blackboard: Solving for unadulterated red]
[1:51:28][handmade_opengl.cpp: Make the shader undo the alpha modulation of the colours]
[1:52:42][Run the game to see our current status]
[1:53:29][handmade_opengl.cpp: Double-check the frame buffer creation code]
[1:54:54][Step in to OpenGLRenderCommands() and inspect the frame buffers]
[1:55:52][handmade_opengl.cpp: Make OpenGLRenderCommands() loop over the correct frame buffers]
[1:56:22][Run the game to see that we're much better]
[1:57:00]["Happy day happiness of special deliciousness"][quote 573]
[1:57:12][Determine to implement the depth peel shader tomorrow]
[1:57:31][Q&A]
[1:58:19][@sausagesuperb][I tend to see in a lot of APIs (for example SDL) things like DestroyWindow calls. If this is the last thing you do before exiting the app, doesn't the operating system take care of this for you?]
[1:59:45][@daniel_collin][Have you considered keeping the shader code as separate files so you can do automatic reload on save in the editor, for example, or do you think there won't be enough shader code to motivate the work?]
[2:00:55][handmade_opengl.cpp: Investigate why glDrawArrays() is busted]
[2:03:40][@itfrombit][I think your last hardcoded giant triangle strip UV mapping coordinate has a cut and paste error. Should be {1.0, 0.0} instead of {1.0, 1.0}?]
[2:03:52][handmade_opengl.cpp: Fix the final coordinate in Vertices and run the game to see that that wasn't enough to save us]
[2:04:10][@daniel_collin][By the way, it was pointed out that the compatibility bit only works in 3.2+ (and I think you specify 3.0 currently)]
[2:04:19][@tmellemseter][A bit off-topic, but why is not The Jeff and Casey Show Season 5 on the Molly Rocket website?]
[2:04:47][Consider what may be going wrong in our shader]
[2:07:32][@daniel_collin][I was told that you had some issue(s) with RenderDoc. Do you know if it was related to you having a old GPU or was it a real bug in Renderdoc?]
[2:08:52][@sahfortv][Could you view in the debugger and see if the shader outputs sensible values?]
[2:09:10][@sausagesuperb][In the future when Jon Blow's language is released for public (in case it will be before Handmade Hero completion), will you switch to use it for finishing unfinished parts of the game, or would you stay with C/C++ until the bitter end?]
[2:10:18][That is it]
[/video]