🌐 Translate:
Gamma Correction and Gamma Encoding
This post is a short set of notes I organized after reading Digital Images: From File to Screen. The example images are reproduced directly from that article. My main goal is to clarify what gamma correction does and the relationship between gamma correction and gamma encoding.
Notes from Unity Shaders to OpenGL (3): HDR and Bloom
In the previous post, I implemented normal and parallax mapping and worked through the TBN matrix. This time I continued with HDR and Bloom. Advanced Lighting—HDR Floating-point framebuffer On a typical screen, each pixel’s color is limited to the range 0–1, called LDR (low dynamic range). Lighting calculations do not actually expect the output to stay between 0 and 1. We need a larger range to represent different light intensities, especially in the PBR era. First, the Pixel Shader must be able to output values greater than 0–1, so we change the framebuffer. The default GL_RGBA has 8 bits per channel, ranging from 0–1. Changing the internal format to GL_RGBA16F or GL_RGBA32F makes the framebuffer floating point, allowing a Pixel Shader rendered into it to store HDR values. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, windowWidth, windowHeight, 0, GL_RGBA, GL_FLOAT, NULL); Let us experiment immediately after making the change.
Notes from Unity Shaders to OpenGL (2): Tangent Space
Continuing the previous post and following LearnOpenGL, this time I started implementing Normal Mapping. Advanced Lighting—Normal Mapping This section introduces the principles and implementation of the familiar normal map. Normal maps are usually blue because the default surface normal points along the Z axis (the B channel), so the B value is the largest of the RGB channels. A bumpy surface offsets the normal toward the x and y directions by different amounts, producing a texture like the one above.
Notes from Unity Shaders to OpenGL (1)
![Untitled.png](/assets/img/blog/Untitled (5).png) Why write OpenGL? One convenient thing about writing shaders in Unity’s Built-in Render Pipeline (BiRP) or URP is the large number of macros, built-in functions, and variables available. They let users ignore many implementation details. For example, converting a 3D coordinate between coordinate systems in URP usually means calling a TransformNNNToMMM function; direction vectors have TransformNNNToMMMDDir, and calculating screen coordinates only requires a built-in function such as ComputeScreenPos. This is very convenient, but because of these conveniences I never fully understood the calculations happening underneath.
Getting Started with Unity's C# Job System (1)
In the previous post, I gave a brief introduction to the advantages and disadvantages of multithreaded programming and the architecture of the Job System. This post introduces Unity’s different Job interfaces and their basic usage. I hope that after reading it you can write not only multithreaded code, but also code that actually performs parallel computation. Contents Terminology The first Job—implementing IJob Implementing IJobFor IJobParallelFor Comparing results Further performance optimization—Burst Compiler Is using the Job System and parallel computation the same thing as DOTS? DOTS—Data-Oriented Technology Stack—is Unity’s data-oriented programming package. It includes the ECS architecture, the C# Job System, and the Burst Compiler. These three pieces can exist independently, so even if a project does not use ECS, the C# Job System and Burst Compiler can be used in any existing project.