[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Adding Simple Lighting" vod_platform=youtube id=9iivQoWdsFk annotator=Miblo] [0:10][Recap and set the stage for the day, with a mention of @mtsmox's discovery of that problem with our depth enable] [1:21][A few words on the month-long failure of Google Drive to download the HandmadeCon videos] [2:21][Blackboard: Multisampled Depth Peeling] [7:21][Run the game to show off the artifact-free smoothing] [10:07][Blackboard: Splitting the min and max depth to perform the depth peeling] [11:32][Run the game, consider packing the new art into a texture atlas, and determine to get some lighting in] [18:10][Blackboard: In Graphics, Light = Photons] [21:53][Blackboard: Off-line rendered lighting, as a probabilistic sampling problem] [25:37][Blackboard: Real-time rendered lighting, and falloff] [32:57][Blackboard: Falloff affected by Distance, and the inverse square law] [40:16][Blackboard: Perceivable Brightness, and the projection equation as the inverse of the photon spread equation] [44:42][Blackboard: Falloff affected by Participating Media, e.g. dust, air, water droplets] [48:21][Blackboard: Falloff affected by Reflection] [55:53][Blackboard: Surface Diffusiveness] [1:04:05][Blackboard: Cosine falloff, affected by the angle at which photons hit a surface] [1:07:16][Blackboard: Regional lighting, as in Stardew Valley] [1:11:22][Blackboard: Normal mapped lighting, as created by Sprite Lamp[ref site="YouTube" page="Sprite Lamp Trailer" url="https://www.youtube.com/watch?v=fy3FvPg01w0"]] [1:13:25][handmade_opengl.cpp: Add a regional light source in CompileZBiasProgram()[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"]] [1:20:08][Run the game to see our light source] [1:22:00][handmade_opengl.cpp: Create a second, brighter light in CompileZBiasProgram()] [1:23:05][Run the game to see our two lights, and note that we may want to pre-compute the lights into a voxel grid] [1:25:04][Consider using the facing direction of our surfaces to improve the lighting] [1:27:19][Blackboard: Light scattering, and cosine falloff] [1:31:02][Practical experiment: Glancing light off a piece of paper] [1:32:50][Blackboard: Surface normal] [1:33:49][handmade_platform.h: Add N to textured_vertex] [1:35:02][Blackboard: Using the cross product to produce normals] [1:35:43][handmade_render_group.cpp: Make PushQuad() produce the surface Normal] [1:39:53][handmade_opengl.cpp: Enable UseProgramBegin() to use that Normal] [1:42:35][handmade_opengl.cpp: Make OpenGLCreateProgram() take an opengl_program_common to write into directly] [1:46:43][Step in to UseProgramBegin() to see if anything looks weird] [1:48:23][handmade_opengl.cpp: Insert space for the normals in the Vertex arrays] [1:49:15][Q&A][:speech] [1:49:49][@soysaucethekid][For the lighting of the sprites, do you need to compensate for the angle offset if it's using the same light source as the terrain?] [1:51:00][@AsafGartner][There seems to be a lot of banding around the lights] [1:52:19][handmade_opengl.cpp: Try to make OpenGLInit() use a full floating point resolution back buffer] [1:56:15][handmade_opengl.cpp: Try to make OpenGLRenderCommands() enable GL_DITHER] [2:00:30][@flyingsolomon][As our hero does not represent the actual hero that saves our lives every day all over the world, I took liberty and made some corrections to the game art...] [2:00:53][@stashiocat][What kind of rendering pipeline does this use? Forward? Deferred? Both?] [2:01:24][@graeme7][is the debug text being lighted?] [2:01:29][@mtsmox][Use sampler with shift key pressed to get info window] [2:01:40][@flyingsolomon][I miss the little line showing the current filename inside 4coder. It was easier to follow that way] [2:02:08][@areriff86][How expensive it will be if the light source is moving, for example, following the torch that hero could be carrying or the flying light projectile?] [2:03:01][@uplinkcoder][Update CodeXL. It will not be able to step into the shader, but you should be able to see the OpenGL state] [2:03:33][Wind it down, with the determination to investigate the banding, noting that the light moves with the hero][:speech] [/video]