computer graphics
What is Metal in the context of computer graphics?
Metal is Apple's graphics and compute API. Its shader language is the Metal Shading Language (MSL).
In computer graphics, one often sees the output of vertex shaders are 4-tuples. The first three numbers in the 4-tuple are x, y, and z coordinates. What is the 4th?
The homogeneous coordinate, sometimes referred to as the w coordinate. It serves 3 primary purposes. 1. Perspective Division --- objects farther away appear smaller (screen_x = x /w, etc.) 2. Matrix Multiplications --- the w coordinate allows for elegant handling of affine transformations via matrix multiplications. 3. Clipping and Depth Buffering --- helps determine whether an object is visible and its depth relative to other objects. TODO: sounds like a moron wrote this
How do most graphics backends determine whether or not a triangle is facing the camera?
If the points are ordered counterclockwise, then the triangle is facing the camera. This incidentally aligns with historical conventions like the right-hand rule and Euler angles.
Yaw, pitch, and roll
Yaw --- flatspin; use rudder to control. Pitch --- backflip; use elevator to control. Roll --- barrel roll; use ailerons to control.
What is a fragment shader?
Every pixel that ends up on your screen has associated to it at least one fragment. The fragment usually describes what color the pixel will be. Fragment shaders take as input vertices (which already have been processed by a vertex shader) and produce fragments as output.
What is a vertex buffer?
It stores all the *unique* vertices of the triangles you're drawing. You'd then use an index buffer to identify specific vertices in the vertex buffer with specific vertices in your triangles.
Why is gamma encoding used in computer graphics?
Gamma encoding of images is used to optimize the usage of bits when encoding an image, or bandwidth used to transport an image, by taking advantage of the non-linear manner in which humans perceive light and color. The human perception of brightness (lightness), under common illumination conditions (neither pitch black nor blindingly bright), follows an approximate power function (which has no relation to the gamma function), with greater sensitivity to relative differences between darker tones than between lighter tones.
general 3d rotation matrix
R = R_z(๐›ผ) R_y(ฮฒ) R_x(๐›พ) matrix multiplication is not commutative so order matters
What is a typical CPU -> GPU latency in the context of rendering frames of a video game?
1-5 milliseconds
Scaling about the origin by s_x / s_w, s_y / s_w, s_z / s_w in projective geometry
{{ s_x, 0, 0, 0}, { 0, s_y, 0, 0}, {0, 0, s_z, 0}, {0, 0, 0, s_w}}
yaw matrix
R_z(๐›ผ) = {{cos ๐›ผ, -sin ๐›ผ, 0}, {sin ๐›ผ, cos ๐›ผ, 0}, {0, 0, 1}}
Rot(ฮธ) in projective geometry
{{ cos ฮธ, -sin ฮธ, 0}, {sin ฮธ, cos ฮธ, 0}, {0, 0, 1}}
What is a swapchain in the context of computer graphics?
A swapchain is a series of images presented to the display. It is handles buffering and synchronization between the display and the GPU to prevent artifacts like tearing. Related topics: double buffering, triple buffering, vsync
roll matrix
R_x(๐›พ) = {{1, 0, 0}, {0, cos ๐›พ, -sin ๐›พ}, {0, sin ๐›พ, cos ๐›พ}}
What is OpenGL?
A graphics API developed by Khronos Group. Its shader language is GLSL. Its successor is Vulkan.
What is mipmapping?
Mipmaps (also MIP maps) or pyramids are pre-calculated, optimized sequences of images, each of which is a progressively lower resolution representation of the previous. The height and width of each image, or level, in the mipmap is a factor of two smaller than the previous level. They are intended to increase rendering speed and reduce aliasing artifacts. The letters MIP in the name are an acronym of the Latin phrase multum in parvo, meaning "much in little".
What is WGSL?
WGSL stands for WebGPU Shading Language. It is the shading language for WebGPU. It's development focuses on converting WGSL shaders to into the shader language corresponding to whatever backend you're using. For example, the backend for Vulkan is SPIR-V; for Metal it's MSL; for DX12 is HLSL; for OpenGL it's GLSL. Apparently SPIR-V is going to be replaced by WGSL.
What is a vertex shader?
It transforms your shapes/objects to look the way you want it (where it's positioned, how it's oriented, etc.).
What is an index buffer?
It is used in conjuction with a vertex buffer --- the set of unique vertices in your triangles --- to associate specific vertices in your vertex buffer to specific vertices in your triangles.
What is gamma in computer graphics?
Gamma correction, gamma, or the "transfer function" is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems. Gamma correction is, in the simplest cases, defined by the following power-law expression: ๐‘‰_out = ๐ด ๐‘‰_in ^๐›พ where the non-negative real input value ๐‘‰ in is raised to the power ๐›พ and multiplied by the constant A to get the output value ๐‘‰ out . In the common case of A = 1, inputs and outputs are typically in the range 0โ€“1.
What is a bind group in wgpu?
A BindGroup describes a set of resources and how they can be accessed by a shader. TODO: maybe this is a WGSL thing, not a wgpu thing.
What is the view frustum?
The region of space of the modeled world that may appear on screen. Frustum etymology: Latin for "piece cut off"
Are WGSL matrices column-major or row-major?
column-major
What is sRGB?
sRGB is a standard RGB (red, green, blue) color space that HP and Microsoft created cooperatively in 1996 to use on monitors, printers, and the World Wide Web. Its IEC specification indicates a reference display with a nominal gamma of 2.2.
What are shaders?
Shaders are mini-programs that you send to your GPU to perform operations on your data. There are three main types of shaders: vertex, fragment, and compute. Vertex shaders transform your shapes to look the way you want. Fragment shaders convert the transformed vertices into fragments. Each pixel that gets drawn on your screen has at least one fragment. Usually the fragment has a color that gets copied to the pixel.
What is a gamut?
a gamut, or color gamut, is a convex set containing the colors that can be accurately represented
What is the IEC in technology?
International Electrotechnical Commission
pitch matrix
R_y(ฮฒ) = {{cos ฮฒ, 0, sin ฮฒ}, {0, 1, 0}, {-sin ฮฒ, 0, cos ฮฒ}}
What is normal mapping in computer graphics?
Normal mapping is a texture mapping technique used for faking the lighting of bumps and dents โ€“ an implementation of bump mapping. It is used to add details without using more polygons. A common use of this technique is to greatly enhance the appearance and details of a low polygon model by generating a normal map from a high polygon model or height map.
Trans(a, b) in projective geometry
{{1, 0, a}, {0, 1, b}, {0, 0, 1}}
What is Vulkan?
A graphics API developed by Khronos Group. Its shader language is currently SPIR-V, but there are plans to replace it with WGSL.
What is DX12?
DirectX 12, a graphics API developed by Microsoft and NVIDIA. Its shader language is the High-Level Shader Language (HLSL).
Homogeneous Coordinates
A system of coordinates used in projective geometry. 1. Formulas involving homogeneous coordinates are often simpler and more symmetric than their Cartesian counterparts; projective transformations are easily represented by a matrix. 2. Coordinates of points, including points at infinity, can be represented using finite coordinates. 3. Modern graphics APIs and graphics cards take advantage of homogeneous coordinate systems by using vector processors with 4-element registers (X, Y, Z, W).
What is the aspect ratio in computer graphics?
width : height
Rot_(a, b)(ฮธ) in projective geometry
Trans(a, b) Rot(ฮธ) Trans(-a, -b)
Do uniforms get sent to the GPU every single frame?
Yes, typically
Does wgpu use a linear or nonlinear color space?
linear
What is a uniform in computer graphics?
A uniform is a global Shader variable. These act as parameters that the user of a shader program can pass to that program. Uniforms are so named because they do not change from one shader invocation to the next within a particular rendering call thus their value is uniform among all invocations. This makes them unlike shader stage inputs and outputs, which are often different for each invocation of a shader stage.
Tristimulus Values
The human eye with normal vision has three kinds of cone cells that sense light, having peaks of spectral sensitivity in short ("S", 420 nm โ€“ 440 nm), medium ("M", 530 nm โ€“ 540 nm), and long ("L", 560 nm โ€“ 580 nm) wavelengths. These cone cells underlie human color perception in conditions of medium and high brightness; in very dim light color vision diminishes, and the low-brightness, monochromatic "night vision" receptors, denominated "rod cells", become effective. Thus, three parameters corresponding to levels of stimulus of the three kinds of cone cells, in principle describe any human color sensation. these three values compose a tristimulus specification of the objective color of the light spectrum. The three parameters, denoted "S", "M", and "L", are indicated using a 3-dimensional space denominated the "LMS color space", which is one of many color spaces devised to quantify human color vision.
How long do you have to render each frame if you want to render at least 60 frames per second?
16.666 milliseconds
What is a typical GPU -> CPU latency in the context of rendering frames of a video game?
5-10 milliseconds, but it's somewhat irrelevant because this trip is not involved in the path from CPU to what you see on your screen.