[video output=day098 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Normal Map Code Cleanup" vod_platform=youtube id=xWQfjqAHvxs annotator=dspecht annotator=Miblo]
[1:43][Off we go with a bit of a recap]
[3:51][Talk about MakeSphereNormalMap and GPU vs CPU renderer]
[4:54][Make TreeNormal for MakeSphereNormalMap to use]
[7:23][Get the game running, look at the unpacking of the NormalMap and change the way that it's packed]
[9:05][Blackboard: Consider the hacky nature of the problem]
[11:38][Blackboard: The Ground's normals]
[14:03][Handle front-facing bitmaps for now, starting by introducing UnscaleAndBiasNormal]
[16:21][Check it out in-game and look back through the code]
[17:28][Draw just the Normal and force Texel.a to be 1.0f]
[18:17][Step through the NormalMap code]
[19:14][Moment of realisation: We were still sampling out of the Texture]
[19:43][Continue stepping through the code]
[21:43][Moment of realisation: Usually you want to move to the next Pixel when you write one]
[22:13][Quickly check the maths]
[22:52][Blackboard: Nz should be Pythagorean theorem solved]
[24:39][Calculate Nz]
[25:11][Set the Normal and look at how the Pixels are packed]
[26:28][Step through the code]
[26:52][Blackboard: Dealing with the area outside the sphere]
[27:35][Introduce RootTerm]
[29:05][Check the values of the Normal]
[29:55][Take a look at it in-game and find some erroneously negative values]
[31:40][Owl of Shame Moment: Yesterday's code was awful]
[32:14][View the correct NormalMap]
[32:48][Recalculate Texel.rgb such that it is within the valid range of colours]
[34:23][Turn off the NormalMap and consider using something more defined than the tree bitmap]
[34:55][Temporarily draw TreeNormal as if it was a texture map]
[36:02][Set the Pitch correctly and introduce BilinearSample function]
[39:07][Check it out in-game and switch to the path in which the NormalMap modulates the texture]
[39:49][Light the texture with the NormalMap]
[41:22][Take a look at it in-game]
[41:48][Tackle the environment_map stuff]
[45:24][Blackboard: Picking from the environment map]
[47:51][Nullify the Middle sample and make SampleEnvironmentMap produce values we can use]
[55:33][Look forward to next week]
[56:28][Q&A][:speech]
[57:42][Recap today's cleaning up]
[58:21][@pseudonym73][When you lerp two normals, you probably won't get a normalised vector. There are a few things you can do about that. Would you briefly comment on your thoughts about this?]
[1:01:41][@chronaldragon][Q: how are we going to sample lights when calculating the pixel values for each sprite? Will there be a list of all the lights? Or will that be a parameter of some sort?]
[1:02:10][@ingenero][What ever happened to your almond milk?]
[1:02:27][@insofaras][Will Yangtian be making normal maps for the art now too?]
[1:02:51][@andsz_][Will you cover more advanced BRDFs? Or just simple phong-like lighting equations?]
[1:04:48][@panic00][What if I don't want my game to be just 'normal'? Are there any other kinds of maps I can use to make my game more unique?]
[1:06:25][@chronaldragon][Q: Some games use a 'bump-map' in addition or instead of a normal map. What is the difference between these and what are the advantages or disadvantages?]
[1:07:12][Blackboard: Bump Map vs Normal Map]
[1:12:37][gasto5 Q; Will the effect end up like a bump map effect?]
[1:12:54][@deadvertex][Could we do reflections by using our frame buffer as an environment map when drawing the bitmap?]
[1:13:17][@pseudonym73][If you imagine the surface as an implicit function f(x,y,z) = 0, it's the gradient of THAT function. Which is the same as the cross product of the two surface tangents.]
[1:14:44][We have come to the end of the questions][:speech]
[/video]
