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

70 lines
6.9 KiB
Plaintext

[video output=day387 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Further Attempts at Multisampled Depth Peeling" vod_platform=youtube id=SJRwEVr4HSw annotator=Miblo]
[0:08][Recap and set the stage for the day]
[1:28][Run the game to show our custom multi-resolution resolve with and without multisampling, and describe the problem that multisampling introduces for our depth peeling scheme]
[10:05][handmade_opengl.cpp: Read through CompileResolveMultisample(), and tweak it to specify GLSL version 1.50]
[10:56][Run the game to see that it works with GLSL 1.50 specified]
[11:40][Continue reading through CompileResolveMultisample()]
[12:40][Show the offset bug with ~Milton]
[14:12][Blackboard: Multisample Resolve]
[24:07][Blackboard: Picking a primitive's most distant sample from the camera]
[28:51][handmade_opengl.cpp: Make CompileResolveMultisample() sample the colour from the most distant pixel of primitives]
[41:28][Compile and run to see weird artifacts]
[42:05][handmade_opengl.cpp: Read through CompileResolveMultisample() and make it correctly set the Depth]
[45:14][Run the game to see that we're not getting smoothing along edges]
[45:42][handmade_opengl.cpp: Increase the DepthThreshold in CompileResolveMultisample() and run the game to see the smoothing]
[46:34][Consider always taking a particular depth sample for depth peeling purposes]
[49:00][handmade_opengl.cpp: Revert the DepthThreshold, and rewrite CompileResolveMultisample() to only track the DepthMin]
[51:17][Run the game to see artifacts at the primitive edges]
[51:48][handmade_opengl.cpp: Introduce a centroid to set FragZ in a way that won't vary per sample in CompileResolveMultisample()]
[56:44][Run the game to still see the artifacts]
[57:15][handmade_opengl.cpp: Enable CompileResolveMultisample() to visualise the number of unique samples]
[1:05:57][Run the game to see our debug visualisation]
[1:06:53][handmade_opengl.cpp: Enable CompileResolveMultisample() to colourise our debug visualisation]
[1:07:49][Run the game to see that we are getting two unique depth samples throughout the scene, and consider why]
[1:10:23][handmade_opengl.cpp: Make CompileResolveMultisample() hard set the InputZ to 0.5]
[1:11:13][Run the game to view our debug visualisation]
[1:12:17][handmade.cpp and handmade_platform.h: And a MultisamplingDebug toggle to the debug system]
[1:19:16][Run the game and toggle between the debug visualisation and regular view]
[1:20:08][handmade_opengl.cpp: Make CompileResolveMultisample() correctly set the InputZ, run the game and inspect the MultisamplingDebug view]
[1:22:16][Propose taking the background out of the equation]
[1:23:00][handmade_opengl.cpp: Enable CompileResolveMultisample() to skip sampling the background]
[1:26:09][Run the game to see that we don't get multisamples when there's only one primitive]
[1:26:53][handmade_opengl.cpp: Prevent CompileResolveMultisample() from using the InputZ and run the game to see that everything has multisamples]
[1:32:36][Inspect a screenshot to see that no blending occurs where there is only one depth value]
[1:33:12][handmade_opengl.cpp: Make CompileResolveMultisample() compute the InvSampleCount from the full SampleCount]
[1:34:48][Run the game to see that it now computes the correct colour, but does not sum up properly, and consider why]
[1:36:40][Note that premultiplied alpha and gamma correction don't work well together]
[1:38:23][handmade_opengl.cpp: Try to make CompileResolveMultisample() un-premultiply alpha and then reintroduce the alpha after producing the average colour value]
[1:39:51][win32_handmade.cpp: Switch back to 1280x720 and run the game]
[1:41:29][Consider two things: It'd be nice to fix the unique sample picking, but there still may be issues with multiple depth peels across the scene]
[1:43:15][handmade_platform.h and win32_handmade.cpp: Use 2x oversampling, run the game and inspect a screenshot]
[1:46:46][handmade_opengl.cpp: Consider enabling OpenGLRenderCommands() to correctly perform oversampling]
[1:48:23][win32_handmade.cpp: Switch to 1920x1080, run the game and consider downsampling that to a much lower resolution on our card]
[1:49:22][Consider getting the depth peel buffers to work in multisampling mode]
[1:50:19][Q&A][:speech]
[1:51:43][@dmitsuki][I can't compile the code, it's saying "Requires extension support: sampler2DMS (GL_ARB_texture_multisample)". But not having support for this makes no sense because I have an R9 390, which is a newer AMD card than you]
[1:52:30][@fr0styninja][Haven't really followed along with how you've implemented peeling but what if you separate out 3D objects and run them through a different shader that doesn't do peeling?]
[1:52:51][@pragmascrypt][Would doing a depth pre-pass without multisampling help?]
[1:53:29][@flyingsolomon][What do you think about ffmpeg and its likes? In your opinion is there a better way to implement a video-oriented program (with multiple codec support) without going nuts?]
[1:53:50][@cubercaleb][If you want the same depth for each multi-sample, couldn't you write the depth as a separate vertex shader output with centroid interpolation?]
[1:55:15][Run the game to show how the centroid sampling works great, but that at the seam between triangles we do get multiple samples]
[1:56:22][@dmitsuki][It works! Is that version defining what version of OpenGL that's going to be used? Which version is 150?]
[1:57:36][@serge_rgb][Hey Casey. Sorry about the cursor bug! Could you try creating a new canvas to see if it still happens? I missed the start of the stream but people told me that it only happens with wacom input. Is that true?]
[1:58:04][Blackboard: Show the offset input with the wacom tablet]
[2:02:39][@Kknewkles][Hi Casey! Do you have a few more good scientific-programmy papers to get me started on a good habit of reading long stuff for coding? I do remember those from "Papers I Loved" and the rasterization bridge one. Maybe there are some lighter reads for to begin on this road?[ref
site="Melissa E. O'Neill"
page="PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation"
url="http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf"]]
[2:08:07][@fr0styninja][How's 1935 coming along? Long time no news]
[2:08:54][@flyingsolomon][If thread behavior is considered to be completely random, can we leverage it to our random number generator?[ref
site="Wikipedia"
page="RdRand"
url="https://en.wikipedia.org/wiki/RdRand"]]
[2:11:32][@cubercaleb][Isn't PCG less favorable than something like Xorshift for games because the stepping function can't be SSE optimized?[ref
site="Melissa E. O'Neill"
page="PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation"
url="http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf"]]
[2:17:13][@rooctag][How come there are different Z values on the diagonal on the same sprite? Is it an epsilon issue, or did I miss something?]
[2:19:59][Wrap it up][:speech]
[/video]