74 lines
5.1 KiB
Plaintext
74 lines
5.1 KiB
Plaintext
[video output=day364 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Enabling the OpenGL Depth Buffer" vod_platform=youtube id=m8trVjY2WgI annotator=Miblo]
|
|
[1:32][Run the game, recap and set the stage for the day]
|
|
[4:55][Blackboard: Using the Z-buffer to sort ground tiles]
|
|
[6:35][Blackboard: Slanting the upright sprites to make them occlude each other properly]
|
|
[13:55][Run the game and illustrate why this scheme will be important for debugging purposes]
|
|
[14:08]["We're going to write some code and hope that it's right"][quote 550]
|
|
[14:56][Determine to turn on the Z-buffer[ref
|
|
site="Handmade Hero"
|
|
page="Day 358 - Introduction to Depth Buffers"
|
|
url="https://hero.handmade.network/episode/code/day358"]]
|
|
[15:36][handmade_opengl.cpp: Make OpenGLRenderCommands() enable GL_DEPTH_TEST and call glDepthMask()[ref
|
|
site="docs.GL"
|
|
page="glDepthMask"
|
|
url="http://docs.gl/gl2/glDepthMask"] and glColorMask()]
|
|
[21:40][win32_handmade.cpp: Make Win32SetPixelFormat() set cDepthBits[ref
|
|
site="MSDN"
|
|
page="PIXELFORMATDESCRIPTOR structure"
|
|
url="https://msdn.microsoft.com/en-us/library/windows/desktop/dd368826"]]
|
|
[25:00][win32_handmade.cpp: Make Win32SetPixelFormat() specify the colour bits[ref
|
|
site="Khronos"
|
|
page="WGL_ARB_pixel_format"
|
|
url="http://developer.download.nvidia.com/opengl/specs/WGL_ARB_pixel_format.txt"]]
|
|
[28:39][Run the game, see nothing on the screen and investigate why]
|
|
[29:24][handmade_opengl.cpp: Make OpenGLRenderCommands() pass GL_DEPTH_BUFFER_BIT to glClear()]
|
|
[31:56][Run the game to see that we're getting Z-tested drawing]
|
|
[32:42][Blackboard: Preventing fully transparent pixels from entering the Z-buffer]
|
|
[36:25][handmade_opengl.cpp: Make OpenGLRenderCommands() enable and call glAlphaFunc()[ref
|
|
site="docs.GL"
|
|
page="glAlphaFunc"
|
|
url="http://docs.gl/gl2/glAlphaFunc"]]
|
|
[38:24][handmade_opengl.cpp: Temporarily make glAlphaFunc() operate for alpha values greater than 0]
|
|
[39:04][Blackboard: No blending if sprites happen to be drawn in the wrong order]
|
|
[42:06][handmade_opengl.cpp: Make OpenGLRenderCommands() call glDepthFunc()[ref
|
|
site="docs.GL"
|
|
page="glDepthFunc"
|
|
url="http://docs.gl/gl2/glDepthFunc"]]
|
|
[43:19][Run the game to see that the drawing order is being respected, but that the sort is unstable]
|
|
[46:05][Determine to process the Z-values[ref
|
|
site="Unspecified Behaviour"
|
|
page="Calculating the gluPerspective matrix and other OpenGL matrix maths"
|
|
url="https://unspecified.wordpress.com/2012/06/21/calculating-the-gluperspective-matrix-and-other-opengl-matrix-maths/"]]
|
|
[50:46][Blackboard: Near and Far Clip (Planes)]
|
|
[53:50][Blackboard: Mapping the Z-values in the correct direction to the -1 to 1 range]
|
|
[56:27][Blackboard: Determining the structure of the mapping function]
|
|
[59:08][Blackboard: Solve these equations for a and b]
|
|
[1:02:11][Blackboard: Verify these equations]
|
|
[1:08:49][Blackboard: Solve the equations again, passing in the correct values]
|
|
[1:17:44][handmade_math.h: Make PerspectiveProjection() compute d and e to pass to the matrix]
|
|
[1:19:02][Run the game to see the finer grained Z-fighting]
|
|
[1:20:03][handmade_render_group.cpp: Enable PushBitmap() to increase the sprites' height relative to their Z]
|
|
[1:22:52][Run the game to see the slanted sprites, and consider why we must take the camera into account for shearing]
|
|
[1:25:03][handmade_render_group.cpp: Make PushBitmap() also modify the sprites' Y and X values]
|
|
[1:27:21][Consider using the camera's relative position to compute these modifications]
|
|
[1:28:48][Q&A][:speech]
|
|
[1:29:20][@ratchetfreak][When adjusting the sprite like that, don't you need to interpolate the texture coordinates in screenspace instead of clipspace (the default)?]
|
|
[1:30:29][@macielda][What is Alpha to Coverage? Any good references on that?]
|
|
[1:31:48][@k1ng_k3v1n][Would an orthogonal projection matrix be applicable for your game?]
|
|
[1:32:19][@sharlock93][Is the -n and -f because OpenGL has the camera on the negative -z?]
|
|
[1:33:06][@magik603][Why are you using legacy OpenGL?]
|
|
[1:34:49][@cvaucher][Do you typically use an infinite far plane for increased precision? Shawn McGrath mentioned it in his stream awhile back]
|
|
[1:36:20][@macielda][Would it be simpler to use Orthographic transforms for upright objects? Are you not simply undoing the Perspective Projection there?]
|
|
[1:37:28][@pepevel][Would it be possible to use a shader to do the Z-buffer rendering?]
|
|
[1:40:17][@sharlock93][So the near and far plane are linearly mapped. I have read somewhere where the mapping is not linear, in which case do we not make them linear?]
|
|
[1:43:13][Blackboard: Accounting for the -z in our coefficients]
|
|
[1:48:15][Consult the OpenGL spec[ref
|
|
site="OpenGL"
|
|
page="The OpenGL Graphics System: A Specification (v2.0)"
|
|
url="https://hippo.nipax.cz/docs/glspec20.pdf"]]
|
|
[1:52:24][@sharlock93][Oh yeah, sorry, I mixed two things up]
|
|
[1:52:34][Blackboard: Computing a and b, accounting for the -z]
|
|
[2:02:30][handmade_math.h: Try to make PerspectiveProjection() compute the non-perspective corrected terms for orthographic]
|
|
[2:05:23][End it there][:speech]
|
|
[/video]
|