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

56 lines
3.9 KiB
Plaintext
Raw Permalink Normal View History

[video output=day095 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Gamma-correct Premultiplied Alpha" vod_platform=youtube id=JTIzGsGqQaA annotator=dspecht annotator=Miblo]
[1:20][Recap yesterday's work]
[2:40][When do you premultiply the alpha?]
[4:58][This bilinear blend might want to be in premultiplied alpha]
[6:45][Inspect the change in appearance of the tree]
[8:44][See if we're storing the Texels premultiplied (we are)]
[9:24][We are not doing the most correct thing]
[10:07][Do not premultiply the alpha at all]
[10:51][Multiply the alpha just before the blend]
[11:40][On the output our Color values want to be not premultiplied]
[12:32][What happens on repeated blends?]
[14:15][Blackboard: When our values aren't stored premultipled]
[16:44][Blackboard: Projecting back to sRGB]
[18:07][Project the Color values back to sRGB space before storing them]
[19:58][Add struct containing rgb and a]
[21:00][Check it out in-game and consider making all our routines gamma-aware]
[22:43][Convert DrawRectangle to handle gamma correctly]
[28:50][Try and check it out in-game]
[29:52][Think about making our software renderer run relatively quickly]
[33:27][Take another look at DrawRectangleSlowly and premultiply the Color upfront]
[36:59][Do a little bit of cleanup]
[38:38][Blackboard: How the Header worked]
[39:25][Do two sequential pushes of the Header and Data]
[41:26][Step through that and make sure it works]
[42:52][Increment the BaseAddress properly and check it out in-game]
[44:58][Consider pulling out the Draw functions into a seperate file]
[46:36][Internet: MSDN: 'optimize'[ref
site="MSDN"
page="optimize"
url="https://msdn.microsoft.com/en-us/library/chh3fb0k.aspx"]]
[47:53][Try using #pragma optimize]
[49:57][Internet: MSDN: 'Optimization Best Practices'[ref
site="MSDN"
page="Optimization Best Practices"
url="https://msdn.microsoft.com/en-us/library/ms235601.aspx"]]
[50:52][Try wrapping everything else in a #pragma optimize off]
[54:25][Q&A][:speech]
[55:39][@arbesfeld][Why can't you compile OpenGL code to C to make a software renderer?]
[56:00][@mr4thdimention][Is it useful to be able to debug with optimizations on? Do you think you might be able to show how to do that at some point?]
[56:40][Demonstrate /Zo compiler flag[ref
site="MSDN"
page="/Zo (Enhance Optimized Debugging"
url="https://msdn.microsoft.com/en-us/library/dn785163.aspx"]]
[1:01:38][@arbesfeld][GLSL]
[1:05:48][@flaturated][Should the Load Bitmap function also be optimized after making changes today to do premultiply?]
[1:06:23][@guit4rfreak][How would something like a dynamic array in this memory system work? Something that is persistent across frames, but able to change size. Holes are not possible in the memory arenas right now?]
[1:08:04][@arbesfeld][Couldn't a compiler translate the OpenGL commands to C commands and wrap them in a loop which iterates over the pixels?]
[1:10:34][@lucaspperin][Could you explain us how you free all the memory stack when closing the game?]
[1:10:56][@starchypancakes][I have a hard time understanding why sRGB conversions are required for the alpha channel at all, and why your intitial code wasn't correct. The alpha channel is being used to just represent a proportion of photons from one source and a proportion of photons from another source(s). Wouldn't that be outside of the purview of color curves because it doesn't technically have anything to do with brightness?]
[1:11:39][@gdmonkey][You seem to be manipulating colors on a low level. How are you pushing pixels? Sorry, I am kinda new]
[1:12:27][@grumpygiant256][Any reason why you write 'Texel.a + Dest.a - Texel.a*Dest.a' instead of just 'InvRSA*Dest.a + Texel.a', which would match the RGB channels?]
[1:12:54][Rearrange these calculations and keep on keeping on condensing]
[1:15:54][@andsz_][Wasn't the alpha channel authored with nonlinear colors?]
[1:16:32][Call it a day][:speech]
[/video]