[video output=day503 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Constructing a Camera Easing Function" vod_platform=youtube id=bOJC2uiBBJM annotator=Miblo]
[0:00][Set up to work on :camera functionality][:run]
[5:27][Meaningful Fog and AlphaClip parameters][:camera :speech]
[9:18][Fading floors and moving the :camera][:blackboard]
[11:52][Return from OBS crash][:admin]
[13:15][Defining our :camera clipping boundaries][:blackboard]
[14:02][Reacquaint ourselves with the fogging and alpha clipping code in CompileZBiasProgram()][:camera :hardware :rendering :research]
[18:28][Parameterising our fogging and alpha clipping][:blackboard]
[19:13][Augment game_camera with ExpectedFloorAtZ on which to base our fog and alpha clip parameters][:camera]
[25:47][Check out our heavily fogged orphanage][:camera :run]
[26:55][Augment game_state with Alpha and Fog parameters for our in-game :camera editor to use][:ui]
[35:20][Try out our new fog and alpha controls][:camera :run :ui]
[35:47][Move the Alpha and Fog from game_state into game_mode_world, and add ExpectedFloorZ to our :UI][:camera]
[41:49][Try out our :camera editor :UI][:run]
[43:41][Swap AlphaMax and AlphaMin in UpdateAndRenderWorld()][:camera]
[44:10][See that the alpha fade is being applied in :camera space, not world space][:run]
[44:42][Rename FogMax and AlphaMax to FogSpan and AlphaSpan respectively][:camera]
[46:16][Find that FogMin is not working as expected][:camera :run]
[47:17][See how the Fog is computed in CompileZBiasProgram()][:camera :hardware :rendering :research]
[49:26][Remove the NearClipPlane from the Alpha computation in SetCameraTransform()][:camera :rendering]
[50:06][Continue to investigate our Fog computation in CompileZBiasProgram()][:camera :hardware :rendering :research]
[51:11][Fog premultiplied alpha in CompileZBiasProgram()][:camera :hardware :rendering :research]
[54:37][Make CompileZBiasProgram() correctly blend the fog using premultipled alpha][:camera :hardware :rendering]
[55:08][][:speech][quote 641]
[55:16][Hit our "Shader validation failed" assertion in OpenGLCreateProgram()][:hardware :rendering :run]
[55:26][Fix CompileZBiasProgram() to only multiply in the alpha in the Lerp() call][:hardware :rendering]
[55:41][Adjust our fogging parameters to try and make sense of them][:camera :run]
[59:06][Bracketing the alpha clip and fogging to contain the player][:blackboard :camera]
[59:44][Expand our notion of :camera focus in game_camera to represent a range, for UpdateCameraForEntityMovement() to set]
[1:06:08][Find that our ExpectedFloorMinZ is not as expected][:camera :run]
[1:08:10][Fix the EntityFocusZ computation in UpdateCameraForEntityMovement()][:camera]
[1:08:37][Find that the bracket is set correctly, but the alpha is wrong][:camera :run]
[1:09:12][Fix the FocusMinZ and FocusMaxZ computations in UpdateAndRenderWorld()][:camera]
[1:09:23][Find that our AlphaClip and Fog bracket works beautifully][:camera :run]
[1:09:51][Proactive :camera interpolation][:speech]
[1:13:02][Interpolation functions][:blackboard :mathematics]
[1:15:16][Position our hero in her bedroom][:"procedural generation"]
[1:16:37][Traverse the orphanage between rooms][:run]
[1:16:59][Change the :camera only to interpolate positions when we change rooms][:mathematics]
[1:18:28][Traverse the orphanage to trigger :camera interpolation][:mathematics :run]
[1:19:32][Make UpdateCameraForEntityMovement() trigger :camera interpolation, keeping track of the FromP and TargetP, and using a tInterpolation value][:mathematics]
[1:22:22][Find that our :camera interpolation is linear][:mathematics :run]
[1:22:41][Make UpdateCameraForEntityMovement() use the Square function to interpolate the :camera][:mathematics]
[1:23:43][Check out our Squared :camera interpolation][:mathematics :run]
[1:23:53][Make UpdateCameraForEntityMovement() use the SquareRoot function to interpolate the :camera][:mathematics]
[1:24:02][Check out our Square rooted :camera interpolation][:mathematics :run]
[1:24:37][Interpolation functions[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics :research]
[1:30:00][Understanding rates of change, and polynomials[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics :research]
[1:37:39][Shaping our desired interpolation curve[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics :research]
[1:40:02][Bézier curves][:blackboard :mathematics]
[1:51:17][Plug our derivatives into Desmos[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics :research]
[1:54:35][Make UpdateCameraForEntityMovement() interpolate the :camera using our ease-in-ease-out function][:mathematics]
[1:55:43][Check out our :camera interpolation][:mathematics :run]
[1:56:32][Q&A][:speech]
[1:57:13][@xxthebigfoxx][Q: The site actually had support for variables. It was giving you a slider to edit the values][:mathematics]
[1:57:30][Try to use variables in a Desmos function[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics :research]
[2:01:09][@pythno][Q: Could we also describe the easy-in / -out via a sine function?][:mathematics]
[2:01:46][@garethhubball][Q: I noticed that you used t*t*t for t cubed. Does C have support for something like t**3 for exponents?][:language]
[2:03:03][@areriff][Q: Have you tested the new transition going up and down the stairs?][:camera :mathematics]
[2:04:21][@abarishu][Q: By setting the u and v values to negative, you can get things like "overshoot" where the :camera goes over and then corrects back. I don't think it will be a good feel in [~hero Handmade Hero]'s case, but for some cases that is really good][:mathematics]
[2:04:29][Try making UpdateCameraForEntityMovement() interpolate the :camera using an overshooting function[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator]][:mathematics]
[2:07:50][Check out our overshooting :camera][:run]
[2:08:38][Revert UpdateCameraForEntityMovement() to perform an ease-in-ease-out :camera interpolation][:mathematics]
[2:09:17][Save our Desmos curve[ref
    site=Desmos
    page="Graphic Calculator"
    url=https://www.desmos.com/calculator/wse2o5kqpl]][:research]
[2:11:38][It's been a pleasure][:speech]
[/video]
