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

135 lines
12 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[video output=day580 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Investigating Octahedral Interpolation" vod_platform=youtube id=8PxkSisBp3I annotator=Miblo]
[0:03][Recap and set the stage for the day streamlining the :lighting system, operating directly in the octahedral map, and hook up the light convection][:speech]
[4:58][Determine to hook up the bounce-based light convection][:lighting :speech]
[6:02][Demo the current state of the :lighting][:"debug visualisation" :run]
[7:57][On assuming we have a bug, and not rationalising away by manufacturing an explanation that the code is correct][:speech]
[13:16][Determine to investigate the octahedral interpolation][:"debug visualisation" :lighting :run]
[15:50][Prevent GenerateRoom() from varying the floor height][:"procedural generation"]
[16:54][Take a close look at the apparent square :lighting falloff artifact][:"debug visualisation" :run]
[21:25][Try making SumLight() in CompileZBiasProgram() overwrite the top-level voxel with the value of the first bottom-level voxel][:lighting]
[21:58][Note the weird shape of our angular falloff][:"debug visualisation" :lighting :run]
[23:19][Scrutinise SumLight() in CompileZBiasProgram() for anything that may affect the angular falloff][:lighting :research]
[25:41][Try making SumLight() in CompileZBiasProgram() lookup into the octahedral light map at a known location][:lighting]
[26:10][Find no interpolation variance while moving the :camera][:"debug visualisation" :lighting :run]
[26:43][Revert SumLight() in CompileZBiasProgram() to interpolate the full voxel hierarchy][:lighting]
[26:50][Find that our :lighting interpolates coherently, which suggests that our weirdness is coming from the octahedral light map][:"debug visualisation" :run]
[28:15][Revert SumLight(0 in CompileZBiasProgram() to lookup into the octahedral light map in the correct direction][:lighting]
[28:21][Take a close look at the octahedral-shaped :lighting falloff artifact, in conjunction with Jeff Knox's octahedral unwrapping visualisation in Desmos[ref
site=Desmox
page=Octahedral
url=https://www.desmos.com/calculator/sayie6xbgl]][:"debug visualisation" :run]
[33:31][Disable interpolation in OpenGLChangeToSettings()][:lighting]
[34:45][See a hard-edged artifact][:"debug visualisation" :lighting :run]
[35:21][Set up to make EndLightingComputation() copy known values to the border rows][:lighting]
[37:09][See no change][:"debug visualisation" :lighting :run]
[37:18][Make OpenGLChangeToSettings() zoom out the light map viewer][:"debug visualisation" :lighting]
[38:18][View the light map][:"debug visualisation" :lighting :run]
[38:46][Make EndLightingComputation() copy known values to the border rows][:lighting]
[38:56][See the red and green lines in the light map viewer, but not in the game][:"debug visualisation" :lighting :run]
[39:46][Enable interpolation in OpenGLChangeToSettings()][:lighting]
[40:15][See our red and green, but not at the artifact edges][:"debug visualisation" :lighting :run]
[40:33][Disable interpolation in OpenGLChangeToSettings()][:lighting]
[40:41][Consider our artifact to occupy the interior of the octahedral light map][:"debug visualisation" :lighting :run]
[40:52][Make EndLightingComputation() copy known values to the border columns][:lighting]
[41:35][See the yellow and cyan lines in the light map viewer, but not in the game][:"debug visualisation" :lighting :run]
[41:54][Enable interpolation in OpenGLChangeToSettings()][:lighting]
[42:02][See our yellow and cyan, but not at the artifact edges][:"debug visualisation" :lighting :run]
[42:17][Disable interpolation in OpenGLChangeToSettings()][:lighting]
[42:22][Consider our copy operation not to be implicated][:"debug visualisation" :lighting :run]
[43:08][Try making SumLight() in CompileZBiasProgram() overwrite the top-level voxel with the value of the first bottom-level voxel][:lighting]
[43:30][Clearly view our diamond-shaped artifact][:"debug visualisation" :lighting :run]
[47:28][Make OpenGLChangeToSettings() zoom out the light map viewer][:"debug visualisation" :lighting]
[47:38][See no especially bright areas in the light map viewer][:"debug visualisation" :lighting :run]
[48:06][Pan around the light map for our expected bright areas][:"debug visualisation" :"hot reloading" :lighting :programming :run]
[53:15][See two identical neighbouring values in the light map][:"debug visualisation" :lighting :run]
[54:45][Continuities][:lighting :run]
[55:58][Enable interpolation in OpenGLChangeToSettings()][:lighting]
[56:14][Discontinuities in the rate of change][:"debug visualisation" :lighting :run]
[58:23][Toggle on EDGE_COLORING in EndLightingComputation()][:"debug visualisation" :lighting]
[58:30][Disable interpolation in OpenGLChangeToSettings()][:lighting]
[58:40][Recall that the artifact is not on an edge copy][:"debug visualisation" :lighting :run]
[1:00:17][Make EndLightingComputation() write purple structured art into the interior of the octahedral light map, with thanks to Mike Biddlecombe][:"debug visualisation" :lighting]
[1:01:29][See a great swathe of purple, revealing that the artifact is from the interpolation between texels][:"debug visualisation" :lighting :run]
[1:02:53][Make EndLightingComputation() write a 3×3 structured art matrix in the octahedral light map][:"debug visualisation" :lighting]
[1:05:41][View our structured art][:"debug visualisation" :lighting :run]
[1:06:14][Enable interpolation in OpenGLChangeToSettings()][:lighting]
[1:06:22][See our bilinear interpolation artifact, and consider trying radial interpolation][:"debug visualisation" :lighting :run]
[1:09:06][Make EndLightingComputation() blank out the central texel of our 3×3 matrix][:"debug visualisation" :lighting]
[1:09:19][See the bilinear interpolation artifacts radiating from the centre][:"debug visualisation" :lighting :run]
[1:10:12][Consider writing our own radial interpolation in CompileZBiasProgram(), seeing what Texture Lookup Functions are available in OpenGL 3.2[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]][:lighting :research]
[1:14:52][Embark on implementing our own radial interpolation routine in CompileZBiasProgram()][:lighting]
[1:19:50][Bilinear Fudge][:blackboard :lighting :mathematics]
[1:22:06][Fudging Bilinear to be Radial][:blackboard :lighting :mathematics]
[1:28:41][Graph our radial interpolation equation in Desmos[ref
site=Desmos
page="Untitled Graph"
url=https://desmos.com/calculator]][:lighting :mathematics :research]
[1:55:28][Understanding our radial discontinuity][:blackboard :lighting :mathematics]
[1:57:33][Hack our radial interpolation equation in to 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]][:lighting :mathematics]
[2:05:36][With the radial interpolation toggled off, see our bilinear interpolation artifacts][:"debug visualisation" :lighting :run]
[2:06:07][Manually reproduce the bilinear interpolation in CompileZBiasProgram()][:lighting :mathematics]
[2:07:17][Bilinear Interpolation][:blackboard :lighting :mathematics]
[2:10:17][Toggle on and complete our manual interpolation path 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]][:lighting :mathematics]
[2:12:17][Hit and fix shader validation errors][:lighting :mathematics :programming :run]
[2:13:36][See our manual bilinear interpolation artifacts][:"debug visualisation" :lighting :run]
[2:14:10][Toggle off our manual interpolation path in CompileZBiasProgram()][:lighting :mathematics]
[2:14:16][See a difference between our and OpenGL's bilinear interpolation][:"debug visualisation" :lighting :run]
[2:15:26][Offsetting our manual bilinear interpolation][:blackboard :lighting :mathematics]
[2:16:24][Offset our manual bilinear interpolation back by half a pixel in CompileZBiasProgram()][:lighting :mathematics]
[2:16:48][See no difference between our and OpenGL's bilinear interpolation][:"debug visualisation" :lighting :programming :run]
[2:17:35][Toggle on our radial interpolation in CompileZBiasProgram()][:lighting :mathematics]
[2:18:19][See our radial falloff][:"debug visualisation" :lighting :run]
[2:18:45][Toggle off our manual interpolation path in CompileZBiasProgram()][:lighting :mathematics]
[2:18:55][See OpenGL's bilinear interpolation artifact return][:"debug visualisation" :lighting :run]
[2:19:01][Toggle on our manual interpolation path in CompileZBiasProgram()][:lighting :mathematics]
[2:19:06][Take a close look at our radial interpolation][:"debug visualisation" :lighting :run]
[2:19:39][Let EndLightingComputation() produce real :lighting values in our 3×3 structured art matrix][:lighting]
[2:19:49][Perceive but prefer our radial interpolation discontinuities][:"debug visualisation" :lighting :run]
[2:20:14][Revert SumLight() in CompileZBiasProgram() to interpolate the full voxel hierarchy][:lighting]
[2:21:01][View our smoothly interpolated :lighting][:"debug visualisation" :run]
[2:21:46][Revert CompileZBiasProgram() to modulate the world's real colours with light][:lighting]
[2:21:55][View our really lit world][:lighting :run]
[2:22:16][Q&A][:speech]
[2:22:50][@devsigner][Q: Why is the :lighting behind the character so dark? Shouldn't a point light be more round?]
[2:24:03][@somebody_took_my_name][Q: For a look at Desmos: see 'Untitled Graph'[ref
site=Desmos
page="Untitled Graph"
url=https://www.desmos.com/calculator/2yex0yzdk5]][:mathematics]
[2:26:28][@centhusiast][Q: How fast is this :lighting method when we compile in debug mode?]
[2:26:56][@jessem3y3r][Q: I have to say that your debug videos are often more educational than implementation-heavy ones. Very insightful into your process. Thanks!]
[2:28:38][@xrxr13579][Q: Is octahedral :lighting the only way to go for what you want?]
[2:29:32][@philliptrudeau][Q: Once you take depth samples, could you do bounce :lighting by fetching the depth sample and then moving that far down the normal to seek directly to the next voxel?]
[2:30:26][@somebody_took_my_name][Q: Sorry that was just a temp graph, I hadn't saved it. But now with an account and all, the permanent link (I guess) is here[ref
site=Desmos
page="Four pixel interpolation"
url=https://www.desmos.com/calculator/qmephgc1p5]][:mathematics]
[2:31:36][@kniffel5][Q: Could you do a stream on RAD's Telemetry[ref
site="RAD Game Tools"
page="Telemetry Performance Visualization System"
url=http://www.radgametools.com/telemetry.htm] one day, showing all the things you can do with it? I'm really interested in the tool, but the only good video source on it is [@naysayer88 Jon Blow], and his streams aren't very "tutorial-y" by nature!]
[2:33:23][@philliptrudeau][Q: With the octahedral map, both the bilinear filtering and the "puffy" filtering seemed to have a pretty quick falloff between samples. Would you consider doing something like bi-cubic filtering for a smoother blend?][:lighting]
[2:37:08][@centhusiast][Q: Do you you use any equation for the light density attenuation?][:lighting]
[2:37:29][@kniffel5][Q: Thanks! Do you know if RAD has discounts for students?]
[2:38:37][@centhusiast][Q: Yes, I meant intensity attenuation?]
[2:39:28][@xrxr13579][Q: Would you ever go back to RAD?]
[2:40:06][@mattiamanzati][Q: Does the paper from nVidia about octahedral sampling[ref
title="Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields"
author="Jean-Philippe Guertin, Derek Nowrouzezahrai, Morgan McGuire"
url=http://jcgt.org/published/0008/02/01/] cover also the sampling filter, or did they just use linear and bump up the size of the bitmap to have more samples?][:lighting]
[2:47:47][@roblovski][Q: When doing game logic, do you think it's ever a good idea to write in async / await style and have that transformed into a state machine?]
[2:50:36][@xrxr13579][Q: Thoughts on the ML family of languages and tagged unions?][:language]
[2:51:18][@centhusiast][Q: Do you know about the inverse distance weight interpolation method? Do you think it can be used for games?]
[2:51:34][@nickito97][Q: What do you think of C++20 modules and, separately, of constexpr in C++ in general?][:language]
[2:51:56][@cyberimmersion][Q: I've only really focused much on python, and I'm trying to learn another :language. What do you think of Golang?]
[2:52:08][Wind it down][:speech]
[/video]