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

59 lines
5.0 KiB
Plaintext
Raw Normal View History

[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Adjusting Sprite Cards to Counter Projection" vod_platform=youtube id=0h916hXePbw annotator=Miblo]
[0:02][Recap and set the stage for the day]
[1:07][handmade_math.h: Make PerspectiveProjection() set the near clip plane to a positive value and perform some test multiplications]
[3:58][Step into PerspectiveProjection() and inspect Test0 and Test1]
[6:42][Blackboard: Check our clip plane equations]
[12:29][handmade_math.h: Swap the perspective and non-perspective code in PerspectiveProjection(), step into it and inspect Test0 and Test1 again]
[16:42][Blackboard: Solving for d and e]
[22:04][handmade_math.h: Make PerspectiveProjection() compute Test0 and Test1 using negated n and f, step into it and inspect them again]
[23:37][handmade_math.h: Switch PerspectiveProjection() to use the perspective correct equation, step in and inspect the Test0 and Test1]
[24:42][Blackboard: Checking the math for the perspective correct terms]
[33:32][handmade_math.h: Simplify the d term for the perspective correct equation]
[34:43][Blackboard: Solving for d and e in the perspective correct clip plane equations]
[38:51][handmade_platform.h: Rename w to __ in the v3 union]
[40:48][Step into PerspectiveProjection() and inspect Test0 and Test1]
[42:06][Run the game to see that we're back in business]
[43:30][handmade_render_group.cpp: Make PushBitmap() tilt upright sprites and run the game]
[44:40][Reflect on our unwitting correctness]
[47:27][Blackboard: Sprite Cards]
[51:24][Run the game to demo the squatness of the trees]
[53:41][Blackboard: Producing the sprites' depth and height using the camera's relative position]
[55:18]["Watch this point"][quote 551]
[59:14][Blackboard: Approaching this problem using ray intersections]
[1:03:08][Blackboard: Solving for ray intersects ray]
[1:09:02][Blackboard: Simplifying this down]
[1:12:56][Blackboard: Handling the case when the vectors are parallel]
[1:20:13][Blackboard: Determining the conditions under which this equation is unsolvable]
[1:23:29][handmade_math.h: Introduce RayIntersect2()]
[1:27:01][Blackboard: Producing a ta that goes with the same denominator]
[1:39:43][handmade_math.h: Make RayIntersect2() compute ta and tb using the same denominator]
[1:43:21][Try to solve our equations using an online tool]
[1:48:07][handmade_render_group.cpp: Make PushBitmap() compute and call RayIntersect2() on the camera and card positions]
[1:54:22][handmade_render_group.h: Add CameraP, CameraX, CameraY and CameraZ to the render_group struct]
[1:57:56][handmade_render_group.cpp: Make SetCameraTransform() take the Camera position values]
[2:01:17][Run the game to see that it is not nearly as messed up as expected]
[2:02:07][Q&A][:speech]
[2:03:09][@quikligames][There was a lot of chat about Wolfram expecting 1-letter variable names and interpreting rbx as r * b * x]
[2:03:23][@billdstrong][Didn't we do this math when doing the screen projection?]
[2:04:12][@Miblo][Do you think we needed an epilepsy warning there?]
[2:04:44][@pepevel][Hello, yesterday I was asking about shaders and the z-buffer. Could I rephrase the question? It will be the last time]
[2:05:00][@macielda][Maybe if you swap the order of the sum on 'tb = ...' you get an equation more similar to 'ta = ...'?]
[2:05:26][handmade_math.h: Try swapping the order of the sum in RayIntersect2()]
[2:06:03][@vaualbus][Can you show again the equation?]
[2:07:11][@zennmystic][Is the stream weekends only now or is it temp thing?]
[2:07:31][@insobot][1935 is Molly Rocket's upcoming volitional fiction game, set in the criminal underworld of New York City in the 1930s[ref
site="Molly Rocket"
page="Announcing 1935!"
url="http://mollyrocket.com/news_0023.html"]]
[2:07:37][@pepevel][As Handmade Hero is a 2D game, my idea would be to treat the z variable not as the z coordinate but as a variable that the pixel shader will use to kill hidden pixels and do alpha blending with the GPU power]
[2:10:28][@macielda][Are you doing this so you can mix perspective projection and orthographic projection for game objects?]
[2:11:31][@rooctag][Now we have the alpha issue with the 3D stuff, is this easier to fix than the 2D sort because you already know how to fix that?]
[2:13:32][@vaualbus][This could be the solutiun at least for Matlab: \[ta = -(Pax*rby - Pay*rbx - Pbx*rby + Pby*rbx)/(rax*rby - ray*rbx), tb = -(Pax*ray - Pay*rax - Pbx*ray + Pby*rax)/(rax*rby - ray*rbx)\]]
[2:17:57][handmade_render_group.cpp: Make PushBitmap() use CardRyz to set the YAxis]
[2:18:24][Run the game to see that we're surprisingly good]
[2:20:01][@macielda][It seems like @vaualbus' solution is negated in relation to yours]
[2:23:14][handmade_render_group.cpp: Enable PushBitmap() to produce a standard sprite card and run the game to see that]
[2:25:14][handmade_opengl.cpp: Temporarily make OpenGLRenderCommands() clip out all transparent pixels, and run the game]
[2:27:47][Consider addressing transparency in the sort, and close it down][:speech]
[/video]