[video output=day399 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Creating a CPU-side Lighting Testbed" vod_platform=youtube id=4LEFWEbrnPc annotator=Miblo]
[0:09][Recap and set the stage for the day, with a few words on loadable shaders and heredoc indentation]
[2:45][handmade_opengl.cpp: Try out @mmozeiko's idea to put a closing quote before the heredoc text]
[3:41]["Unfortunately it looks like here 4coder is too smart for us"][quote 588]
[4:27][Spec out a possible string opener for 4coder to understand]
[5:31][@mmozeiko][Oh, that worked: __blablaFOO]
[5:37][handmade_opengl.cpp: Play further with the heredoc stuff, before admitting defeat for now with thanks to @mmozeiko]
[7:19][Run the game to see where we last left off, noting that we are perhaps taking an unproductive approach in developing the system for the GPU]
[11:35][Switch our development of the lighting system to the CPU-side]
[13:53][handmade_render_group.cpp and handmade_world_mode.cpp: Introduce LightingTest() in order to enable UpdateAndRenderWorld() to hijack the RenderGroup]
[19:16][Run the game to see our sprites]
[19:40][handmade_render_group.cpp: Enable LightingTest() to edit the vertices]
[21:45][Run the game to see a completely whitewashed screen]
[22:58][handmade_render_group.cpp: Introduce struct lighting_element]
[26:12]["Don't scratch your eye"][quote 589]
[26:35][handmade_render_group.cpp: Make LightingTest() initialise an array of lighting_element]
[27:35][Blackboard: Extracting the vertex data of sprites]
[28:44][handmade_render_group.cpp: Enable LightingTest() to copy that vertex data in to the Elements array]
[33:13][Blackboard: Computing the radius]
[33:34][handmade_render_group.cpp: Fix compile errors in LightingTest()]
[34:57][Run the game and see no difference]
[35:03][handmade_render_group.cpp: Enable LightingTest() to copy the lighting back out to the quads in a diamond shape]
[40:35][Blackboard: Producing a full coordinate system from a vector for drawing out the lighting]
[46:20][handmade_render_group.cpp: Enable LightingTest() to produce that coordinate system and draw out the diamond]
[51:10][Run the game and see pure grey]
[51:22][handmade_render_group.cpp: Investigate what LightingTest() is drawing]
[54:08][handmade_render_group.cpp: Replace V0 and V2 with Vert0 and Vert2 in LightingTest()]
[55:25][Run the game to determine that it's probably the pack that is incorrect]
[56:07][handmade_render_group.cpp: Make LightingTest() multiply the RGBAUnpack4x8() and RGBAPack4x8() calls into the correct colour space]
[58:28][Run the game to see that we're getting a little closer]
[58:33][handmade_render_group.cpp: Continue to investigate the problem]
[59:30][Step in to LightingTest() and inspect the Vert0 and Element->RefC]
[1:00:52][handmade_render_group.cpp: Make LightingTest() work on Element when computing the lighting]
[1:01:06][Run the game to see that we're good to go]
[1:01:14][Step in to LightingTest() to inspect the positional values]
[1:02:05][handmade_render_group.cpp: Make LightingTest() correctly set the Y]
[1:02:18][Step in the LightingTest() and again inspect the positional values]
[1:02:50][handmade_render_group.cpp: Make LightingTest() correctly set the base]
[1:04:18][Step in to LightingTest() and inspect our expected positions]
[1:04:29][Run the game to see how we're doing]
[1:04:42][handmade_render_group.cpp: Make LightingTest() set the vertices in the same order as PushQuad()]
[1:05:53][Run the game to see our diamond reflectors]
[1:07:40][handmade_render_group.cpp: Toggle off the copying out of the lighting, and run the game to consider the pink and yellow debug rectangles]
[1:08:42][handmade_render_group.cpp: Try to make LightingTest() more sanely set the span for long, thin rectangles]
[1:12:07][Run the game to still see large pink rectangles]
[1:13:52][handmade_render_group.cpp: Make LightingTest() use the correct winding when copying the lighting in]
[1:14:24][Run the game to see that that fixes it, and consider this representation of the lighting]
[1:16:31][handmade_render_group.cpp: Introduce a moveable light source in LightingTest()]
[1:19:41][Run the game and move our light source]
[1:20:03][handmade_render_group.cpp: Enable LightingTest() to propagate the light in an O(n²) fashion]
[1:26:10][Run the game to see black, because the rendering is so slow]
[1:28:00][handmade_world_mode.cpp: Toggle off the particles and only create one screen]
[1:29:36][Run the game to see our room]
[1:29:52][handmade_world_mode.cpp: Reduce the room size in AddStandardRoom()]
[1:30:48][Run the game and move around our tiny room]
[1:31:34][handmade_render_group.cpp: Reenable our O(n²) loop and run the game to see our lit room]
[1:32:44][handmade_render_group.cpp: Change how LightingTest() sets the light colour]
[1:33:05][Run the game to see the disco lighting]
[1:33:28][handmade_render_group.cpp: Make LightingTest() clamp the emitters' colours]
[1:34:31][Run the game to still see a little flickering]
[1:34:47][handmade_render_group.cpp: Make LightingTest() sum into a separate colour accumulator]
[1:36:50][Run the game to see that it's somewhat incorrect]
[1:37:08][handmade_render_group.cpp: Make LightingTest() factor in the distance to the light]
[1:39:33][Run the game to see that it's still a little bit wonky]
[1:41:15][handmade_render_group.cpp: Make LightingTest() factor in the distance falloff]
[1:41:58][Run the game and consider that we may have too much angular flickering]
[1:43:19][handmade_render_group.cpp: Make LightingTest() propagate the light in three loops]
[1:44:13][Run the game to see a lot of flickering, and consider the sanity of developing on the CPU]
[1:45:01][handmade_render_group.cpp: Prevent LightingTest() from using the distance falloff, and only do one iteration]
[1:45:32][Run the game and wonder why lateral movement causes so much flickering]
[1:46:44][handmade_render_group.cpp: Consider where LightingTest() may be wrong]
[1:48:06][Q&A][:speech]
[1:49:07][@kim_jorgensen][Could you enable the overlay. Your head is in the way]
[1:49:35][Consult Microsoft Spy++ for the currently open programs]
[1:52:38][@mmozeiko][Sorry the trick didn't work, it works for editor I use. There is an option to try to use old non-raw string literals: char* shader = STRINGIFY( ... write multiline code here ... ); where STRINGIFY is macro with # preprocesor thing. Compiler will smush multi-line code into one-line string and you'll lose line numbers in error messages, but they don't seem to be used on stream anyway]
[1:53:44][handmade_opengl.cpp: Try to #define SHADER_CODE in an effort to enable 4coder to indent our shader code]
[1:58:28][@thecrypticmind][Hi! Not sure if this might be something for the forums, but I am on Day 60 and I just swapped to develop on my laptop and am noticing that I am missing the frame rate pretty frequently when Sleep is called: it misses with a few ms. My output log is not as smooth as yours with 33.33m/s every log message, but instead it fluctuates a bit over it. Is this something that gets addressed further down in the episodes?]
[1:58:44][@Brian][Did the black overlay disapear during the stream, or during Q&A? From the code, if TargetActive, we fade in the CornerWindow. But if the countdown has finished and what not, then it is not active any more]
[2:00:01][@mmozeiko][You can do char* shader = SHADER_CODE(n#include "shader.h"n); and then put code in new shader.h file, maybe then indentation will be fine afterwards]
[2:00:38][@mmozeiko][No, it will work]
[2:02:28][Close it down][:speech]
[/video]
