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

97 lines
6.9 KiB
Plaintext

[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Introduction to Vertex and Fragment Shaders" vod_platform=youtube id=GtNvxxl3AK4 annotator=Miblo]
[0:01][Recap and set the stage for the day]
[2:21][Blackboard: Shaders[ref
site="Handmade Hero Episode Guide"
page="Filling Rotated and Scaled Rectangles"
url=https://hero.handmade.network/episode/code/day092][ref
site="Handmade Hero Episode Guide"
page="Packing Pixels for the Framebuffer"
url=https://hero.handmade.network/episode/code/day117][ref
site="Handmade Hero Episode Guide"
page="Passing Rotation and Shear to the Renderer"
url=https://hero.handmade.network/episode/code/day275]]
[3:22][Blackboard: How hardware does pixel processing vs how we did it in software with SIMD]
[7:38][Blackboard: Processing a 4x4 square of 16 pixels at a time, also called "warp"]
[10:56][Blackboard: Writing a pixel shader, with the understanding that everything operates on many pixels at once]
[15:55][Blackboard: Leveraging the capabilities of the hardware]
[19:49][Blackboard: An example illustrating the need to understand the ramifications of operating wide]
[24:50]["You're going down"][quote 556]
[27:27][Blackboard: "Fragment" shader]
[30:15][Blackboard: "Vertex" shader]
[33:36][handmade_opengl.cpp: Make OpenGLCreateProgram() check GL_LINK_STATUS and GL_COMPILE_STATUS rather than GL_VALIDATE_STATUS[ref
site="Khronos"
page="glcorearb.h"
url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[35:48][Run the game and successfully receive compile errors]
[36:08][Note that Martins pointed out that multiline strings are supported in Visual Studio 2013[ref
site="cppreference"
page="string literal"
url="http://en.cppreference.com/w/cpp/language/string_literal"]]
[39:37][handmade_opengl.cpp: Introduce VertexCode and FragmentCode here docs in OpenGLInit()]
[41:09][Research the Core Language (GLSL) versioning[ref
site="OpenGL Wiki"
page="Core Language (GLSL)"
url="https://www.khronos.org/opengl/wiki/Core_Language_(GLSL"]]
[44:06][handmade_opengl.cpp: Set #version 130 in HeaderCode and run the game]
[44:33][The OpenGL Shading Language 1.50 Quick Reference Card[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"]]
[50:49][handmade_opengl.cpp: Sketch out a shader in VertexCode]
[53:20][The Built-in Inputs, Outputs and Constants]
[56:22][handmade_opengl.cpp: Enable the VertexCode to take the Transform, using a uniform]
[57:39][handmade_opengl.cpp: Start to enable OpenGLRenderCommands() to pass Transform to the shader]
[59:52][Blackboard: How the shader compiler references a uniform]
[1:02:47][handmade_opengl.h: Add GLSLTransformID to open_gl]
[1:03:39][handmade_opengl.cpp: Start to sketch out a shader in FragmentCode in conjunction with the OpenGL Shading Language 1.50 Quick Reference Card]
[1:06:26][Note that there is no colour value in the fragment language's gl_FragDepth]
[1:08:57][handmade_opengl.cpp: Continue sketching out the FragmentCode]
[1:10:03][handmade_opengl.cpp: Enable OpenGLRenderCommands() to setup a uniform matrix using glUniformMatrix4()]
[1:13:31][handmade_opengl.cpp: Make OpenGLRenderCommands() call glUseProgram() in order to actually run the shader]
[1:14:59][win32_handmade.cpp: Pull glGetUniformLocation(), glUniform4fv() and glUniformMatrix4fv() from glcorearb.h]
[1:19:02][handmade_opengl.cpp: Correctly declare main() in the shader code and run]
[1:21:19][Read about glGetProgram()[ref
site=docs.GL
page="glGetProgram"
url=http://docs.gl/gl3/glGetProgram]]
[1:21:42][handmade_opengl.cpp: Make OpenGLCreateProgram() only check GL_LINK_STATUS and run the game to see that it works]
[1:22:28][handmade_opengl.cpp: Make VertexCode set the InputVertex.w to 1.0 and run the game to see that the vertex shader is running]
[1:23:32][handmade_opengl.cpp: Enable VertexCode to perform a ZTransform]
[1:25:51][Run the game to see that we're getting the biasing we want]
[1:26:32][handmade_opengl.cpp: Rewrite the VertexCode more instructively]
[1:28:41][Run the game and reiterate what the VertexCode is doing, with a few words on its efficiency]
[1:30:17][handmade_opengl.cpp: Determine to enable FragmentCode to operate on textures]
[1:33:45][Blackboard: Variables in the fragment shader: "flat", "noperspective" and "smooth"]
[1:37:56][handmade_opengl.cpp: Enable the FragmentCode to sample from textures, using a uniform]
[1:41:39][Run the game and unexpectedly receive no error]
[1:41:50][handmade_opengl.cpp: Enable VertexCode to pass FragUV and FragColor out to the FragmentCode]
[1:45:03][Run the game ]
[1:45:08][handmade_opengl.cpp: Make VertexCode correctly set FragUV using gl_TexCoord\[0\].xy]
[1:47:51][Run the game in the belief that we're passing down everything we need]
[1:48:51][handmade_opengl.cpp: Make OpenGLRenderCommands() set a TextureSamplerID to pass to the FragmentCode shader]
[1:52:53][Research glUniform[ref
site=docs.GL
page="glUniform"
url=http://docs.gl/gl3/glUniform]]
[1:54:14][win32_handmade.cpp: Pull glUniformli() from glcorearb.h]
[1:56:17][Q&A][:speech]
[1:56:58][Fuss with OBS]
[1:59:45][@rbdjellyfish][Check your global settings]
[2:01:17][@0xdeadbeefh][Maybe just have one scene? So it can't switch]
[2:02:08][@rooctag][Now that we've gone OpenGL, do you still think the RaspberryPi option is still on the list?]
[2:02:59][@macielda][Would you show us the code for what you have done in the last 2-4 minutes?]
[2:03:16][handmade_opengl.cpp: Recap the FragmentCode here doc, and setting the TextureSamplerID]
[2:06:22][@wgg25][gl_TexCoord is an output from the vertex shader, which is why everything is black, you should use gl_MultiTexCoord0 (no brackets)]
[2:06:40][handmade_opengl.cpp: Make the VertexCode use gl_MultiTexCoord0 to specify the FragUV, and run the game to see that it works]
[2:07:09][handmade_opengl.cpp: Remove the setting of TexSample.a to 1.0 from the FragmentCode, and run the game to see what we expect to get]
[2:09:12][@miblo][Are you receiving the Qs from HMN IRC/#hero? Your usual invocation of !qa didn't appear there today]
[2:09:41][@rooctag][You mentioned the new assets will not be rectangular like the current assets. Do we need to update the asset pipeline for this?]
[2:11:02][@abarishu][Are we completely dropping support for the software renderer now?]
[2:11:36][@rooctag][I mean the hero head vs body vs cape are all the same shape]
[2:11:59][@macielda][Can you explain with a little bit more detail about how the Z-bias thing works? I'm not sure I understand it]
[2:12:12][Blackboard: How the Z-bias prevents sprites from intersecting]
[2:18:01][@abarishu][So we are going to implement some form of Z-buffer in software?]
[2:18:19][@macielda][The key part for me was that the Z is only used for the ZBuffer and the W does the perspective divide, thanks]
[2:19:20][Go ahead and close it down with the determination to upgrade the graphics card][:speech]
[/video]