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

73 lines
6.4 KiB
Plaintext
Raw Permalink Normal View History

[video output=day382 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Depth Peel Compositing" vod_platform=youtube id=up8hb_TrKTE annotator=Miblo]
[0:03][Recap and set the stage for the day]
[2:50][Run the game to take a look at the situation as it stands]
[5:51][handmade_opengl.cpp: Establish that we can set the viewport correctly]
[10:28][handmade_opengl.cpp: Simplify the shader down so that it just draws red]
[14:11][Step through OpenGLRenderCommands() to verify the vertex data]
[18:03][handmade_opengl.cpp: Correctly set the vertices' W coordinates]
[19:38][Run the game to see red where we expect]
[20:41][handmade_opengl.cpp: Remove our debug test code]
[22:12][Run the game to see that our composite is working]
[22:28]["Cheers"][quote 574]
[22:41][handmade_opengl.cpp: Verify that we can read from our framebuffers and run the game to see that the Peel0 value is wrong]
[23:46][handmade_opengl.cpp: Investigate what is wrong, noting that AMD wasn't letting us use multisampling sRGB]
[26:14][handmade_opengl.cpp: Make the shader perform the blend without sRGB, and run the game to see that it looks close to correct]
[29:20][handmade_opengl.cpp: Enable OpenGLInit() to use sRGB without multisampling, and run the game to see that the halo has gone, but the trees have fringing]
[32:29][handmade_opengl.cpp: Make OpenGLRenderCommands() only clear the top layer, and run the game to see that the fringing has gone]
[33:34][Consider how best to handle multiple overlapping alpha'd elements]
[35:22][Blackboard: Alpha + Z Buffer]
[36:49][Blackboard: The standard way of handling transparency in multiple passes]
[38:35][Blackboard: A smarter way of handling transparency]
[43:13][Blackboard: Single Framebuffer, Multiple Depth Peels]
[47:45][handmade_opengl.cpp: Make OpenGLRenderCommands() always draw to the same colour buffer and blend multiple depth peels into it]
[52:34][Run the game to see Z fighting]
[54:24][handmade_opengl.cpp: Investigate the Z fighting]
[56:55][Realise that we do need two colour buffers for sorting, and back out our single-buffer code]
[59:12][handmade_opengl.cpp: Make OpenGLRenderCommands() write into multiple depth buffers, and the shader sample from multiple peels]
[1:05:55][handmade_opengl.h: Split opengl_program out into new zbias_program and peel_composite_program structs]
[1:09:37][handmade_opengl.cpp: Introduce versions of UseProgramBegin() that take these new structs]
[1:13:39][Run the game and look at the different peels]
[1:14:31][handmade_opengl.cpp: Enable OpenGLRenderCommands() to draw to all the peels]
[1:16:48][Run the game and investigate the failing compositing]
[1:19:16][handmade_opengl.cpp: Make CompilePeelComposite() copy the peels across, run the game and only see the profiler]
[1:23:45][handmade_opengl.cpp: Gather up the first texture into all the peels]
[1:24:38]["You can't just start talking about variables that don't exist yet"][quote 575]
[1:24:43][handmade_opengl.cpp: Investigate the incorrect blitting]
[1:26:47][handmade_opengl.cpp: Make OpenGLRenderCommands() correctly set the ActiveTexture, and run the game]
[1:27:54][handmade_opengl.cpp: Enable everything until we're back at the composite path, and run the game]
[1:29:21][handmade_opengl.cpp: Investigate how we are doing the peel composite]
[1:32:20][Run the game and note that the depth peel doesn't handle identical Z values]
[1:33:44][handmade_particles.cpp: Make SpawnFire() randomise the P.z]
[1:37:01][Run the game and consider making a more controlled test case]
[1:37:44][handmade_particles.cpp: Make SpawnFire() throw the particles upwards in Z]
[1:39:10][Run the game to admire the particles]
[1:39:22][handmade_particles.cpp: Make SpawnFire() give the particles more poof, and run the game to admire them][quote 576]
[1:42:17][handmade_opengl.cpp: Determine that we only have two peels and investigate why]
[1:46:16][Step into CompilePeelComposite() and inspect the PeelSampler values and GlobalFrameBufferTextures]
[1:51:31][handmade_opengl.cpp: Make OpenGLRenderCommands() not mipmap the textures when binding]
[1:53:07][Run the game to see that that fixed it]
[1:53:53][handmade_opengl.cpp: Reenable everything and perform the full blend]
[1:54:32][Run the game to see that it looks quite nice]
[1:55:52][handmade_opengl.cpp: Work towards enabling CompileZBiasProgram() to alpha fade the clip plane]
[2:02:08][Run the game to see the awesome depth peel at half alpha]
[2:02:50][handmade_opengl.cpp: Complete implementing the near clip plane fading]
[2:08:37][Run the game to admire the near clip plane fading]
[2:09:52][Q&A][:speech]
[2:10:11][Note that it doesn't seem to line up with the near clip plane]
[2:10:45][handmade_world_mode.cpp: Increase the NearClipPlane and run the game to see it]
[2:12:50][@Miblo][Could you try disabling the randomisation of the ground tile Z? I'm interested to see if that'll adversely affect the sexiness of the depth peel]
[2:13:26][handmade_world_mode.cpp: Temporarily disable the randomisation and run the game to see that]
[2:14:28][@thesizik][Debug menu's broken now]
[2:14:55][handmade_render_group.cpp: Make SetCameraTransform() correctly set the clip alpha distances for the debug menu, and run the game]
[2:16:30][@pragmascrypt][For depth peeling: would it be possible to discard all pixels in the 2nd layer that have an alpha value of 255 in the front layer because they are not interesting for the composition anyway?]
[2:19:20][@alexkelbo][I'm behind on day 130, just finished the SIMD / thread introduction. What feature of the game eventually forced you to use the GPU? (Totally love the software rendering)]
[2:21:12][@alexkelbo][Is the game going to be more 3D-ish gameplay-wise than originally planned?]
[2:22:32][@napoleon89][So is the depth peeling being used for order-independent transparency with the sprites?]
[2:23:44][@zzyzzyxx][Can you go into more detail on what fixed layers 2 / 3 from being all black? It wasn't an old card only being able to read two textures, but I missed the actual resolution]
[2:24:04][OpenGL assumes that textures are mipmapped]
[2:26:52][@k2t0f12d][Do you actually have to have wireframe models to be considered 2.5D, or would this count as well?]
[2:28:28][@k2t0f12d][You could define your own render definition for HMD]
[2:29:47][@alexkelbo][Is the floor below us being drawn completely and the one we are on on top of it, or is the one below clipped so only the pixels we see through the holes are drawn?]
[2:31:33][Wrap it up with a glimpse into the future of new art integration][:speech]
[/video]