diff --git a/.buildinfo b/.buildinfo new file mode 100644 index 0000000..d9e2223 --- /dev/null +++ b/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: d82dc8fa58ea2df82caa2d8349320848 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle new file mode 100644 index 0000000..7f660d5 Binary files /dev/null and b/.doctrees/environment.pickle differ diff --git a/.doctrees/index.doctree b/.doctrees/index.doctree new file mode 100644 index 0000000..c51062a Binary files /dev/null and b/.doctrees/index.doctree differ diff --git a/.doctrees/source/blog/autoexposure.doctree b/.doctrees/source/blog/autoexposure.doctree new file mode 100644 index 0000000..f026557 Binary files /dev/null and b/.doctrees/source/blog/autoexposure.doctree differ diff --git a/.doctrees/source/blog/censustransform.doctree b/.doctrees/source/blog/censustransform.doctree new file mode 100644 index 0000000..010d534 Binary files /dev/null and b/.doctrees/source/blog/censustransform.doctree differ diff --git a/.doctrees/source/blog/chromaticity.doctree b/.doctrees/source/blog/chromaticity.doctree new file mode 100644 index 0000000..c49f1fd Binary files /dev/null and b/.doctrees/source/blog/chromaticity.doctree differ diff --git a/.doctrees/source/blog/coordinatespaces.doctree b/.doctrees/source/blog/coordinatespaces.doctree new file mode 100644 index 0000000..c2c1092 Binary files /dev/null and b/.doctrees/source/blog/coordinatespaces.doctree differ diff --git a/.doctrees/source/blog/cpp.doctree b/.doctrees/source/blog/cpp.doctree new file mode 100644 index 0000000..d4149db Binary files /dev/null and b/.doctrees/source/blog/cpp.doctree differ diff --git a/.doctrees/source/blog/gaussianblur.doctree b/.doctrees/source/blog/gaussianblur.doctree new file mode 100644 index 0000000..b45e80f Binary files /dev/null and b/.doctrees/source/blog/gaussianblur.doctree differ diff --git a/.doctrees/source/blog/logdepth.doctree b/.doctrees/source/blog/logdepth.doctree new file mode 100644 index 0000000..c7e3ad2 Binary files /dev/null and b/.doctrees/source/blog/logdepth.doctree differ diff --git a/.doctrees/source/blog/loops.doctree b/.doctrees/source/blog/loops.doctree new file mode 100644 index 0000000..e6044ea Binary files /dev/null and b/.doctrees/source/blog/loops.doctree differ diff --git a/.doctrees/source/blog/opticalflow.doctree b/.doctrees/source/blog/opticalflow.doctree new file mode 100644 index 0000000..1e9f99c Binary files /dev/null and b/.doctrees/source/blog/opticalflow.doctree differ diff --git a/.doctrees/source/blog/outerralogdepth.doctree b/.doctrees/source/blog/outerralogdepth.doctree new file mode 100644 index 0000000..b3d7e1d Binary files /dev/null and b/.doctrees/source/blog/outerralogdepth.doctree differ diff --git a/.doctrees/source/blog/pythonengine.doctree b/.doctrees/source/blog/pythonengine.doctree new file mode 100644 index 0000000..62e3b49 Binary files /dev/null and b/.doctrees/source/blog/pythonengine.doctree differ diff --git a/.doctrees/source/blog/reshadefx.doctree b/.doctrees/source/blog/reshadefx.doctree new file mode 100644 index 0000000..59324f3 Binary files /dev/null and b/.doctrees/source/blog/reshadefx.doctree differ diff --git a/.doctrees/source/blog/shadermodel3.doctree b/.doctrees/source/blog/shadermodel3.doctree new file mode 100644 index 0000000..6c31685 Binary files /dev/null and b/.doctrees/source/blog/shadermodel3.doctree differ diff --git a/.doctrees/source/blog/sobel.doctree b/.doctrees/source/blog/sobel.doctree new file mode 100644 index 0000000..4bc4d36 Binary files /dev/null and b/.doctrees/source/blog/sobel.doctree differ diff --git a/.doctrees/source/social/instagram.doctree b/.doctrees/source/social/instagram.doctree new file mode 100644 index 0000000..3a1a904 Binary files /dev/null and b/.doctrees/source/social/instagram.doctree differ diff --git a/.doctrees/source/social/project.doctree b/.doctrees/source/social/project.doctree new file mode 100644 index 0000000..67e5bf6 Binary files /dev/null and b/.doctrees/source/social/project.doctree differ diff --git a/.doctrees/source/social/youtube.doctree b/.doctrees/source/social/youtube.doctree new file mode 100644 index 0000000..6a3c8fa Binary files /dev/null and b/.doctrees/source/social/youtube.doctree differ diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/_downloads/af96786462247ba26af205370a7ad1b0/Video Templates (Project Reality).drp b/_downloads/af96786462247ba26af205370a7ad1b0/Video Templates (Project Reality).drp new file mode 100644 index 0000000..e75781d Binary files /dev/null and b/_downloads/af96786462247ba26af205370a7ad1b0/Video Templates (Project Reality).drp differ diff --git a/_sources/index.rst.txt b/_sources/index.rst.txt new file mode 100644 index 0000000..db6f755 --- /dev/null +++ b/_sources/index.rst.txt @@ -0,0 +1,19 @@ + +Homepage +======== + +.. toctree:: + :caption: Content Creation Guide + :glob: + :titlesonly: + + source/social/project + source/social/* + +.. toctree:: + :caption: Graphics Programming Blog + :glob: + :titlesonly: + + source/blog/cpp + source/blog/* diff --git a/_sources/source/blog/autoexposure.rst.txt b/_sources/source/blog/autoexposure.rst.txt new file mode 100644 index 0000000..a0d45c3 --- /dev/null +++ b/_sources/source/blog/autoexposure.rst.txt @@ -0,0 +1,109 @@ + +Temporal Auto-Exposure with Hardware Blending +============================================= + +Some graphics pipelines compute auto-exposure like this: + :Textures: + #. Previous average brightness + #. Current average brightness + :Passes: + #. Store previously generated average brightness + #. Generates current average brightness + #. Smooth average brightnesses and compute auto-exposure + +You can use hardware blending for auto-exposure: + :Textures: + #. Average brightnesses (previous + current) + :Passes: + #. Generate and smooth average brightnesses + #. Compute auto-exposure + +Source Code +----------- + +:: + + /* + Automatic exposure shader using hardware blending + */ + + /* + Vertex shaders + */ + + struct APP2VS + { + float4 HPos : POSITION; + float2 Tex0 : TEXCOORD0; + }; + + struct VS2PS + { + float4 HPos : POSITION; + float2 Tex0 : TEXCOORD0; + }; + + VS2PS VS_Quad(APP2VS Input) + { + VS2PS Output; + Output.HPos = Input.HPos; + Output.Tex0 = Input.Tex0; + return Output; + } + + /* + Pixel shaders + --- + AutoExposure(): https://knarkowicz.wordpress.com/2016/01/09/automatic-exposure/ + */ + + float3 GetAutoExposure(float3 Color, float2 Tex) + { + float LumaAverage = exp(tex2Dlod(SampleLumaTex, float4(Tex, 0.0, 99.0)).r); + float Ev100 = log2(LumaAverage * 100.0 / 12.5); + Ev100 -= _ManualBias; // optional manual bias + float Exposure = 1.0 / (1.2 * exp2(Ev100)); + return Color * Exposure; + } + + float4 PS_GenerateAverageLuma(VS2PS Input) : COLOR0 + { + float4 Color = tex2D(SampleColorTex, Input.Tex0); + float3 Luma = max(Color.r, max(Color.g, Color.b)); + + // OutputColor0.rgb = Output the highest brightness out of red/green/blue component + // OutputColor0.a = Output the weight for temporal blending + float Delay = 1e-3 * _Frametime; + return float4(log(max(Luma.rgb, 1e-2)), saturate(Delay * _SmoothingSpeed)); + } + + float3 PS_Exposure(VS2PS Input) : COLOR0 + { + float4 Color = tex2D(SampleColorTex, Input.Tex0); + return GetAutoExposure(Color.rgb, Input.Tex0); + } + + technique AutoExposure + { + // Pass0: This shader renders to a texture that blends itself + // NOTE: Do not have another shader overwrite the texture + pass GenerateAverageLuma + { + // Use hardware blending + BlendEnable = TRUE; + BlendOp = ADD; + SrcBlend = SRCALPHA; + DestBlend = INVSRCALPHA; + + VertexShader = VS_Quad; + PixelShader = PS_GenerateAverageLuma; + } + + // Pass1: Get the texture generated from Pass0 + // Do autoexposure shading here + pass ApplyAutoExposure + { + VertexShader = VS_Quad; + PixelShader = PS_Exposure; + } + } diff --git a/_sources/source/blog/censustransform.rst.txt b/_sources/source/blog/censustransform.rst.txt new file mode 100644 index 0000000..8951818 --- /dev/null +++ b/_sources/source/blog/censustransform.rst.txt @@ -0,0 +1,48 @@ + +Census Transform in HLSL +======================== + +The census transform is a filter that represents the pixel's neighborhood relationship in a binary string. The binary string will be ``0000000`` if the center pixel is lesser than all of its neighbors. The binary string will be ``11111111`` if the center pixel is greater than or equal to all of its neighbors. + +The filter does not depend on the image's actual intensity. As a result, the filter is robust to illumination. + +Source Code +----------- + +:: + + float GetGreyScale(float3 Color) + { + return max(max(Color.r, Color.g), Color.b); + } + + float GetCensusTransform(sampler SampleImage, float2 Tex, float2 PixelSize) + { + float OutputColor = 0.0; + float4 ColumnTex[3]; + ColumnTex[0] = Tex.xyyy + (float4(-1.0, +1.0, 0.0, -1.0) * PixelSize.xyyy); + ColumnTex[1] = Tex.xyyy + (float4( 0.0, +1.0, 0.0, -1.0) * PixelSize.xyyy); + ColumnTex[2] = Tex.xyyy + (float4(+1.0, +1.0, 0.0, -1.0) * PixelSize.xyyy); + + const int Neighbors = 8; + float SampleNeighbor[Neighbors]; + SampleNeighbor[0] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xy).rgb); + SampleNeighbor[1] = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xy).rgb); + SampleNeighbor[2] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xy).rgb); + SampleNeighbor[3] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xz).rgb); + SampleNeighbor[4] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xz).rgb); + SampleNeighbor[5] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xw).rgb); + SampleNeighbor[6] = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xw).rgb); + SampleNeighbor[7] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xw).rgb); + float CenterSample = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xz).rgb); + + // Generate 8-bit integer from the 8-pixel neighborhood + for(int i = 0; i < Neighbors; i++) + { + float Comparison = step(SampleNeighbor[i], CenterSample); + OutputColor += ldexp(Comparison, i); + } + + // Convert the 8-bit integer to float, and average the results from each channel + return OutputColor * (1.0 / (exp2(8) - 1)); + } diff --git a/_sources/source/blog/chromaticity.rst.txt b/_sources/source/blog/chromaticity.rst.txt new file mode 100644 index 0000000..f93e555 --- /dev/null +++ b/_sources/source/blog/chromaticity.rst.txt @@ -0,0 +1,100 @@ + +Chromaticity in HLSL +==================== + +Images often represent color in 3 channels: ``(R, G, B)`` - red, green, and blue. You can represent ``(R, G, B)`` in any range. For this post, the range is a minimum of **0.0** and a maximum of **1.0**. + +Normalized Chromaticity +----------------------- + +Formulas +^^^^^^^^ + +Normalized RG/RGB + .. math:: + + r = \frac{R}{R+G+B}\\ + g = \frac{G}{R+G+B}\\ + b = \frac{B}{R+G+B}\\ + \\ + r+g+b = 1 + + Output :math:`(r,g,b)` + :(1.0, 0.0, 0.0): 100% red + :(0.0, 1.0, 0.0): 100% green + :(0.0, 0.0, 1.0): 100% blue + + Output :math:`(r,g)` + :\(1.0, 0.0\): 100% red + :\(0.0, 1.0\): 100% green + :\(0.0, 0.0\): 100% blue + +Normalized RG/RGB White-Point + .. math:: + + R=1\\ + G=1\\ + B=1\\ + \\ + r = \frac{R}{R+G+B}\\ + g = \frac{G}{R+G+B}\\ + b = \frac{B}{R+G+B}\\ + \\ + r+g+b = 1 + +Source Code +^^^^^^^^^^^ + +:: + + float3 GetRGBChromaticity(float3 Color) + { + // Optimizes 2 ADD instructions 1 DP3 instruction + float SumRGB = dot(Color, 1.0); + float3 Chromaticity = saturate(Color / SumRGB); + // Output the chromaticity's white point if the divisor is 0.0 + // Prevents undefined behavior happens when you divide by 0 + Chromaticity = (SumRGB == 0.0) ? 1.0 / 3.0 : Chromaticity; + return Chromaticity; + } + +Spherical Chromaticity +---------------------- + +This post introduces a color space that computes chromaticity with angles. + +Precision Loss in RG Chromaticity +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pecision is a major drawback to RG chromaticity. In RG chromaticity, all possible values map into a right-triangle, eliminating half of the precision in integer buffers. + +We can encode data that fits in the entire ``RG8`` range by calculating the angles between the channels. + +Source Code +^^^^^^^^^^^ + +:: + + /* + This code is based on the algorithm described in the following paper: + Author(s): Joost van de Weijer, T. Gevers + Title: "Robust optical flow from photometric invariants" + Year: 2004 + DOI: 10.1109/ICIP.2004.1421433 + Link: https://www.researchgate.net/publication/4138051_Robust_optical_flow_from_photometric_invariants + */ + + float2 GetSphericalRG(float3 Color) + { + const float HalfPi = 1.0 / acos(0.0); + + // Precalculate (x*x + y*y)^0.5 and (x*x + y*y + z*z)^0.5 + float L1 = length(Color.rg); + float L2 = length(Color.rgb); + + float2 Angles = 0.0; + Angles[0] = (L1 == 0.0) ? 1.0 / sqrt(2.0) : Color.g / L1; + Angles[1] = (L2 == 0.0) ? 1.0 / sqrt(3.0) : L1 / L2; + + return saturate(asin(abs(Angles)) * HalfPi); + } diff --git a/_sources/source/blog/coordinatespaces.rst.txt b/_sources/source/blog/coordinatespaces.rst.txt new file mode 100644 index 0000000..f841227 --- /dev/null +++ b/_sources/source/blog/coordinatespaces.rst.txt @@ -0,0 +1,31 @@ + +Coordinate Spaces: A Refresher +============================== + +Standard Basis + Defines the directions of the x-axis, y-axis, and z-axis. + + :(1.0, 0.0, 0.0): x-axis + :(0.0, 1.0, 0.0): y-axis + :(0.0, 0.0, 1.0): z-axis + + +.. list-table:: Coordinate Spaces + :header-rows: 1 + + * - Coordinate Space + - Standard-Basis Location + - (0.0, 0.0, 0.0) Location + * - Tangent-Space + - On the **face or vertex**. + - On the center of the **face or vertex**. + * - Object-Space + - On the **object**. + - On the center of the **object**. + * - World-Space + - On the **world**. + - On the center of the **world**. + * - View-Space + - On the **viewer**. + - On the center of the **viewer**. + diff --git a/_sources/source/blog/cpp.rst.txt b/_sources/source/blog/cpp.rst.txt new file mode 100644 index 0000000..298f118 --- /dev/null +++ b/_sources/source/blog/cpp.rst.txt @@ -0,0 +1,750 @@ +GiraffeAcademy's C++ Examples +============================= + +Sourced from: `C++ Programming | In One Video `_ + +Abstract Classes +---------------- + +.. code-block:: cpp + + #include + using namespace std; + + class Vehicle + { + public: + virtual void move() = 0; + void getDescription() + { + cout << "Vehicles are used for transportation" << endl; + } + }; + + class Bicycle : public Vehicle + { + public: + void move() + { + cout << "The bicycle pedals forward" << endl; + } + }; + + class Plane : public Vehicle + { + public: + virtual void move() + { + cout << "The plane flys through the sky" << endl; + } + }; + + int main() + { + Plane myPlane; + myPlane.move(); + myPlane.getDescription(); + + return 0; + } + +Arrays +------ + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + // Define an integer array + // int luckyNumbers[6]; + int luckyNumbers[] = {4, 8, 15, 16, 23, 42}; + // indexes: 0 1 2 3 4 5 + + // Set the number 99 at the 1st member + luckyNumbers[0] = 90; + + // Print out the array's 1st and 2nd members + cout << luckyNumbers[0] << endl; + cout << luckyNumbers[1] << endl; + + return 0; + } + +Arrays (2D) +----------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + // Define a 2D integer array + // int numberGrid[2][3]; + int numberGrid[2][3] = {{1, 2, 3}, {4, 5, 6}}; + + // Set the number 99 at [row 1][column 2] + numberGrid[0][1] = 99; + + // Print [row 1][column 1 and 2] + cout << numberGrid[0][0] << endl; + cout << numberGrid[0][1] << endl; + + return 0; + } + +Casting +------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + cout << (int)3.14 << endl; + cout << (double)3 / 2 << endl; + + return 0; + } + +Classes +------- + +.. code-block:: cpp + + #include + #include + using namespace std; + + // Create the Book datatype + class Book + { + public: + string title; + string author; + + void readBook() + { + cout << "Reading " + this->title + " by " + this->author << endl; + } + }; + + int main() + { + // Construct the book1 object instance + Book book1; + book1.title = "Harry Potter"; + book1.author = "JK Rowling"; + + // Print out info from the book1 object instance + book1.readBook(); + cout << book1.title << endl; + + // Construct the book2 object instance + Book book2; + book2.title = "Lord of the Rings"; + book2.author = "JRR Tolkien"; + + // Print out info from the book2 object instance + book2.readBook(); + cout << book2.title << endl; + + return 0; + } + +Constants +--------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + const int BIRTH_YEAR = 1945; + // BIRTH_YEAR = 1988; // Can't change BIRTH_YEAR + cout << BIRTH_YEAR; + + return 0; + } + +Constructors +------------ + +.. code-block:: cpp + + #include + #include + using namespace std; + + // Create the Book datatype + class Book + { + public: + string title; + string author; + + // Define the class' constuctor function + // NOTE: This is like `def __init__()` in Python :D + Book(string title, string author) + { + this->title = title; + this->author = author; + } + + void readBook() + { + cout << "Reading " + this->title + " by " + this->author << endl; + } + }; + + int main() + { + // Construct the book1 object instance + Book book1("Harry Potter", "JK Rowling"); + + // Print out info from the book1 object instance + book1.readBook(); + cout << book1.title << endl; + + // Construct the book2 object instance + Book book2("Lord of the Rings", "JRR Tolkien"); + + // Print out info from the book2 object instance + book2.readBook(); + cout << book2.title << endl; + + return 0; + } + +Exceptions +---------- + +.. code-block:: cpp + + #include + using namespace std; + + double division(int a, int b) + { + if (b == 0) + { + throw "Division by zero error!"; + } + return (a / b); + } + + int main() + { + try + { + division(10, 0); + } + catch (const char *msg) + { + cerr << msg << endl; + } + + return 0; + } + +For Loops +--------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + for (int i = 0; i < 5; i++) + { + cout << i << endl; + } + + return 0; + } + +Functions +--------- + +.. code-block:: cpp + + #include + using namespace std; + + // Specify a method signature + int addNumbers(int num1, int num2); + + int main() + { + // NOTE: We declare the function first + int sum = addNumbers(4, 60); + cout << sum << endl; + + return 0; + } + + int addNumbers(int num1, int num2) + { + return num1 + num2; + } + +Getters & Setters +----------------- + +.. code-block:: cpp + + #include + #include + using namespace std; + + // Create the Book datatype + class Book + { + private: + string title; + string author; + + public: + // Define the class' constuctor function + // NOTE: This is like `def __init__()` in Python :D + Book(string title, string author) + { + this->setTitle(title); + this->setAuthor(author); + } + + string getTitle() + { + return this->title; + } + + void setTitle(string title) + { + this->title = title; + } + + string getAuthor(string author) + { + return this->author; + } + + void setAuthor(string author) + { + this->author = author; + } + + void readBook() + { + cout << "Reading " + this->title + " by " + this->author << endl; + } + }; + + int main() + { + // Construct the book1 object instance + Book book1("Harry Potter", "JK Rowling"); + + // Print out info from the book1 object instance + book1.readBook(); + cout << book1.getTitle() << endl; + + // Construct the book2 object instance + Book book2("Lord of the Rings", "JRR Tolkien"); + + // Print out info from the book2 object instance + book2.readBook(); + cout << book2.getTitle() << endl; + + return 0; + } + +If Statements +------------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + // Define 2 booleans + bool isStudent = false; + bool isSmart = false; + + if (isStudent && isSmart) + { + cout << "You are a student" << endl; + } + else if (isStudent && !isSmart) + { + cout << "You are not a smart student" << endl; + } + else + { + cout << "You are not a student and not smart" << endl; + } + + // >, <, >=, <=, !=, == + if (1 > 3) + { + cout << "Number comparison was true" << endl; + } + + if ('a' > 'b') + { + cout << "Character comparison was true" << endl; + } + + string myString = "cat"; + if (myString.compare("cat") != 0) + { + cout << "string comparison was true" << endl; + } + + return 0; + } + +Inheritance +----------- + +.. code-block:: cpp + + #include + using namespace std; + + // Create a Chef datatype + class Chef + { + public: + string name; + int age; + + Chef(string name, int age) + { + this->name = name; + this->age = age; + } + + void makeChicken() + { + cout << "The chef makes chicken" << endl; + } + + void makeSalad() + { + cout << "The chef makes salad" << endl; + } + + void makeSpecialDish() + { + cout << "The chef makes a special dish" << endl; + } + }; + + // Create an ItalianChef datatype that is an extenion of the Chef datatype + class ItalianChef : public Chef + { + public: + string countryOfOrigin; + + // Extended class' constructor from Chef's class constructor + ItalianChef(string name, int age, string countryOfOrigin) : Chef(name, age) + { + this->countryOfOrigin = countryOfOrigin; + } + + void makePasta() + { + cout << "The chef makes pasta" << endl; + } + + // Override the Chef class' makeSpecialDish() + void makeSpecialDish() + { + cout << "The chef makes chicken parmesan" << endl; + } + }; + + int main() + { + // Example of the Chef class + Chef myChef("Gordon Ramsay", 50); + myChef.makeSpecialDish(); + + // Example of the extended ItalianChef class + ItalianChef myItalianChef("Massimo Bottura", 55, "Italy"); + myItalianChef.makeSpecialDish(); + cout << myItalianChef.age << endl; + + return 0; + } + +Numbers +------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + cout << 2 * 3 << endl; // Basic arithmetic: +, -, /, * + cout << 10 % 3 << endl; // Modulus operator: returns the remainder of 10 / 3 + cout << (1 + 2) * 3 << endl; // Order of operations + + /* + Division rules with ints and doubles: + f/f = f + i/i = i + i/f = f + f/i = f + */ + cout << 10 / 3.0 << endl; + + int num = 10; + num += 100; // +=, -=, /=, *= + cout << num << endl; + + // Example: variable incrementation + num++; + cout << num << endl; + + return 0; + } + +Pointers +-------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + /* + What pointers are: + - Exposes memory addresses + - Manipulates memory addresses + Why we use pointers: + - Memory addresses can change per-syetem + - Directly change data without copying it + */ + + // Print out an integer variable's memory address + int num = 10; + cout << &num << endl; + + // Store the integer variable's memory address into memory + int *pNum = # + cout << pNum << endl; // Print the memory adddress + cout << *pNum << endl; // Dereference the memory address to fetch its stored value + + return 0; + } + +Printing +-------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + cout << "Hello World!" << endl; + + return 0; + } + +Strings +------- + +.. code-block:: cpp + + #include + #include + using namespace std; + + int main() + { + string greetings = "Hello"; + // char indexes: 01234 + + cout << greetings.length() << endl; // Get string length + cout << greetings[0] << endl; // Get 1st character of string + cout << greetings.find("llo") << endl; // Find "llo"'s starting character position + cout << greetings.substr(2) << endl; // Get all characters, starting from the 2nd character of the string + cout << greetings.substr(1, 3) << endl; // Get 3 characters, starting from the 1st character of the string + + return 0; + } + +Switch Statements +----------------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + char myGrade = 'A'; + switch (myGrade) + { + case 'A': + cout << "You pass" << endl; + break; + case 'B': + cout << "You fail" << endl; + break; + default: + cout << "Invalid grade" << endl; + } + + return 0; + } + +User Input +---------- + +.. code-block:: cpp + + #include + #include + using namespace std; + + int main() + { + string name; + cout << "Enter your name: "; + cin >> name; + cout << "Hello " << name << endl; + + int num1, num2; + cout << "Enter first number: "; + cin >> num1; + cout << "Enter second number: "; + cin >> num2; + cout << "Answer: " << num1 + num2 << endl; + + return 0; + } + +Variables +--------- + +.. code-block:: cpp + + #include + #include + using namespace std; + + int main() + { + /* + Traits: + - Case-sensitive + - May begin with letters + - Can include letters, numbers, or _ + Convention: + - First word lower-case, rest upper-case (camelCase) + - Example: myVariable + */ + + string name = "Mike"; // string of characters, not primitive + char testGrade = 'A'; // single 8-bit character + + // NOTE: You can make them unsigned by adding the "unsigned" prefix + short age0 = 10; // atleast 16-bit signed integer + int age1 = 20; // atleast 16-bits signed integer (not smaller than short) + long age2 = 30; // atleast 32-bits signed integer + long long age3 = 40; // atleast 64-bits signed integer + + float gpa0 = 2.5f; // single percision floating point + double gpa1 = 3.5l; // double-precision floating point + long double gpa2 = 3.5; // extended-precision floating point + + bool isTall; // 1-bit -> true/false + isTall = true; + + return 0; + } + +Vectors +------- + +.. code-block:: cpp + + #include + #include + #include + using namespace std; + + int main() + { + // Define a vector of strings + vector friends; + // Append 3 strings into the vector + friends.push_back("Oscar"); + friends.push_back("Angela"); + friends.push_back("Kevin"); + // Append "Jim" at the 2nd index of the vendor + friends.insert(friends.begin() + 1, "Jim"); + + // Print out the friend vector's first 3 members + cout << friends.at(0) << endl; + cout << friends.at(1) << endl; + cout << friends.at(2) << endl; + // Print out the friend vector's size + cout << friends.size() << endl; + + return 0; + } + +While Loops +----------- + +.. code-block:: cpp + + #include + using namespace std; + + int main() + { + // Notify that this is a while loop + cout << "Executing while loop" << endl; + + // Do while loop + int index = 1; + while (index <= 5) + { + cout << index << endl; + index++; + } + + // Notify that this is a do-while loop + cout << "Executing do-while loop" << endl; + + do + { + cout << index << endl; + index++; + } while (index <= 5); + + return 0; + } \ No newline at end of file diff --git a/_sources/source/blog/gaussianblur.rst.txt b/_sources/source/blog/gaussianblur.rst.txt new file mode 100644 index 0000000..56561c8 --- /dev/null +++ b/_sources/source/blog/gaussianblur.rst.txt @@ -0,0 +1,46 @@ + +RasterGrid's Gaussian Blur in HLSL +================================== + +Gaussian blurs sample many pixels. `RasterGrid optimized Gaussian blur by sampling in-between pixels `_. RasterGrid's article did not include shader code for varied Gaussian blur radii. This post solves that. + +Source Code +----------- + +:: + + float GetGaussianWeight(float SampleIndex, float Sigma) + { + const float Pi = 3.1415926535897932384626433832795f; + float Output = rsqrt(2.0 * Pi * (Sigma * Sigma)); + return Output * exp(-(SampleIndex * SampleIndex) / (2.0 * Sigma * Sigma)); + } + + float GetGaussianOffset(float SampleIndex, float Sigma, out float LinearWeight) + { + float Offset1 = SampleIndex; + float Offset2 = SampleIndex + 1.0; + float Weight1 = GetGaussianWeight(Offset1, Sigma); + float Weight2 = GetGaussianWeight(Offset2, Sigma); + LinearWeight = Weight1 + Weight2; + return ((Offset1 * Weight1) + (Offset2 * Weight2)) / LinearWeight; + } + + float4 GetGaussianBlur(float2 Tex, float LOD, float2 PixelSize, float Sigma) + { + // Sample and weight center first to get even number sides + float TotalWeight = GetGaussianWeight(0.0, Sigma); + float4 OutputColor = tex2Dlod(SampleColorTex, float4(Tex, 0.0, LOD)) * TotalWeight; + + for(float i = 1.0; i < Sigma * 3.0; i += 2.0) + { + float LinearWeight = 0.0; + float LinearOffset = GetGaussianOffset(i, Sigma, LinearWeight); + OutputColor += tex2Dlod(SampleColorTex, float4(Tex - (LinearOffset * PixelSize), 0.0, LOD)) * LinearWeight; + OutputColor += tex2Dlod(SampleColorTex, float4(Tex + (LinearOffset * PixelSize), 0.0, LOD)) * LinearWeight; + TotalWeight += LinearWeight * 2.0; + } + + // Normalize intensity to prevent altered output + return OutputColor / TotalWeight; + } diff --git a/_sources/source/blog/logdepth.rst.txt b/_sources/source/blog/logdepth.rst.txt new file mode 100644 index 0000000..8394383 --- /dev/null +++ b/_sources/source/blog/logdepth.rst.txt @@ -0,0 +1,66 @@ + +Logarithmic Depth Buffering in HLSL +=================================== + +`The Project Reality Team `_ implemented logarithmic depth buffering for the 1.7.3 update. This post covers our implementation of simple logarithmic depth buffering in HLSL. + +`Outerra has an optimized 2013 implementation of logarithmic depth in GLSL `_. This is our simplified version of Outerra’s logarithmic depth in HLSL. + +Source Code +----------- + +:: + + float4x4 _WorldViewProj : WorldViewProj; + + struct APP2VS + { + float4 Pos : POSITION0; + }; + + struct VS2PS + { + float4 HPos : POSITION; + float Depth : TEXCOORD0; + }; + + struct PS2FB + { + float4 Color : COLOR; + float Depth : DEPTH; + }; + + // Converts linear depth to logarithmic depth in the pixel shader + // Source: https://outerra.blogspot.com/2013/07/logarithmic-depth-buffer-optimizations.html + float ApplyLogarithmicDepth(float Depth) + { + const float FarPlane = 10000.0; + const float FCoef = 1.0 / log2(FarPlane + 1.0); + return log2(Depth) * FCoef; + } + + VS2PS VS_LogDepth(APP2VS Input) + { + VS2PS Output = (VS2PS)0; + + // Usually a transformation happens here + Output.HPos = mul(float4(Input.Pos.xyz, 1.0), _WorldViewProj); + + // Output depth + Output.Depth = Output.HPos.w + 1.0; + + return Output; + } + + PS2FB PS_LogDepth(VS2PS Input) + { + PS2FB Output; + + // You need to output something to the color buffer + Output.Color = 0.0; + + // You must output to the pixel shader’s DEPTH semantic so the GPU can do per-fragment depth testing. + Output.Depth = ApplyLogarithmicDepth(Input.Depth); + + return Output; + }; diff --git a/_sources/source/blog/loops.rst.txt b/_sources/source/blog/loops.rst.txt new file mode 100644 index 0000000..527a320 --- /dev/null +++ b/_sources/source/blog/loops.rst.txt @@ -0,0 +1,36 @@ + +Turning a Nested 2D Loop into 1D +================================ + +In GPU programming, you might sample a 2D window with a nested. However, a nested loop might be more inefficient than 1 loop. + +This post is an example of how to sample a 3x3 window of offsets in 1 loop. + +Source Code +----------- + +:: + + // Get required data to calculate main window data + const int WindowSize = 3; + const int WindowHalf = trunc(WindowSize / 2); + + // Start from the negative so we can process a window in 1 loop + [loop] for (int i = 0; i < (WindowSize * WindowSize); i++) + { + float2 XY = -WindowHalf + float2(i % WindowSize, trunc(i / WindowSize)); + } + +== ============ == ================= == +i# X Y +== ============ == ================= == +0 -1 + (0 % 3) -1 -1 + trunc(0 / 3) -1 +1 -1 + (1 % 3) 0 -1 + trunc(1 / 3) -1 +2 -1 + (2 % 3) 1 -1 + trunc(2 / 3) -1 +3 -1 + (3 % 3) -1 -1 + trunc(3 / 3) 0 +4 -1 + (4 % 3) 0 -1 + trunc(4 / 3) 0 +5 -1 + (5 % 3) 1 -1 + trunc(5 / 3) 0 +6 -1 + (6 % 3) -1 -1 + trunc(6 / 3) 1 +7 -1 + (7 % 3) 0 -1 + trunc(7 / 3) 1 +8 -1 + (8 % 3) 1 -1 + trunc(8 / 3) 1 +== ============ == ================= == diff --git a/_sources/source/blog/opticalflow.rst.txt b/_sources/source/blog/opticalflow.rst.txt new file mode 100644 index 0000000..de81953 --- /dev/null +++ b/_sources/source/blog/opticalflow.rst.txt @@ -0,0 +1,223 @@ + +Lucas-Kanade Optical Flow in HLSL +================================= + +An optical flow algorithm estimates the motion between frames. Optical flow is essential in object detection, object recognition, motion estimation, video compression, and video effects. + +This post covers an HLSL implementation of Lucas-Kanade optical flow. + +Algorithm +--------- + +The pyramid LK algorithm consists of the following steps. + +#. Build the current frame’s mipmap pyramid + + Encode the image into chromaticity with ``GetSphericalRG()`` + +#. Filter the current frame with a Gaussian blur +#. Set the initial motion vector to ``<0.0, 0.0>`` +#. Compute optical flow from the smallest to largest pyramid level + + Propagate the optical flow at each level + +#. Filter the optical flow with a Gaussian blur +#. Store the current frame for use in the next frame + +.. note:: + + The code contains **generic** functions, so you may need to change some parts of the code so it is compatible with your setup. + +Source Code +----------- + +:: + + /* + This code is based on the algorithm described in the following paper: + Author(s): Joost van de Weijer, T. Gevers + Title: "Robust optical flow from photometric invariants" + Year: 2004 + DOI: 10.1109/ICIP.2004.1421433 + Link: https://www.researchgate.net/publication/4138051_Robust_optical_flow_from_photometric_invariants + */ + + float2 GetSphericalRG(float3 Color) + { + const float HalfPi = 1.0 / acos(0.0); + + // Precalculate (x*x + y*y)^0.5 and (x*x + y*y + z*z)^0.5 + float L1 = length(Color.rg); + float L2 = length(Color.rgb); + + float2 Angles = 0.0; + Angles[0] = (L1 == 0.0) ? 1.0 / sqrt(2.0) : Color.g / L1; + Angles[1] = (L2 == 0.0) ? 1.0 / sqrt(3.0) : L1 / L2; + + return saturate(asin(abs(Angles)) * HalfPi); + } + + float CMath_GetHalfMax() + { + // Get the Half format distribution of bits + // Sign Exponent Significand + // 0 00000 000000000 + const int SignBit = 0; + const int ExponentBits = 5; + const int SignificandBits = 10; + + const int Bias = -15; + const int Exponent = exp2(ExponentBits); + const int Significand = exp2(SignificandBits); + + const float MaxExponent = ((float)Exponent - (float)exp2(1)) + (float)Bias; + const float MaxSignificand = 1.0 + (((float)Significand - 1.0) / (float)Significand); + + return (float)pow(-1, SignBit) * (float)exp2(MaxExponent) * MaxSignificand; + } + + // [-HalfMax, HalfMax) -> [-1.0, 1.0) + float2 CMath_HalfToNorm(float2 Half2) + { + return clamp(Half2 / CMath_GetHalfMax(), -1.0, 1.0); + } + + // [-1.0, 1.0) -> [-HalfMax, HalfMax) + float2 CMath_NormToHalf(float2 Half2) + { + return Half2 * CMath_GetHalfMax(); + } + + // [-1.0, 1.0] -> [Width, Height] + float2 CMotionEstimation_UnnormalizeMV(float2 Vectors, float2 ImageSize) + { + return Vectors / abs(ImageSize); + } + + // [Width, Height] -> [-1.0, 1.0] + float2 CMotionEstimation_NormalizeMV(float2 Vectors, float2 ImageSize) + { + return clamp(Vectors * abs(ImageSize), -1.0, 1.0); + } + + /* + Lucas-Kanade optical flow with bilinear fetches + --- + Calculate Lucas-Kanade optical flow by solving (A^-1 * B) + [A11 A12]^-1 [-B1] -> [ A11/D -A12/D] [-B1] + [A21 A22]^-1 [-B2] -> [-A21/D A22/D] [-B2] + --- + [ Ix^2/D -IxIy/D] [-IxIt] + [-IxIy/D Iy^2/D] [-IyIt] + */ + + float2 CMotionEstimation_GetPixelPyLK + ( + float2 MainTex, // Texture coordinates in the [0.0, 1.0) range + float2 Vectors, // Vectors in the [-HalfMax, HalfMax) range + sampler2D SampleI0, + sampler2D SampleI1 + ) + { + // Initialize variables + float4 WarpTex; + float IxIx = 0.0; + float IyIy = 0.0; + float IxIy = 0.0; + float IxIt = 0.0; + float IyIt = 0.0; + float SSD = 0.0; + + // Initiate main & warped texture coordinates + WarpTex = MainTex.xyxy; + + // Calculate warped texture coordinates + WarpTex.zw -= 0.5; // Pull into [-0.5, 0.5) range + WarpTex.zw = CMath_NormToHalf(WarpTex.zw) + Vectors; // Warp in [-HalfMax, HalfMax) range + WarpTex.zw = CMath_HalfToNorm(WarpTex.zw) + 0.5; // Push into [0.0, 1.0) range + WarpTex.zw = saturate(WarpTex.zw); // Clamp into [0.0, 1.0) range + + // Get gradient information + float4 TexIx = ddx(WarpTex); + float4 TexIy = ddy(WarpTex); + float2 PixelSize = abs(TexIx.xy) + abs(TexIy.xy); + float2x2 Rotation = CMath_GetRotationMatrix(45.0); + + // Get required data to calculate main window data + const int WindowSize = 3; + const int WindowHalf = trunc(WindowSize / 2); + + [loop] for (int i = 0; i < (WindowSize * WindowSize); i++) + { + float2 AngleShift = -WindowHalf + float2(i % WindowSize, trunc(i / WindowSize)); + AngleShift = mul(Rotation, AngleShift); + + // Get temporal gradient + float4 TexIT = WarpTex.xyzw + (AngleShift.xyxy * PixelSize.xyxy); + float2 I0 = tex2Dgrad(SampleI0, TexIT.xy, TexIx.xy, TexIy.xy).rg; + float2 I1 = tex2Dgrad(SampleI1, TexIT.zw, TexIx.zw, TexIy.zw).rg; + float2 IT = I0 - I1; + + // Get spatial gradient + float4 OffsetNS = AngleShift.xyxy + float4(0.0, -1.0, 0.0, 1.0); + float4 OffsetEW = AngleShift.xyxy + float4(-1.0, 0.0, 1.0, 0.0); + float4 NS = WarpTex.xyxy + (OffsetNS * PixelSize.xyxy); + float4 EW = WarpTex.xyxy + (OffsetEW * PixelSize.xyxy); + float2 N = tex2Dgrad(SampleI0, NS.xy, TexIx.xy, TexIy.xy).rg; + float2 S = tex2Dgrad(SampleI0, NS.zw, TexIx.xy, TexIy.xy).rg; + float2 E = tex2Dgrad(SampleI0, EW.xy, TexIx.xy, TexIy.xy).rg; + float2 W = tex2Dgrad(SampleI0, EW.zw, TexIx.xy, TexIy.xy).rg; + float2 Ix = E - W; + float2 Iy = N - S; + + // IxIx = A11; IyIy = A22; IxIy = A12/A22 + IxIx += dot(Ix, Ix); + IyIy += dot(Iy, Iy); + IxIy += dot(Ix, Iy); + + // IxIt = B1; IyIt = B2 + IxIt += dot(Ix, IT); + IyIt += dot(Iy, IT); + + SSD += dot(IT, IT); + } + + /* + Calculate Lucas-Kanade matrix + --- + [ Ix^2/D -IxIy/D] [-IxIt] + [-IxIy/D Iy^2/D] [-IyIt] + */ + + /* + Create a normalized SSD-based mask. + https://www.cs.huji.ac.il/~peleg/papers/HUJI-CSE-LTR-2006-39-LK-Plus.pdf + */ + + float M = (SSD / (IxIx + IyIy)) > 0.1; + IxIx *= M; + IyIy *= M; + IxIy *= M; + IxIt *= M; + IyIt *= M; + + // Calculate A^-1 and B + float D = determinant(float2x2(IxIx, IxIy, IxIy, IyIy)); + float2x2 A = float2x2(IyIy, -IxIy, -IxIy, IxIx) / D; + float2 B = float2(-IxIt, -IyIt); + + // Calculate A^T*B + float2 Flow = (D > 0.0) ? mul(B, A) : 0.0; + + // Convert motion vectors from Half -> Norm + Vectors = CMath_HalfToNorm(Vectors); + + // Propagate normalized motion vectors in Norm Range + Vectors += CMotionEstimation_NormalizeMV(Flow, PixelSize); + + // Clamp motion vectors to restrict range to valid lengths + Vectors = clamp(Vectors, -1.0, 1.0); + + // Pack motion vectors to Half format + return CMath_NormToHalf(Vectors); + } diff --git a/_sources/source/blog/outerralogdepth.rst.txt b/_sources/source/blog/outerralogdepth.rst.txt new file mode 100644 index 0000000..29d6e31 --- /dev/null +++ b/_sources/source/blog/outerralogdepth.rst.txt @@ -0,0 +1,18 @@ + +Correcting Outerra's Logarithmic Depth Buffering +================================================ + +`Outerra has a vertex shader implementation of log depth buffering in GLSL `_. However, Outerra missed a major part of their log depth buffering. This is our corrected version of Outerra’s log depth buffering in HLSL. + +Outerra missed a multiply in the end. We must multiply log depth by ``W`` because the GPU automatically divides the vertex position ``HPos`` by ``W``. + +Source Code +----------- + +:: + + // Output.HPos is the computed vertex position in homogeneous space + const float FarPlane = 10000.0; + const float FCoef = 1.0 / log2(FarPlane + 1.0); + Output.HPos.z = saturate(log2(max(1e-6, Output.HPos.w)) * FCoef); + Output.HPos.z *= Output.HPos.w; diff --git a/_sources/source/blog/pythonengine.rst.txt b/_sources/source/blog/pythonengine.rst.txt new file mode 100644 index 0000000..86da7ef --- /dev/null +++ b/_sources/source/blog/pythonengine.rst.txt @@ -0,0 +1,58 @@ + +A Pythonic 3D Engine in 1 Weekend +================================= + +I spent this weekend following `Coder Space's Python 3D engine tutorial series `_. The tutorial covered the fundamentals of the OpenGL pipeline, from the CPU to the GPU. + +Video 1: Main Tutorial +---------------------- + +I learned about the OpenGL pipeline, starting from the CPU to the GPU. The first tutorial taught me how to… + +#. Render basic geometry +#. Add a camera to a scene +#. Add Phong lighting into a scene +#. Refactor code to re-use buffer object data +#. Use Uniform transformations +#. Adopt Best practices in rendering + + - Mipmapping + - Gamma correction + +#. Load external 3D models + +.. note:: + + I learned that VBOs are unformatted, allocated spaces of memory that store vertex-related data. However, we can use buffer objects for purposes other than being a VBO. + +Video 2: SkyBox, Environment Mapping +------------------------------------ + +I created a skybox for the rendering scene. The second tutorial taught me how to… + +#. Refactor code with polymorphism +#. Make cube-maps with faces +#. Replace cube-based skybox with plane-based skybox + +.. note:: + + Implementing a plane-based skybox was difficult, to say the least. + +Video 3: Shadow Mapping, PCF +---------------------------- + +I just created a smooth shadow-mapping system for objects. + +Feedback +-------- + +As someone who wanted to learn the graphics programming fundamentals, I found this series enjoyable to follow. I believe this tutorial can reach the masses if it also covers… + +- Instancing +- Deferred rendering +- Generating vertex normal and tangent + +Recommendation +-------------- + +I recommend this tutorial for people who already have experience with Python and want to get straight to crafting graphics. Thank you, Coder Space! diff --git a/_sources/source/blog/reshadefx.rst.txt b/_sources/source/blog/reshadefx.rst.txt new file mode 100644 index 0000000..30d718f --- /dev/null +++ b/_sources/source/blog/reshadefx.rst.txt @@ -0,0 +1,125 @@ + +ReShadeFX for Beginners +======================= + +No bullshit, just move along. + +Recap + :Vertex Shader: Code that does math on every vertex + :Pixel Shader: Code that does math on every pixel + +What is a Shader? +----------------- + +A shader is code that does math. + +A shader is like a drawing a square. Here is how you draw a red square: + +#. You draw a dotted outline of the square. +#. You connect the dotted outline of the square. +#. You color red inside the square. + +Your First Vertex Shader +------------------------ + +.. code:: + :number-lines: + + // Vertex shader generating a triangle covering the entire screen. + // See also https://www.reddit.com/r/gamedev/comments/2j17wk/a_slightly_faster_bufferless_vertex_shader_trick/ + + // Make a function that calculate on each vertex. + // PostProcessVS() outputs a triangle that is twice the screen's size. + void PostProcessVS + ( + in uint id : SV_VertexID, // Get "id" from CPU memory named "SV_VertexID" + out float4 position : SV_Position, // Send "position" to GPU memory named "SV_Position" + out float2 texcoord : TEXCOORD // Send "texcoord" to GPU memory named "TEXCOORD" + ) + { + /* + PART 1 + --- + Use the vertex's ID to calculate its texture coordinates. + NOTE: Texture coordinates are 0-1 + --- + ID 0 -> texcoord (0.0, 0.0) + ID 1 -> texcoord (0.0, 2.0) + ID 2 -> texcoord (2.0, 0.0) + */ + + // If the vertex's ID is 2, set the its texcoord's X position to 2. + // If the vertex's ID is not 2, set its texcoord's X position to 0. + texcoord.x = (id == 2) ? 2.0 : 0.0; + + // If the vertex's ID is 1, set the its texcoord's Y position to 2. + // If the vertex's ID is not 1, set its texcoord's Y position to 0. + texcoord.y = (id == 1) ? 2.0 : 0.0; + + /* + PART 2 + --- + We stretch the triangle to be twice the size of the screen. + To do this, use the vertex's texture coordinates to calculate it's position in clip-space. + + In clip-space, the values represent: + Bottom-left of screen: (-1.0, -1.0) + Bottom-right of screen: (1.0, -1.0) + Top-left of screen: (-1.0, 1.0) + Top-right of screen: (1.0, 1.0) + --- + texcoord (0.0, 0.0) -> position (-1.0, 1.0) + texcoord (0.0, 2.0) -> position (-1.0, 3.0) + texcoord (2.0, 0.0) -> position (3.0, 1.0) + */ + + position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0); + + /* + PART 3 + --- + 1. The GPU will "clip" fragments that have a position beyond -1 or 1. + 2. The GPU will interpolate the "texcoord" and "position" data between vertices + */ + } + +Your First Pixel Shader +----------------------- + +.. code:: + :number-lines: + + // Make a function that calculate on each pixel. + // PostProcessPS() outputs a color on each of the triangle's pixel. + void PostProcessPS + ( + in float2 texcoord : TEXCOORD, // Get "texcoord" from GPU memory named "TEXCOORD" + out float4 color : SV_Target // Send "color" to GPU memory named "SV_Target" + ) + { + /* + Use the texcoord's XY value to set the triangle's red and green value. + texcoord(1.0, 0.0) -> color(1.0, 0.0, 0.0, 1.0) -> all red + texcoord(0.0, 1.0) -> color(1.0, 0.0, 0.0, 1.0) -> all green + texcoord(1.0, 1.0) -> color(1.0, 1.0, 0.0, 1.0) -> mix of red and green + */ + color.r = texcoord.x; + color.g = texcoord.y; + color.b = 0.0; + color.a = 1.0; + } + +Your First Technique +-------------------- + +.. code:: + :number-lines: + + technique ExampleShader + { + pass + { + VertexShader = PostProcessVS; + PixelShader = PostProcessPS; + } + } diff --git a/_sources/source/blog/shadermodel3.rst.txt b/_sources/source/blog/shadermodel3.rst.txt new file mode 100644 index 0000000..f0930a0 --- /dev/null +++ b/_sources/source/blog/shadermodel3.rst.txt @@ -0,0 +1,119 @@ + +Project Reality: Shader Model 3.0 Considerations +================================================ + +`The Project Reality Team `_ updated Project Reality to support Shader Model 3. The update gave Project Reality more graphical potential. This post considerations when porting shaders from Shader Model 2 to 3. + +Fogging +------- + +From Shader Model 3, fogging is no longer fixed-function. You must implement your fogging method in the pixel shader. + +Output Register Count +--------------------- + +- `Shader Model 2 vertex shaders have a certain number of output registers for each type of data `__. + + :oPos: 1 position + :oFog: 1 fog + :oPts: 1 point-size + :oD#: 2 vertex color + :oT#: 8 texture coordinate + +- In Shader Model 3, you have 12 output registers available for any type of data. + +Input Register Format +--------------------- + +- In Shader Model 2, output registers have different levels of precision. + + For example, `vertex color registers, like oD#, are 8 bits of unsigned data, in the range of 0-1 in the pixel shader `_. + +- When you port vertex colors ``oD#`` from Shader Model 2 to 3, you must apply ``saturate()`` to the vertex color output. + +Register Assignments and Declarations +------------------------------------- + +If you encounter the following asm, with constants not declared in ASM. + +:: + + VertexShader = asm + { + vs.1.1 + + dcl_position0 v0 + + add r0.xyz, v0.xzw, -c[0].xyz + mul r0.xyz, r0.xyz, c[1].xyw // z = 0, w = 1 + add oPos.x, r0.x, -c[1].w + add oPos.y, r0.y, -c[1].w + mov oPos.z, r0.z + mov oPos.w, c[1].w // z = 0, w = 1 + add r1, v0.y, -c[2].x + mul oD0, r1, c[2].y + mov oD0.a, c[1].z // z = 0 + }; + + PixelShader = asm + { + ps.1.1 + mov r0, v0 + }; + +The solution: use the ``: register()`` to a shader variable to a particular register. You can read more about it `here `_. + +:: + + // Assign variables to registers because DICE didn't do so in their ASM. + float4 Constant0 : register(c0); // c[0] + float4 Constant1 : register(c1); // c[1] + float4 Constant2 : register(c2); // c[2] + + struct APP2PS_ProjectRoad + { + float4 Pos : POSITION0; + }; + + struct VS2PS_ProjectRoad + { + float4 HPos : POSITION; + float4 Color : TEXCOORD0; + }; + + // VertexShader + VS2PS_ProjectRoad VS_ProjectRoad(APP2PS_ProjectRoad Input) + { + VS2PS_ProjectRoad Output = (VS2PS_ProjectRoad)0.0; + + // add r0.xyz, v0.xzw, -c[0].xyz + // mul r0.xyz, r0.xyz, c[1].xyw // z = 0, w = 1 + float3 ProjPos = Input.Pos.xzw - Constant0.xyz; + ProjPos *= Constant1.xyw; // z = 0, w = 1 + + // add oPos.x, r0.x, -c[1].w + // add oPos.y, r0.y, -c[1].w + // mov oPos.z, r0.z + // mov oPos.w, c[1].w // z = 0, w = 1 + Output.HPos.x = ProjPos.x - Constant1.w; + Output.HPos.y = ProjPos.y - Constant1.w; + Output.HPos.z = ProjPos.z; + Output.HPos.w = Constant1.w; // z = 0, w = 1 + + // add r1, v0.y, -c[2].x + // mul oD0, r1, c[2].y + // mov oD0.a, c[1].z // z = 0 + float4 Color = Input.Pos.y - Constant2.x; + Output.Color = Color * Constant2.y; + Output.Color.a = Constant1.z; // z = 0 + Output.Color = saturate(Output.Color); + + return Output; + } + + // PixelShader + float4 PS_ProjectRoad(VS2PS_ProjectRoad Input) : COLOR0 + { + // mov r0, v0 + return Input.Color; + } diff --git a/_sources/source/blog/sobel.rst.txt b/_sources/source/blog/sobel.rst.txt new file mode 100644 index 0000000..1b1f3bb --- /dev/null +++ b/_sources/source/blog/sobel.rst.txt @@ -0,0 +1,28 @@ + +Bilinear Sobel Filtering in HLSL +================================ + +The Sobel filter requires you to sample 8 pixels around the center pixel. The filter is linear, so you can sample 8 pixels in 4 texture fetches by sampling in-between pixels. + +Source Code +----------- + +:: + + struct Sobel + { + float4 Ix; + float4 Iy; + }; + + Sobel GetSobel(sampler SampleImage, float2 Tex, float2 PixelSize) + { + Sobel Output; + float4 A = tex2D(SampleImage, Tex + (float2(-0.5, +0.5) * PixelSize)); + float4 B = tex2D(SampleImage, Tex + (float2(+0.5, +0.5) * PixelSize)); + float4 C = tex2D(SampleImage, Tex + (float2(-0.5, -0.5) * PixelSize)); + float4 D = tex2D(SampleImage, Tex + (float2(+0.5, -0.5) * PixelSize)); + Output.Ix = (B + D) - (A + C); + Output.Iy = (A + B) - (C + D); + return Output; + } diff --git a/_sources/source/social/instagram.rst.txt b/_sources/source/social/instagram.rst.txt new file mode 100644 index 0000000..3e7f900 --- /dev/null +++ b/_sources/source/social/instagram.rst.txt @@ -0,0 +1,38 @@ + +Instagram +========= + +Account +------- + +Requirements +^^^^^^^^^^^^ + +#. Description of the creator +#. Other links (if possible) + +Posts +----- + +Requirements +^^^^^^^^^^^^ + +#. No Instagram filters or cropping +#. At least 1 sentence on what the content is about +#. Only 3 to 5 hashtags + + - Hashtags must be relevant + - Hashtags must be different + - Hashtag set must be mix of well known and niche + +Templates +--------- + +Uploading Images +^^^^^^^^^^^^^^^^ + +:: + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + + #hashtag1 #hashtag2 #hashtag3 diff --git a/_sources/source/social/project.rst.txt b/_sources/source/social/project.rst.txt new file mode 100644 index 0000000..f4dffb3 --- /dev/null +++ b/_sources/source/social/project.rst.txt @@ -0,0 +1,34 @@ + +Personal Project +================ + +Tools +----- + +`Davinci Resolve `_ + Editing and compositing Video +`FFmpeg `_ + Media conversion, used with `yt-dlp` +`OBS Studio `_ + Desktop recording +`yt-dlp `_ + Downloading media + +Downloads +--------- + +- :download:`Davinci Resolve: Video Templates (Project Reality) <../../_downloads/Video Templates (Project Reality).drp>` + +Useful Commands +--------------- + +yt-dlp +^^^^^^ + +.. describe:: yt-dlp -f bv+ba + + Downloads the best video and audio from a link. + +.. describe:: yt-dlp -f bv+ba -a <.txt file path> + + Downloads the best video and audio from a list. diff --git a/_sources/source/social/youtube.rst.txt b/_sources/source/social/youtube.rst.txt new file mode 100644 index 0000000..81b3ea1 --- /dev/null +++ b/_sources/source/social/youtube.rst.txt @@ -0,0 +1,101 @@ + +YouTube +======= + +Account Requirements +-------------------- + +#. Description of the channel +#. Methods of contact (if possible) +#. Other links (if possible) + +Video Requirements +------------------ + +#. Description + + #. **At least 1 sentence** on what the video is about + #. Timecodes (if needed) + #. **All** sources used in the video, including their respective authors + #. **Only 3** hashtags related to the video + + - Hashtags must be **relevant** + - Hashtags must be **different** + - Hashtag set must be **mix of well known and niche** + - **Re-use** hashtags across similar videos, especially if they share a playlist. + + #. **No** unnecessary keywords + +#. **High-definition** thumbnails +#. Associated playlist(s) +#. **Only 3 to 5** tags + + - Tags should be **lower-case** + - Tags should be left-to-right, from **least-to-most** specific + - **Re-use** hashtags across similar videos, especially if they share a playlist. + +#. Appropriate category +#. **Scheduled at 12:00am** before the following.. + + - Weekends (Friday and Saturday) + - Related events, such as holidays + +Video Template +-------------- + +.. list-table:: + :header-rows: 1 + + * - Title + - Playlist + - Tags + - Category + * - Video Name • Video Subject + - Generic Playlist + - alternative title 1, alternative title 2, alternative title 3 + - People & Blogs + +:: + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + + 0:00 | Event 1 + 1:00 | Event 2 + + *Links* + • Link 1 Name: Link + • Link 2 Name: Link + + *Products in This Video* + • Product Link 1: Link + • Product Link 2: Link + + Product description... + + *Audio Sources* + • Recording Name (Author Name): Link + • Song Name (Author Name): Link + + *Video Sources* + • Channel Name: Link + • Video Name (Author Name): Link + • Video Re-upload Name (Re-upload Author Name, Original Author: Original Author Name): Link + + *What I Used to Make This Video* + • Tool 1: Link + • Tool 2: Link + + *Notes* + • Rhoncus urna neque viverra justo nec ultrices dui sapien. + + *Disclaimer* + • For non-commercial purposes only. Feel free to claim this video content if you own the song. + + #hashtag1 #hashtag2 #hashtag3 + + +.. note:: + **Do not** include ``Author Name`` if they are already included in the source's name. + + :No: Project Reality Standalone Trailer (Project Reality): https://youtu.be/vkYX41j6ZbA + :Yes: Project Reality Standalone Trailer: https://youtu.be/vkYX41j6ZbA diff --git a/_static/alabaster.css b/_static/alabaster.css new file mode 100644 index 0000000..c0bbec9 --- /dev/null +++ b/_static/alabaster.css @@ -0,0 +1,668 @@ +/* -- page layout ----------------------------------------------------------- */ + +body { + font-family: Georgia, serif; + font-size: 17px; + background-color: #fff; + color: #000; + margin: 0; + padding: 0; +} + + +div.document { + width: 80rem; + margin: 30px auto 0 auto; +} + +div.documentwrapper { + float: left; + width: 100%; +} + +div.bodywrapper { + margin: 0 0 0 20rem; +} + +div.sphinxsidebar { + width: 20rem; + font-size: 14px; + line-height: 1.5; +} + +hr { + border: 1px solid #B1B4B6; +} + +div.body { + background-color: #fff; + color: #3E4349; + padding: 0 30px 0 30px; +} + +div.body > .section { + text-align: left; +} + +div.footer { + width: 80rem; + margin: 20px auto 30px auto; + font-size: 14px; + color: #888; + text-align: right; +} + +div.footer a { + color: #888; +} + +p.caption { + font-family: inherit; + font-size: inherit; +} + + +div.relations { + display: none; +} + + +div.sphinxsidebar { + max-height: 100%; + overflow-y: auto; +} + +div.sphinxsidebar a { + color: #444; + text-decoration: none; + border-bottom: 1px dotted #999; +} + +div.sphinxsidebar a:hover { + border-bottom: 1px solid #999; +} + +div.sphinxsidebarwrapper { + padding: 18px 10px; +} + +div.sphinxsidebarwrapper p.logo { + padding: 0; + margin: -10px 0 0 0px; + text-align: center; +} + +div.sphinxsidebarwrapper h1.logo { + margin-top: -10px; + text-align: center; + margin-bottom: 5px; + text-align: left; +} + +div.sphinxsidebarwrapper h1.logo-name { + margin-top: 0px; +} + +div.sphinxsidebarwrapper p.blurb { + margin-top: 0; + font-style: normal; +} + +div.sphinxsidebar h3, +div.sphinxsidebar h4 { + font-family: Georgia, serif; + color: #444; + font-size: 24px; + font-weight: normal; + margin: 0 0 5px 0; + padding: 0; +} + +div.sphinxsidebar h4 { + font-size: 20px; +} + +div.sphinxsidebar h3 a { + color: #444; +} + +div.sphinxsidebar p.logo a, +div.sphinxsidebar h3 a, +div.sphinxsidebar p.logo a:hover, +div.sphinxsidebar h3 a:hover { + border: none; +} + +div.sphinxsidebar p { + color: #555; + margin: 10px 0; +} + +div.sphinxsidebar ul { + margin: 10px 0; + padding: 0; + color: #000; +} + +div.sphinxsidebar ul li.toctree-l1 > a { + font-size: 120%; +} + +div.sphinxsidebar ul li.toctree-l2 > a { + font-size: 110%; +} + +div.sphinxsidebar input { + border: 1px solid #CCC; + font-family: Georgia, serif; + font-size: 1em; +} + +div.sphinxsidebar #searchbox { + margin: 1em 0; +} + +div.sphinxsidebar .search > div { + display: table-cell; +} + +div.sphinxsidebar hr { + border: none; + height: 1px; + color: #AAA; + background: #AAA; + + text-align: left; + margin-left: 0; + width: 50%; +} + +div.sphinxsidebar .badge { + border-bottom: none; +} + +div.sphinxsidebar .badge:hover { + border-bottom: none; +} + +/* To address an issue with donation coming after search */ +div.sphinxsidebar h3.donation { + margin-top: 10px; +} + +/* -- body styles ----------------------------------------------------------- */ + +a { + color: #004B6B; + text-decoration: underline; +} + +a:hover { + color: #6D4100; + text-decoration: underline; +} + +div.body h1, +div.body h2, +div.body h3, +div.body h4, +div.body h5, +div.body h6 { + font-family: Georgia, serif; + font-weight: normal; + margin: 30px 0px 10px 0px; + padding: 0; +} + +div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; } +div.body h2 { font-size: 180%; } +div.body h3 { font-size: 150%; } +div.body h4 { font-size: 130%; } +div.body h5 { font-size: 100%; } +div.body h6 { font-size: 100%; } + +a.headerlink { + color: #DDD; + padding: 0 4px; + text-decoration: none; +} + +a.headerlink:hover { + color: #444; + background: #EAEAEA; +} + +div.body p, div.body dd, div.body li { + line-height: 1.4em; +} + +div.admonition { + margin: 20px 0px; + padding: 10px 30px; + background-color: #EEE; + border: 1px solid #CCC; +} + +div.admonition tt.xref, div.admonition code.xref, div.admonition a tt { + background-color: #FBFBFB; + border-bottom: 1px solid #fafafa; +} + +div.admonition p.admonition-title { + font-family: Georgia, serif; + font-weight: normal; + font-size: 24px; + margin: 0 0 10px 0; + padding: 0; + line-height: 1; +} + +div.admonition p.last { + margin-bottom: 0; +} + +dt:target, .highlight { + background: #FAF3E8; +} + +div.warning { + background-color: #FCC; + border: 1px solid #FAA; +} + +div.danger { + background-color: #FCC; + border: 1px solid #FAA; + -moz-box-shadow: 2px 2px 4px #D52C2C; + -webkit-box-shadow: 2px 2px 4px #D52C2C; + box-shadow: 2px 2px 4px #D52C2C; +} + +div.error { + background-color: #FCC; + border: 1px solid #FAA; + -moz-box-shadow: 2px 2px 4px #D52C2C; + -webkit-box-shadow: 2px 2px 4px #D52C2C; + box-shadow: 2px 2px 4px #D52C2C; +} + +div.caution { + background-color: #FCC; + border: 1px solid #FAA; +} + +div.attention { + background-color: #FCC; + border: 1px solid #FAA; +} + +div.important { + background-color: #EEE; + border: 1px solid #CCC; +} + +div.note { + background-color: #EEE; + border: 1px solid #CCC; +} + +div.tip { + background-color: #EEE; + border: 1px solid #CCC; +} + +div.hint { + background-color: #EEE; + border: 1px solid #CCC; +} + +div.seealso { + background-color: #EEE; + border: 1px solid #CCC; +} + +div.topic { + background-color: #EEE; +} + +p.admonition-title { + display: inline; +} + +p.admonition-title:after { + content: ":"; +} + +pre, tt, code { + font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; + font-size: 0.9em; +} + +.hll { + background-color: #FFC; + margin: 0 -12px; + padding: 0 12px; + display: block; +} + +img.screenshot { +} + +tt.descname, tt.descclassname, code.descname, code.descclassname { + font-size: 0.95em; +} + +tt.descname, code.descname { + padding-right: 0.08em; +} + +img.screenshot { + -moz-box-shadow: 2px 2px 4px #EEE; + -webkit-box-shadow: 2px 2px 4px #EEE; + box-shadow: 2px 2px 4px #EEE; +} + +table.docutils { + border: 1px solid #888; + -moz-box-shadow: 2px 2px 4px #EEE; + -webkit-box-shadow: 2px 2px 4px #EEE; + box-shadow: 2px 2px 4px #EEE; +} + +table.docutils td, table.docutils th { + border: 1px solid #888; + padding: 0.25em 0.7em; +} + +table.field-list, table.footnote { + border: none; + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +table.footnote { + margin: 15px 0; + width: 100%; + border: 1px solid #EEE; + background: #FDFDFD; + font-size: 0.9em; +} + +table.footnote + table.footnote { + margin-top: -15px; + border-top: none; +} + +table.field-list th { + padding: 0 0.8em 0 0; +} + +table.field-list td { + padding: 0; +} + +table.field-list p { + margin-bottom: 0.8em; +} + +/* Cloned from + * https://github.com/sphinx-doc/sphinx/commit/ef60dbfce09286b20b7385333d63a60321784e68 + */ +.field-name { + -moz-hyphens: manual; + -ms-hyphens: manual; + -webkit-hyphens: manual; + hyphens: manual; +} + +table.footnote td.label { + width: .1px; + padding: 0.3em 0 0.3em 0.5em; +} + +table.footnote td { + padding: 0.3em 0.5em; +} + +dl { + margin-left: 0; + margin-right: 0; + margin-top: 0; + padding: 0; +} + +dl dd { + margin-left: 30px; +} + +blockquote { + margin: 0 0 0 30px; + padding: 0; +} + +ul, ol { + /* Matches the 30px from the narrow-screen "li > ul" selector below */ + margin: 10px 0 10px 30px; + padding: 0; +} + +pre { + background: unset; + padding: 7px 30px; + margin: 15px 0px; + line-height: 1.3em; +} + +div.viewcode-block:target { + background: #ffd; +} + +dl pre, blockquote pre, li pre { + margin-left: 0; + padding-left: 30px; +} + +tt, code { + background-color: #ecf0f3; + color: #222; + /* padding: 1px 2px; */ +} + +tt.xref, code.xref, a tt { + background-color: #FBFBFB; + border-bottom: 1px solid #fff; +} + +a.reference { + text-decoration: none; + border-bottom: 1px dotted #004B6B; +} + +a.reference:hover { + border-bottom: 1px solid #6D4100; +} + +/* Don't put an underline on images */ +a.image-reference, a.image-reference:hover { + border-bottom: none; +} + +a.footnote-reference { + text-decoration: none; + font-size: 0.7em; + vertical-align: top; + border-bottom: 1px dotted #004B6B; +} + +a.footnote-reference:hover { + border-bottom: 1px solid #6D4100; +} + +a:hover tt, a:hover code { + background: #EEE; +} +div.sphinxsidebar { + position: fixed; + margin-left: 0; +} + +@media screen and (max-width: 80rem) { + + body { + margin: 0; + padding: 20px 30px; + } + + div.documentwrapper { + float: none; + background: #fff; + margin-left: 0; + margin-top: 0; + margin-right: 0; + margin-bottom: 0; + } + + div.sphinxsidebar { + display: block; + float: none; + width: unset; + margin: -20px -30px 20px -30px; + position: static; + padding: 10px 20px; + background: #333; + color: #FFF; + } + + div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p, + div.sphinxsidebar h3 a { + color: #fff; + } + + div.sphinxsidebar a { + color: #AAA; + } + + div.sphinxsidebar p.logo { + display: none; + } + + div.document { + width: 100%; + margin: 0; + } + + div.footer { + display: none; + } + + div.bodywrapper { + margin: 0; + } + + div.body { + min-height: 0; + min-width: auto; /* fixes width on small screens, breaks .hll */ + padding: 0; + } + + .hll { + /* "fixes" the breakage */ + width: max-content; + } + + .rtd_doc_footer { + display: none; + } + + .document { + width: auto; + } + + .footer { + width: auto; + } + + .github { + display: none; + } + + ul { + margin-left: 0; + } + + li > ul { + /* Matches the 30px from the "ul, ol" selector above */ + margin-left: 30px; + } +} + + +/* misc. */ + +.revsys-inline { + display: none!important; +} + +/* Hide ugly table cell borders in ..bibliography:: directive output */ +table.docutils.citation, table.docutils.citation td, table.docutils.citation th { + border: none; + /* Below needed in some edge cases; if not applied, bottom shadows appear */ + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} + + +/* relbar */ + +.related { + line-height: 30px; + width: 100%; + font-size: 0.9rem; +} + +.related.top { + border-bottom: 1px solid #EEE; + margin-bottom: 20px; +} + +.related.bottom { + border-top: 1px solid #EEE; +} + +.related ul { + padding: 0; + margin: 0; + list-style: none; +} + +.related li { + display: inline; +} + +nav#rellinks { + float: right; +} + +nav#rellinks li+li:before { + content: "|"; +} + +nav#breadcrumbs li+li:before { + content: "\00BB"; +} + +/* Hide certain items when printing */ +@media print { + div.related { + display: none; + } +} + +img.github { + position: absolute; + top: 0; + border: 0; + right: 0; +} \ No newline at end of file diff --git a/_static/basic.css b/_static/basic.css new file mode 100644 index 0000000..e5179b7 --- /dev/null +++ b/_static/basic.css @@ -0,0 +1,925 @@ +/* + * basic.css + * ~~~~~~~~~ + * + * Sphinx stylesheet -- basic theme. + * + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +/* -- main layout ----------------------------------------------------------- */ + +div.clearer { + clear: both; +} + +div.section::after { + display: block; + content: ''; + clear: left; +} + +/* -- relbar ---------------------------------------------------------------- */ + +div.related { + width: 100%; + font-size: 90%; +} + +div.related h3 { + display: none; +} + +div.related ul { + margin: 0; + padding: 0 0 0 10px; + list-style: none; +} + +div.related li { + display: inline; +} + +div.related li.right { + float: right; + margin-right: 5px; +} + +/* -- sidebar --------------------------------------------------------------- */ + +div.sphinxsidebarwrapper { + padding: 10px 5px 0 10px; +} + +div.sphinxsidebar { + float: left; + width: 230px; + margin-left: -100%; + font-size: 90%; + word-wrap: break-word; + overflow-wrap : break-word; +} + +div.sphinxsidebar ul { + list-style: none; +} + +div.sphinxsidebar ul ul, +div.sphinxsidebar ul.want-points { + margin-left: 20px; + list-style: square; +} + +div.sphinxsidebar ul ul { + margin-top: 0; + margin-bottom: 0; +} + +div.sphinxsidebar form { + margin-top: 10px; +} + +div.sphinxsidebar input { + border: 1px solid #98dbcc; + font-family: sans-serif; + font-size: 1em; +} + +div.sphinxsidebar #searchbox form.search { + overflow: hidden; +} + +div.sphinxsidebar #searchbox input[type="text"] { + float: left; + width: 80%; + padding: 0.25em; + box-sizing: border-box; +} + +div.sphinxsidebar #searchbox input[type="submit"] { + float: left; + width: 20%; + border-left: none; + padding: 0.25em; + box-sizing: border-box; +} + + +img { + border: 0; + max-width: 100%; +} + +/* -- search page ----------------------------------------------------------- */ + +ul.search { + margin: 10px 0 0 20px; + padding: 0; +} + +ul.search li { + padding: 5px 0 5px 20px; + background-image: url(file.png); + background-repeat: no-repeat; + background-position: 0 7px; +} + +ul.search li a { + font-weight: bold; +} + +ul.search li p.context { + color: #888; + margin: 2px 0 0 30px; + text-align: left; +} + +ul.keywordmatches li.goodmatch a { + font-weight: bold; +} + +/* -- index page ------------------------------------------------------------ */ + +table.contentstable { + width: 90%; + margin-left: auto; + margin-right: auto; +} + +table.contentstable p.biglink { + line-height: 150%; +} + +a.biglink { + font-size: 1.3em; +} + +span.linkdescr { + font-style: italic; + padding-top: 5px; + font-size: 90%; +} + +/* -- general index --------------------------------------------------------- */ + +table.indextable { + width: 100%; +} + +table.indextable td { + text-align: left; + vertical-align: top; +} + +table.indextable ul { + margin-top: 0; + margin-bottom: 0; + list-style-type: none; +} + +table.indextable > tbody > tr > td > ul { + padding-left: 0em; +} + +table.indextable tr.pcap { + height: 10px; +} + +table.indextable tr.cap { + margin-top: 10px; + background-color: #f2f2f2; +} + +img.toggler { + margin-right: 3px; + margin-top: 3px; + cursor: pointer; +} + +div.modindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +div.genindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +/* -- domain module index --------------------------------------------------- */ + +table.modindextable td { + padding: 2px; + border-collapse: collapse; +} + +/* -- general body styles --------------------------------------------------- */ + +div.body { + min-width: inherit; + max-width: 800px; +} + +div.body p, div.body dd, div.body li, div.body blockquote { + -moz-hyphens: auto; + -ms-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +a.headerlink { + visibility: hidden; +} + +a:visited { + color: #551A8B; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink, +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { + visibility: visible; +} + +div.body p.caption { + text-align: inherit; +} + +div.body td { + text-align: left; +} + +.first { + margin-top: 0 !important; +} + +p.rubric { + margin-top: 30px; + font-weight: bold; +} + +img.align-left, figure.align-left, .figure.align-left, object.align-left { + clear: left; + float: left; + margin-right: 1em; +} + +img.align-right, figure.align-right, .figure.align-right, object.align-right { + clear: right; + float: right; + margin-left: 1em; +} + +img.align-center, figure.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +img.align-default, figure.align-default, .figure.align-default { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left; +} + +.align-center { + text-align: center; +} + +.align-default { + text-align: center; +} + +.align-right { + text-align: right; +} + +/* -- sidebars -------------------------------------------------------------- */ + +div.sidebar, +aside.sidebar { + margin: 0 0 0.5em 1em; + border: 1px solid #ddb; + padding: 7px; + background-color: #ffe; + width: 40%; + float: right; + clear: right; + overflow-x: auto; +} + +p.sidebar-title { + font-weight: bold; +} + +nav.contents, +aside.topic, +div.admonition, div.topic, blockquote { + clear: left; +} + +/* -- topics ---------------------------------------------------------------- */ + +nav.contents, +aside.topic, +div.topic { + border: 1px solid #ccc; + padding: 7px; + margin: 10px 0 10px 0; +} + +p.topic-title { + font-size: 1.1em; + font-weight: bold; + margin-top: 10px; +} + +/* -- admonitions ----------------------------------------------------------- */ + +div.admonition { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; +} + +div.admonition dt { + font-weight: bold; +} + +p.admonition-title { + margin: 0px 10px 5px 0px; + font-weight: bold; +} + +div.body p.centered { + text-align: center; + margin-top: 25px; +} + +/* -- content of sidebars/topics/admonitions -------------------------------- */ + +div.sidebar > :last-child, +aside.sidebar > :last-child, +nav.contents > :last-child, +aside.topic > :last-child, +div.topic > :last-child, +div.admonition > :last-child { + margin-bottom: 0; +} + +div.sidebar::after, +aside.sidebar::after, +nav.contents::after, +aside.topic::after, +div.topic::after, +div.admonition::after, +blockquote::after { + display: block; + content: ''; + clear: both; +} + +/* -- tables ---------------------------------------------------------------- */ + +table.docutils { + margin-top: 10px; + margin-bottom: 10px; + border: 0; + border-collapse: collapse; +} + +table.align-center { + margin-left: auto; + margin-right: auto; +} + +table.align-default { + margin-left: auto; + margin-right: auto; +} + +table caption span.caption-number { + font-style: italic; +} + +table caption span.caption-text { +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 5px; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #aaa; +} + +th { + text-align: left; + padding-right: 5px; +} + +table.citation { + border-left: solid 1px gray; + margin-left: 1px; +} + +table.citation td { + border-bottom: none; +} + +th > :first-child, +td > :first-child { + margin-top: 0px; +} + +th > :last-child, +td > :last-child { + margin-bottom: 0px; +} + +/* -- figures --------------------------------------------------------------- */ + +div.figure, figure { + margin: 0.5em; + padding: 0.5em; +} + +div.figure p.caption, figcaption { + padding: 0.3em; +} + +div.figure p.caption span.caption-number, +figcaption span.caption-number { + font-style: italic; +} + +div.figure p.caption span.caption-text, +figcaption span.caption-text { +} + +/* -- field list styles ----------------------------------------------------- */ + +table.field-list td, table.field-list th { + border: 0 !important; +} + +.field-list ul { + margin: 0; + padding-left: 1em; +} + +.field-list p { + margin: 0; +} + +.field-name { + -moz-hyphens: manual; + -ms-hyphens: manual; + -webkit-hyphens: manual; + hyphens: manual; +} + +/* -- hlist styles ---------------------------------------------------------- */ + +table.hlist { + margin: 1em 0; +} + +table.hlist td { + vertical-align: top; +} + +/* -- object description styles --------------------------------------------- */ + +.sig { + font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; +} + +.sig-name, code.descname { + background-color: transparent; + font-weight: bold; +} + +.sig-name { + font-size: 1.1em; +} + +code.descname { + font-size: 1.2em; +} + +.sig-prename, code.descclassname { + background-color: transparent; +} + +.optional { + font-size: 1.3em; +} + +.sig-paren { + font-size: larger; +} + +.sig-param.n { + font-style: italic; +} + +/* C++ specific styling */ + +.sig-inline.c-texpr, +.sig-inline.cpp-texpr { + font-family: unset; +} + +.sig.c .k, .sig.c .kt, +.sig.cpp .k, .sig.cpp .kt { + color: #0033B3; +} + +.sig.c .m, +.sig.cpp .m { + color: #1750EB; +} + +.sig.c .s, .sig.c .sc, +.sig.cpp .s, .sig.cpp .sc { + color: #067D17; +} + + +/* -- other body styles ----------------------------------------------------- */ + +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + +:not(li) > ol > li:first-child > :first-child, +:not(li) > ul > li:first-child > :first-child { + margin-top: 0px; +} + +:not(li) > ol > li:last-child > :last-child, +:not(li) > ul > li:last-child > :last-child { + margin-bottom: 0px; +} + +ol.simple ol p, +ol.simple ul p, +ul.simple ol p, +ul.simple ul p { + margin-top: 0; +} + +ol.simple > li:not(:first-child) > p, +ul.simple > li:not(:first-child) > p { + margin-top: 0; +} + +ol.simple p, +ul.simple p { + margin-bottom: 0; +} + +aside.footnote > span, +div.citation > span { + float: left; +} +aside.footnote > span:last-of-type, +div.citation > span:last-of-type { + padding-right: 0.5em; +} +aside.footnote > p { + margin-left: 2em; +} +div.citation > p { + margin-left: 4em; +} +aside.footnote > p:last-of-type, +div.citation > p:last-of-type { + margin-bottom: 0em; +} +aside.footnote > p:last-of-type:after, +div.citation > p:last-of-type:after { + content: ""; + clear: both; +} + +dl.field-list { + display: grid; + grid-template-columns: fit-content(30%) auto; +} + +dl.field-list > dt { + font-weight: bold; + word-break: break-word; + padding-left: 0.5em; + padding-right: 5px; +} + +dl.field-list > dd { + padding-left: 0.5em; + margin-top: 0em; + margin-left: 0em; + margin-bottom: 0em; +} + +dl { + margin-bottom: 15px; +} + +dd > :first-child { + margin-top: 0px; +} + +dd ul, dd table { + margin-bottom: 10px; +} + +dd { + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; +} + +.sig dd { + margin-top: 0px; + margin-bottom: 0px; +} + +.sig dl { + margin-top: 0px; + margin-bottom: 0px; +} + +dl > dd:last-child, +dl > dd:last-child > :last-child { + margin-bottom: 0; +} + +dt:target, span.highlighted { + background-color: #fbe54e; +} + +rect.highlighted { + fill: #fbe54e; +} + +dl.glossary dt { + font-weight: bold; + font-size: 1.1em; +} + +.versionmodified { + font-style: italic; +} + +.system-message { + background-color: #fda; + padding: 5px; + border: 3px solid red; +} + +.footnote:target { + background-color: #ffa; +} + +.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +.line-block .line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; +} + +.guilabel, .menuselection { + font-family: sans-serif; +} + +.accelerator { + text-decoration: underline; +} + +.classifier { + font-style: oblique; +} + +.classifier:before { + font-style: normal; + margin: 0 0.5em; + content: ":"; + display: inline-block; +} + +abbr, acronym { + border-bottom: dotted 1px; + cursor: help; +} + +.translated { + background-color: rgba(207, 255, 207, 0.2) +} + +.untranslated { + background-color: rgba(255, 207, 207, 0.2) +} + +/* -- code displays --------------------------------------------------------- */ + +pre { + overflow: auto; + overflow-y: hidden; /* fixes display issues on Chrome browsers */ +} + +pre, div[class*="highlight-"] { + clear: both; +} + +span.pre { + -moz-hyphens: none; + -ms-hyphens: none; + -webkit-hyphens: none; + hyphens: none; + white-space: nowrap; +} + +div[class*="highlight-"] { + margin: 1em 0; +} + +td.linenos pre { + border: 0; + background-color: transparent; + color: #aaa; +} + +table.highlighttable { + display: block; +} + +table.highlighttable tbody { + display: block; +} + +table.highlighttable tr { + display: flex; +} + +table.highlighttable td { + margin: 0; + padding: 0; +} + +table.highlighttable td.linenos { + padding-right: 0.5em; +} + +table.highlighttable td.code { + flex: 1; + overflow: hidden; +} + +.highlight .hll { + display: block; +} + +div.highlight pre, +table.highlighttable pre { + margin: 0; +} + +div.code-block-caption + div { + margin-top: 0; +} + +div.code-block-caption { + margin-top: 1em; + padding: 2px 5px; + font-size: small; +} + +div.code-block-caption code { + background-color: transparent; +} + +table.highlighttable td.linenos, +span.linenos, +div.highlight span.gp { /* gp: Generic.Prompt */ + user-select: none; + -webkit-user-select: text; /* Safari fallback only */ + -webkit-user-select: none; /* Chrome/Safari */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* IE10+ */ +} + +div.code-block-caption span.caption-number { + padding: 0.1em 0.3em; + font-style: italic; +} + +div.code-block-caption span.caption-text { +} + +div.literal-block-wrapper { + margin: 1em 0; +} + +code.xref, a code { + background-color: transparent; + font-weight: bold; +} + +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { + background-color: transparent; +} + +.viewcode-link { + float: right; +} + +.viewcode-back { + float: right; + font-family: sans-serif; +} + +div.viewcode-block:target { + margin: -1px -10px; + padding: 0 10px; +} + +/* -- math display ---------------------------------------------------------- */ + +img.math { + vertical-align: middle; +} + +div.body div.math p { + text-align: center; +} + +span.eqno { + float: right; +} + +span.eqno a.headerlink { + position: absolute; + z-index: 1; +} + +div.math:hover a.headerlink { + visibility: visible; +} + +/* -- printout stylesheet --------------------------------------------------- */ + +@media print { + div.document, + div.documentwrapper, + div.bodywrapper { + margin: 0 !important; + width: 100%; + } + + div.sphinxsidebar, + div.related, + div.footer, + #top-link { + display: none; + } +} \ No newline at end of file diff --git a/_static/custom.css b/_static/custom.css new file mode 100644 index 0000000..2a924f1 --- /dev/null +++ b/_static/custom.css @@ -0,0 +1 @@ +/* This file intentionally left blank. */ diff --git a/_static/doctools.js b/_static/doctools.js new file mode 100644 index 0000000..4d67807 --- /dev/null +++ b/_static/doctools.js @@ -0,0 +1,156 @@ +/* + * doctools.js + * ~~~~~~~~~~~ + * + * Base JavaScript utilities for all Sphinx HTML documentation. + * + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ +"use strict"; + +const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ + "TEXTAREA", + "INPUT", + "SELECT", + "BUTTON", +]); + +const _ready = (callback) => { + if (document.readyState !== "loading") { + callback(); + } else { + document.addEventListener("DOMContentLoaded", callback); + } +}; + +/** + * Small JavaScript module for the documentation. + */ +const Documentation = { + init: () => { + Documentation.initDomainIndexTable(); + Documentation.initOnKeyListeners(); + }, + + /** + * i18n support + */ + TRANSLATIONS: {}, + PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), + LOCALE: "unknown", + + // gettext and ngettext don't access this so that the functions + // can safely bound to a different name (_ = Documentation.gettext) + gettext: (string) => { + const translated = Documentation.TRANSLATIONS[string]; + switch (typeof translated) { + case "undefined": + return string; // no translation + case "string": + return translated; // translation exists + default: + return translated[0]; // (singular, plural) translation tuple exists + } + }, + + ngettext: (singular, plural, n) => { + const translated = Documentation.TRANSLATIONS[singular]; + if (typeof translated !== "undefined") + return translated[Documentation.PLURAL_EXPR(n)]; + return n === 1 ? singular : plural; + }, + + addTranslations: (catalog) => { + Object.assign(Documentation.TRANSLATIONS, catalog.messages); + Documentation.PLURAL_EXPR = new Function( + "n", + `return (${catalog.plural_expr})` + ); + Documentation.LOCALE = catalog.locale; + }, + + /** + * helper function to focus on search bar + */ + focusSearchBar: () => { + document.querySelectorAll("input[name=q]")[0]?.focus(); + }, + + /** + * Initialise the domain index toggle buttons + */ + initDomainIndexTable: () => { + const toggler = (el) => { + const idNumber = el.id.substr(7); + const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); + if (el.src.substr(-9) === "minus.png") { + el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; + toggledRows.forEach((el) => (el.style.display = "none")); + } else { + el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; + toggledRows.forEach((el) => (el.style.display = "")); + } + }; + + const togglerElements = document.querySelectorAll("img.toggler"); + togglerElements.forEach((el) => + el.addEventListener("click", (event) => toggler(event.currentTarget)) + ); + togglerElements.forEach((el) => (el.style.display = "")); + if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); + }, + + initOnKeyListeners: () => { + // only install a listener if it is really needed + if ( + !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && + !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS + ) + return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.altKey || event.ctrlKey || event.metaKey) return; + + if (!event.shiftKey) { + switch (event.key) { + case "ArrowLeft": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const prevLink = document.querySelector('link[rel="prev"]'); + if (prevLink && prevLink.href) { + window.location.href = prevLink.href; + event.preventDefault(); + } + break; + case "ArrowRight": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const nextLink = document.querySelector('link[rel="next"]'); + if (nextLink && nextLink.href) { + window.location.href = nextLink.href; + event.preventDefault(); + } + break; + } + } + + // some keyboard layouts may need Shift to get / + switch (event.key) { + case "/": + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; + Documentation.focusSearchBar(); + event.preventDefault(); + } + }); + }, +}; + +// quick alias for translations +const _ = Documentation.gettext; + +_ready(Documentation.init); diff --git a/_static/documentation_options.js b/_static/documentation_options.js new file mode 100644 index 0000000..7e4c114 --- /dev/null +++ b/_static/documentation_options.js @@ -0,0 +1,13 @@ +const DOCUMENTATION_OPTIONS = { + VERSION: '', + LANGUAGE: 'en', + COLLAPSE_INDEX: false, + BUILDER: 'html', + FILE_SUFFIX: '.html', + LINK_SUFFIX: '.html', + HAS_SOURCE: true, + SOURCELINK_SUFFIX: '.txt', + NAVIGATION_WITH_KEYS: false, + SHOW_SEARCH_SUMMARY: true, + ENABLE_SEARCH_SHORTCUTS: true, +}; \ No newline at end of file diff --git a/_static/file.png b/_static/file.png new file mode 100644 index 0000000..a858a41 Binary files /dev/null and b/_static/file.png differ diff --git a/_static/github-banner.svg b/_static/github-banner.svg new file mode 100644 index 0000000..c47d9dc --- /dev/null +++ b/_static/github-banner.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/_static/language_data.js b/_static/language_data.js new file mode 100644 index 0000000..367b8ed --- /dev/null +++ b/_static/language_data.js @@ -0,0 +1,199 @@ +/* + * language_data.js + * ~~~~~~~~~~~~~~~~ + * + * This script contains the language-specific data used by searchtools.js, + * namely the list of stopwords, stemmer, scorer and splitter. + * + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]; + + +/* Non-minified version is copied as a separate JS file, if available */ + +/** + * Porter Stemmer + */ +var Stemmer = function() { + + var step2list = { + ational: 'ate', + tional: 'tion', + enci: 'ence', + anci: 'ance', + izer: 'ize', + bli: 'ble', + alli: 'al', + entli: 'ent', + eli: 'e', + ousli: 'ous', + ization: 'ize', + ation: 'ate', + ator: 'ate', + alism: 'al', + iveness: 'ive', + fulness: 'ful', + ousness: 'ous', + aliti: 'al', + iviti: 'ive', + biliti: 'ble', + logi: 'log' + }; + + var step3list = { + icate: 'ic', + ative: '', + alize: 'al', + iciti: 'ic', + ical: 'ic', + ful: '', + ness: '' + }; + + var c = "[^aeiou]"; // consonant + var v = "[aeiouy]"; // vowel + var C = c + "[^aeiouy]*"; // consonant sequence + var V = v + "[aeiou]*"; // vowel sequence + + var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 + var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 + var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 + var s_v = "^(" + C + ")?" + v; // vowel in stem + + this.stemWord = function (w) { + var stem; + var suffix; + var firstch; + var origword = w; + + if (w.length < 3) + return w; + + var re; + var re2; + var re3; + var re4; + + firstch = w.substr(0,1); + if (firstch == "y") + w = firstch.toUpperCase() + w.substr(1); + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) + w = w.replace(re,"$1$2"); + else if (re2.test(w)) + w = w.replace(re2,"$1$2"); + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) + w = w + "e"; + else if (re3.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + else if (re4.test(w)) + w = w + "e"; + } + } + + // Step 1c + re = /^(.+?)y$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(s_v); + if (re.test(stem)) + w = stem + "i"; + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step2list[suffix]; + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) + w = stem + step3list[suffix]; + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) + w = stem; + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) + w = stem; + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) + w = stem; + } + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + if (firstch == "y") + w = firstch.toLowerCase() + w.substr(1); + return w; + } +} + diff --git a/_static/minus.png b/_static/minus.png new file mode 100644 index 0000000..d96755f Binary files /dev/null and b/_static/minus.png differ diff --git a/_static/plus.png b/_static/plus.png new file mode 100644 index 0000000..7107cec Binary files /dev/null and b/_static/plus.png differ diff --git a/_static/pygments.css b/_static/pygments.css new file mode 100644 index 0000000..04a4174 --- /dev/null +++ b/_static/pygments.css @@ -0,0 +1,84 @@ +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.highlight .hll { background-color: #ffffcc } +.highlight { background: #f8f8f8; } +.highlight .c { color: #8f5902; font-style: italic } /* Comment */ +.highlight .err { color: #a40000; border: 1px solid #ef2929 } /* Error */ +.highlight .g { color: #000000 } /* Generic */ +.highlight .k { color: #004461; font-weight: bold } /* Keyword */ +.highlight .l { color: #000000 } /* Literal */ +.highlight .n { color: #000000 } /* Name */ +.highlight .o { color: #582800 } /* Operator */ +.highlight .x { color: #000000 } /* Other */ +.highlight .p { color: #000000; font-weight: bold } /* Punctuation */ +.highlight .ch { color: #8f5902; font-style: italic } /* Comment.Hashbang */ +.highlight .cm { color: #8f5902; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #8f5902 } /* Comment.Preproc */ +.highlight .cpf { color: #8f5902; font-style: italic } /* Comment.PreprocFile */ +.highlight .c1 { color: #8f5902; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #8f5902; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #a40000 } /* Generic.Deleted */ +.highlight .ge { color: #000000; font-style: italic } /* Generic.Emph */ +.highlight .ges { color: #000000 } /* Generic.EmphStrong */ +.highlight .gr { color: #ef2929 } /* Generic.Error */ +.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.highlight .gi { color: #00A000 } /* Generic.Inserted */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #745334 } /* Generic.Prompt */ +.highlight .gs { color: #000000; font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.highlight .gt { color: #a40000; font-weight: bold } /* Generic.Traceback */ +.highlight .kc { color: #004461; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #004461; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #004461; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #004461; font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { color: #004461; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #004461; font-weight: bold } /* Keyword.Type */ +.highlight .ld { color: #000000 } /* Literal.Date */ +.highlight .m { color: #990000 } /* Literal.Number */ +.highlight .s { color: #4e9a06 } /* Literal.String */ +.highlight .na { color: #c4a000 } /* Name.Attribute */ +.highlight .nb { color: #004461 } /* Name.Builtin */ +.highlight .nc { color: #000000 } /* Name.Class */ +.highlight .no { color: #000000 } /* Name.Constant */ +.highlight .nd { color: #888888 } /* Name.Decorator */ +.highlight .ni { color: #ce5c00 } /* Name.Entity */ +.highlight .ne { color: #cc0000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #000000 } /* Name.Function */ +.highlight .nl { color: #f57900 } /* Name.Label */ +.highlight .nn { color: #000000 } /* Name.Namespace */ +.highlight .nx { color: #000000 } /* Name.Other */ +.highlight .py { color: #000000 } /* Name.Property */ +.highlight .nt { color: #004461; font-weight: bold } /* Name.Tag */ +.highlight .nv { color: #000000 } /* Name.Variable */ +.highlight .ow { color: #004461; font-weight: bold } /* Operator.Word */ +.highlight .pm { color: #000000; font-weight: bold } /* Punctuation.Marker */ +.highlight .w { color: #f8f8f8 } /* Text.Whitespace */ +.highlight .mb { color: #990000 } /* Literal.Number.Bin */ +.highlight .mf { color: #990000 } /* Literal.Number.Float */ +.highlight .mh { color: #990000 } /* Literal.Number.Hex */ +.highlight .mi { color: #990000 } /* Literal.Number.Integer */ +.highlight .mo { color: #990000 } /* Literal.Number.Oct */ +.highlight .sa { color: #4e9a06 } /* Literal.String.Affix */ +.highlight .sb { color: #4e9a06 } /* Literal.String.Backtick */ +.highlight .sc { color: #4e9a06 } /* Literal.String.Char */ +.highlight .dl { color: #4e9a06 } /* Literal.String.Delimiter */ +.highlight .sd { color: #8f5902; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #4e9a06 } /* Literal.String.Double */ +.highlight .se { color: #4e9a06 } /* Literal.String.Escape */ +.highlight .sh { color: #4e9a06 } /* Literal.String.Heredoc */ +.highlight .si { color: #4e9a06 } /* Literal.String.Interpol */ +.highlight .sx { color: #4e9a06 } /* Literal.String.Other */ +.highlight .sr { color: #4e9a06 } /* Literal.String.Regex */ +.highlight .s1 { color: #4e9a06 } /* Literal.String.Single */ +.highlight .ss { color: #4e9a06 } /* Literal.String.Symbol */ +.highlight .bp { color: #3465a4 } /* Name.Builtin.Pseudo */ +.highlight .fm { color: #000000 } /* Name.Function.Magic */ +.highlight .vc { color: #000000 } /* Name.Variable.Class */ +.highlight .vg { color: #000000 } /* Name.Variable.Global */ +.highlight .vi { color: #000000 } /* Name.Variable.Instance */ +.highlight .vm { color: #000000 } /* Name.Variable.Magic */ +.highlight .il { color: #990000 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/_static/searchtools.js b/_static/searchtools.js new file mode 100644 index 0000000..b08d58c --- /dev/null +++ b/_static/searchtools.js @@ -0,0 +1,620 @@ +/* + * searchtools.js + * ~~~~~~~~~~~~~~~~ + * + * Sphinx JavaScript utilities for the full-text search. + * + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ +"use strict"; + +/** + * Simple result scoring code. + */ +if (typeof Scorer === "undefined") { + var Scorer = { + // Implement the following function to further tweak the score for each result + // The function takes a result array [docname, title, anchor, descr, score, filename] + // and returns the new score. + /* + score: result => { + const [docname, title, anchor, descr, score, filename] = result + return score + }, + */ + + // query matches the full name of an object + objNameMatch: 11, + // or matches in the last dotted part of the object name + objPartialMatch: 6, + // Additive scores depending on the priority of the object + objPrio: { + 0: 15, // used to be importantResults + 1: 5, // used to be objectResults + 2: -5, // used to be unimportantResults + }, + // Used when the priority is not in the mapping. + objPrioDefault: 0, + + // query found in title + title: 15, + partialTitle: 7, + // query found in terms + term: 5, + partialTerm: 2, + }; +} + +const _removeChildren = (element) => { + while (element && element.lastChild) element.removeChild(element.lastChild); +}; + +/** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping + */ +const _escapeRegExp = (string) => + string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string + +const _displayItem = (item, searchTerms, highlightTerms) => { + const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; + const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; + const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; + const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; + const contentRoot = document.documentElement.dataset.content_root; + + const [docName, title, anchor, descr, score, _filename] = item; + + let listItem = document.createElement("li"); + let requestUrl; + let linkUrl; + if (docBuilder === "dirhtml") { + // dirhtml builder + let dirname = docName + "/"; + if (dirname.match(/\/index\/$/)) + dirname = dirname.substring(0, dirname.length - 6); + else if (dirname === "index/") dirname = ""; + requestUrl = contentRoot + dirname; + linkUrl = requestUrl; + } else { + // normal html builders + requestUrl = contentRoot + docName + docFileSuffix; + linkUrl = docName + docLinkSuffix; + } + let linkEl = listItem.appendChild(document.createElement("a")); + linkEl.href = linkUrl + anchor; + linkEl.dataset.score = score; + linkEl.innerHTML = title; + if (descr) { + listItem.appendChild(document.createElement("span")).innerHTML = + " (" + descr + ")"; + // highlight search terms in the description + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); + } + else if (showSearchSummary) + fetch(requestUrl) + .then((responseData) => responseData.text()) + .then((data) => { + if (data) + listItem.appendChild( + Search.makeSearchSummary(data, searchTerms, anchor) + ); + // highlight search terms in the summary + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); + }); + Search.output.appendChild(listItem); +}; +const _finishSearch = (resultCount) => { + Search.stopPulse(); + Search.title.innerText = _("Search Results"); + if (!resultCount) + Search.status.innerText = Documentation.gettext( + "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories." + ); + else + Search.status.innerText = _( + "Search finished, found ${resultCount} page(s) matching the search query." + ).replace('${resultCount}', resultCount); +}; +const _displayNextItem = ( + results, + resultCount, + searchTerms, + highlightTerms, +) => { + // results left, load the summary and display it + // this is intended to be dynamic (don't sub resultsCount) + if (results.length) { + _displayItem(results.pop(), searchTerms, highlightTerms); + setTimeout( + () => _displayNextItem(results, resultCount, searchTerms, highlightTerms), + 5 + ); + } + // search finished, update title and status message + else _finishSearch(resultCount); +}; +// Helper function used by query() to order search results. +// Each input is an array of [docname, title, anchor, descr, score, filename]. +// Order the results by score (in opposite order of appearance, since the +// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically. +const _orderResultsByScoreThenName = (a, b) => { + const leftScore = a[4]; + const rightScore = b[4]; + if (leftScore === rightScore) { + // same score: sort alphabetically + const leftTitle = a[1].toLowerCase(); + const rightTitle = b[1].toLowerCase(); + if (leftTitle === rightTitle) return 0; + return leftTitle > rightTitle ? -1 : 1; // inverted is intentional + } + return leftScore > rightScore ? 1 : -1; +}; + +/** + * Default splitQuery function. Can be overridden in ``sphinx.search`` with a + * custom function per language. + * + * The regular expression works by splitting the string on consecutive characters + * that are not Unicode letters, numbers, underscores, or emoji characters. + * This is the same as ``\W+`` in Python, preserving the surrogate pair area. + */ +if (typeof splitQuery === "undefined") { + var splitQuery = (query) => query + .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu) + .filter(term => term) // remove remaining empty strings +} + +/** + * Search Module + */ +const Search = { + _index: null, + _queued_query: null, + _pulse_status: -1, + + htmlToText: (htmlString, anchor) => { + const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); + for (const removalQuery of [".headerlink", "script", "style"]) { + htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); + } + if (anchor) { + const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`); + if (anchorContent) return anchorContent.textContent; + + console.warn( + `Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.` + ); + } + + // if anchor not specified or not found, fall back to main content + const docContent = htmlElement.querySelector('[role="main"]'); + if (docContent) return docContent.textContent; + + console.warn( + "Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template." + ); + return ""; + }, + + init: () => { + const query = new URLSearchParams(window.location.search).get("q"); + document + .querySelectorAll('input[name="q"]') + .forEach((el) => (el.value = query)); + if (query) Search.performSearch(query); + }, + + loadIndex: (url) => + (document.body.appendChild(document.createElement("script")).src = url), + + setIndex: (index) => { + Search._index = index; + if (Search._queued_query !== null) { + const query = Search._queued_query; + Search._queued_query = null; + Search.query(query); + } + }, + + hasIndex: () => Search._index !== null, + + deferQuery: (query) => (Search._queued_query = query), + + stopPulse: () => (Search._pulse_status = -1), + + startPulse: () => { + if (Search._pulse_status >= 0) return; + + const pulse = () => { + Search._pulse_status = (Search._pulse_status + 1) % 4; + Search.dots.innerText = ".".repeat(Search._pulse_status); + if (Search._pulse_status >= 0) window.setTimeout(pulse, 500); + }; + pulse(); + }, + + /** + * perform a search for something (or wait until index is loaded) + */ + performSearch: (query) => { + // create the required interface elements + const searchText = document.createElement("h2"); + searchText.textContent = _("Searching"); + const searchSummary = document.createElement("p"); + searchSummary.classList.add("search-summary"); + searchSummary.innerText = ""; + const searchList = document.createElement("ul"); + searchList.classList.add("search"); + + const out = document.getElementById("search-results"); + Search.title = out.appendChild(searchText); + Search.dots = Search.title.appendChild(document.createElement("span")); + Search.status = out.appendChild(searchSummary); + Search.output = out.appendChild(searchList); + + const searchProgress = document.getElementById("search-progress"); + // Some themes don't use the search progress node + if (searchProgress) { + searchProgress.innerText = _("Preparing search..."); + } + Search.startPulse(); + + // index already loaded, the browser was quick! + if (Search.hasIndex()) Search.query(query); + else Search.deferQuery(query); + }, + + _parseQuery: (query) => { + // stem the search terms and add them to the correct list + const stemmer = new Stemmer(); + const searchTerms = new Set(); + const excludedTerms = new Set(); + const highlightTerms = new Set(); + const objectTerms = new Set(splitQuery(query.toLowerCase().trim())); + splitQuery(query.trim()).forEach((queryTerm) => { + const queryTermLower = queryTerm.toLowerCase(); + + // maybe skip this "word" + // stopwords array is from language_data.js + if ( + stopwords.indexOf(queryTermLower) !== -1 || + queryTerm.match(/^\d+$/) + ) + return; + + // stem the word + let word = stemmer.stemWord(queryTermLower); + // select the correct list + if (word[0] === "-") excludedTerms.add(word.substr(1)); + else { + searchTerms.add(word); + highlightTerms.add(queryTermLower); + } + }); + + if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js + localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" ")) + } + + // console.debug("SEARCH: searching for:"); + // console.info("required: ", [...searchTerms]); + // console.info("excluded: ", [...excludedTerms]); + + return [query, searchTerms, excludedTerms, highlightTerms, objectTerms]; + }, + + /** + * execute search (requires search index to be loaded) + */ + _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + const allTitles = Search._index.alltitles; + const indexEntries = Search._index.indexentries; + + // Collect multiple result groups to be sorted separately and then ordered. + // Each is an array of [docname, title, anchor, descr, score, filename]. + const normalResults = []; + const nonMainIndexResults = []; + + _removeChildren(document.getElementById("search-progress")); + + const queryLower = query.toLowerCase().trim(); + for (const [title, foundTitles] of Object.entries(allTitles)) { + if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { + for (const [file, id] of foundTitles) { + const score = Math.round(Scorer.title * queryLower.length / title.length); + const boost = titles[file] === title ? 1 : 0; // add a boost for document titles + normalResults.push([ + docNames[file], + titles[file] !== title ? `${titles[file]} > ${title}` : title, + id !== null ? "#" + id : "", + null, + score + boost, + filenames[file], + ]); + } + } + } + + // search for explicit entries in index directives + for (const [entry, foundEntries] of Object.entries(indexEntries)) { + if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) { + for (const [file, id, isMain] of foundEntries) { + const score = Math.round(100 * queryLower.length / entry.length); + const result = [ + docNames[file], + titles[file], + id ? "#" + id : "", + null, + score, + filenames[file], + ]; + if (isMain) { + normalResults.push(result); + } else { + nonMainIndexResults.push(result); + } + } + } + } + + // lookup as object + objectTerms.forEach((term) => + normalResults.push(...Search.performObjectSearch(term, objectTerms)) + ); + + // lookup as search terms in fulltext + normalResults.push(...Search.performTermsSearch(searchTerms, excludedTerms)); + + // let the scorer override scores with a custom scoring function + if (Scorer.score) { + normalResults.forEach((item) => (item[4] = Scorer.score(item))); + nonMainIndexResults.forEach((item) => (item[4] = Scorer.score(item))); + } + + // Sort each group of results by score and then alphabetically by name. + normalResults.sort(_orderResultsByScoreThenName); + nonMainIndexResults.sort(_orderResultsByScoreThenName); + + // Combine the result groups in (reverse) order. + // Non-main index entries are typically arbitrary cross-references, + // so display them after other results. + let results = [...nonMainIndexResults, ...normalResults]; + + // remove duplicate search results + // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept + let seen = new Set(); + results = results.reverse().reduce((acc, result) => { + let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(','); + if (!seen.has(resultStr)) { + acc.push(result); + seen.add(resultStr); + } + return acc; + }, []); + + return results.reverse(); + }, + + query: (query) => { + const [searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms] = Search._parseQuery(query); + const results = Search._performSearch(searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms); + + // for debugging + //Search.lastresults = results.slice(); // a copy + // console.info("search results:", Search.lastresults); + + // print the results + _displayNextItem(results, results.length, searchTerms, highlightTerms); + }, + + /** + * search for object names + */ + performObjectSearch: (object, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const objects = Search._index.objects; + const objNames = Search._index.objnames; + const titles = Search._index.titles; + + const results = []; + + const objectSearchCallback = (prefix, match) => { + const name = match[4] + const fullname = (prefix ? prefix + "." : "") + name; + const fullnameLower = fullname.toLowerCase(); + if (fullnameLower.indexOf(object) < 0) return; + + let score = 0; + const parts = fullnameLower.split("."); + + // check for different match types: exact matches of full name or + // "last name" (i.e. last dotted part) + if (fullnameLower === object || parts.slice(-1)[0] === object) + score += Scorer.objNameMatch; + else if (parts.slice(-1)[0].indexOf(object) > -1) + score += Scorer.objPartialMatch; // matches in last name + + const objName = objNames[match[1]][2]; + const title = titles[match[0]]; + + // If more than one term searched for, we require other words to be + // found in the name/title/description + const otherTerms = new Set(objectTerms); + otherTerms.delete(object); + if (otherTerms.size > 0) { + const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase(); + if ( + [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0) + ) + return; + } + + let anchor = match[3]; + if (anchor === "") anchor = fullname; + else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname; + + const descr = objName + _(", in ") + title; + + // add custom score for some objects according to scorer + if (Scorer.objPrio.hasOwnProperty(match[2])) + score += Scorer.objPrio[match[2]]; + else score += Scorer.objPrioDefault; + + results.push([ + docNames[match[0]], + fullname, + "#" + anchor, + descr, + score, + filenames[match[0]], + ]); + }; + Object.keys(objects).forEach((prefix) => + objects[prefix].forEach((array) => + objectSearchCallback(prefix, array) + ) + ); + return results; + }, + + /** + * search for full-text terms in the index + */ + performTermsSearch: (searchTerms, excludedTerms) => { + // prepare search + const terms = Search._index.terms; + const titleTerms = Search._index.titleterms; + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + + const scoreMap = new Map(); + const fileMap = new Map(); + + // perform the search on the required terms + searchTerms.forEach((word) => { + const files = []; + const arr = [ + { files: terms[word], score: Scorer.term }, + { files: titleTerms[word], score: Scorer.title }, + ]; + // add support for partial matches + if (word.length > 2) { + const escapedWord = _escapeRegExp(word); + if (!terms.hasOwnProperty(word)) { + Object.keys(terms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: terms[term], score: Scorer.partialTerm }); + }); + } + if (!titleTerms.hasOwnProperty(word)) { + Object.keys(titleTerms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: titleTerms[term], score: Scorer.partialTitle }); + }); + } + } + + // no match but word was a required one + if (arr.every((record) => record.files === undefined)) return; + + // found search word in contents + arr.forEach((record) => { + if (record.files === undefined) return; + + let recordFiles = record.files; + if (recordFiles.length === undefined) recordFiles = [recordFiles]; + files.push(...recordFiles); + + // set score for the word in each file + recordFiles.forEach((file) => { + if (!scoreMap.has(file)) scoreMap.set(file, {}); + scoreMap.get(file)[word] = record.score; + }); + }); + + // create the mapping + files.forEach((file) => { + if (!fileMap.has(file)) fileMap.set(file, [word]); + else if (fileMap.get(file).indexOf(word) === -1) fileMap.get(file).push(word); + }); + }); + + // now check if the files don't contain excluded terms + const results = []; + for (const [file, wordList] of fileMap) { + // check if all requirements are matched + + // as search terms with length < 3 are discarded + const filteredTermCount = [...searchTerms].filter( + (term) => term.length > 2 + ).length; + if ( + wordList.length !== searchTerms.size && + wordList.length !== filteredTermCount + ) + continue; + + // ensure that none of the excluded terms is in the search result + if ( + [...excludedTerms].some( + (term) => + terms[term] === file || + titleTerms[term] === file || + (terms[term] || []).includes(file) || + (titleTerms[term] || []).includes(file) + ) + ) + break; + + // select one (max) score for the file. + const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w])); + // add result to the result list + results.push([ + docNames[file], + titles[file], + "", + null, + score, + filenames[file], + ]); + } + return results; + }, + + /** + * helper function to return a node containing the + * search summary for a given text. keywords is a list + * of stemmed words. + */ + makeSearchSummary: (htmlText, keywords, anchor) => { + const text = Search.htmlToText(htmlText, anchor); + if (text === "") return null; + + const textLower = text.toLowerCase(); + const actualStartPosition = [...keywords] + .map((k) => textLower.indexOf(k.toLowerCase())) + .filter((i) => i > -1) + .slice(-1)[0]; + const startWithContext = Math.max(actualStartPosition - 120, 0); + + const top = startWithContext === 0 ? "" : "..."; + const tail = startWithContext + 240 < text.length ? "..." : ""; + + let summary = document.createElement("p"); + summary.classList.add("context"); + summary.textContent = top + text.substr(startWithContext, 240).trim() + tail; + + return summary; + }, +}; + +_ready(Search.init); diff --git a/_static/sphinx_highlight.js b/_static/sphinx_highlight.js new file mode 100644 index 0000000..8a96c69 --- /dev/null +++ b/_static/sphinx_highlight.js @@ -0,0 +1,154 @@ +/* Highlighting utilities for Sphinx HTML documentation. */ +"use strict"; + +const SPHINX_HIGHLIGHT_ENABLED = true + +/** + * highlight a given string on a node by wrapping it in + * span elements with the given class name. + */ +const _highlight = (node, addItems, text, className) => { + if (node.nodeType === Node.TEXT_NODE) { + const val = node.nodeValue; + const parent = node.parentNode; + const pos = val.toLowerCase().indexOf(text); + if ( + pos >= 0 && + !parent.classList.contains(className) && + !parent.classList.contains("nohighlight") + ) { + let span; + + const closestNode = parent.closest("body, svg, foreignObject"); + const isInSVG = closestNode && closestNode.matches("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.classList.add(className); + } + + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + const rest = document.createTextNode(val.substr(pos + text.length)); + parent.insertBefore( + span, + parent.insertBefore( + rest, + node.nextSibling + ) + ); + node.nodeValue = val.substr(0, pos); + /* There may be more occurrences of search term in this node. So call this + * function recursively on the remaining fragment. + */ + _highlight(rest, addItems, text, className); + + if (isInSVG) { + const rect = document.createElementNS( + "http://www.w3.org/2000/svg", + "rect" + ); + const bbox = parent.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute("class", className); + addItems.push({ parent: parent, target: rect }); + } + } + } else if (node.matches && !node.matches("button, select, textarea")) { + node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); + } +}; +const _highlightText = (thisNode, text, className) => { + let addItems = []; + _highlight(thisNode, addItems, text, className); + addItems.forEach((obj) => + obj.parent.insertAdjacentElement("beforebegin", obj.target) + ); +}; + +/** + * Small JavaScript module for the documentation. + */ +const SphinxHighlight = { + + /** + * highlight the search words provided in localstorage in the text + */ + highlightSearchWords: () => { + if (!SPHINX_HIGHLIGHT_ENABLED) return; // bail if no highlight + + // get and clear terms from localstorage + const url = new URL(window.location); + const highlight = + localStorage.getItem("sphinx_highlight_terms") + || url.searchParams.get("highlight") + || ""; + localStorage.removeItem("sphinx_highlight_terms") + url.searchParams.delete("highlight"); + window.history.replaceState({}, "", url); + + // get individual terms from highlight string + const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); + if (terms.length === 0) return; // nothing to do + + // There should never be more than one element matching "div.body" + const divBody = document.querySelectorAll("div.body"); + const body = divBody.length ? divBody[0] : document.querySelector("body"); + window.setTimeout(() => { + terms.forEach((term) => _highlightText(body, term, "highlighted")); + }, 10); + + const searchBox = document.getElementById("searchbox"); + if (searchBox === null) return; + searchBox.appendChild( + document + .createRange() + .createContextualFragment( + '" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/genindex.html b/genindex.html new file mode 100644 index 0000000..2db898f --- /dev/null +++ b/genindex.html @@ -0,0 +1,128 @@ + + + + + + + Index — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..7db9e04 --- /dev/null +++ b/index.html @@ -0,0 +1,163 @@ + + + + + + + + Homepage — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + + + + \ No newline at end of file diff --git a/objects.inv b/objects.inv new file mode 100644 index 0000000..09ebd69 --- /dev/null +++ b/objects.inv @@ -0,0 +1,6 @@ +# Sphinx inventory version 2 +# Project: A Shaderboy's Collection +# Version: +# The remainder of this file is compressed using zlib. +xڅn0 } +݋r-ifXMGflm(P2{=hK ZlK4Th-q|( ѨɕE>ugd%hXR*_l & N.dzb*Ɵyj˵@u[rH{Q3 Mno:j \ Zv5+7MH]oErHV-Vc vY@ìX"@@@EV򵚩g0yl\\kgB { vmZ΁ > ߳.{}7ʩȯD>TK4P>mʁX%C'h lv P_QP "'@j1 fc-H3XzQuNmZ)\wjs$۷ 3;c_?Y~F&ltncJ}C)yuapս}Wr{n';4vIK Vw#RF⃔z-KrilIݼyuh2FV}6dz*4Km}Ԍ;`ɥe9Ij!%% vm$Wj_/-n \ No newline at end of file diff --git a/search.html b/search.html new file mode 100644 index 0000000..d78d589 --- /dev/null +++ b/search.html @@ -0,0 +1,146 @@ + + + + + + + Search — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +

Search

+ + + + +

+ Searching for multiple words only shows matches that contain + all words. +

+ + +
+ + + +
+ + +
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/searchindex.js b/searchindex.js new file mode 100644 index 0000000..04c8749 --- /dev/null +++ b/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({"alltitles": {"A Pythonic 3D Engine in 1 Weekend": [[11, null]], "Abstract Classes": [[5, "abstract-classes"]], "Account": [[15, "account"]], "Account Requirements": [[17, "account-requirements"]], "Algorithm": [[9, "algorithm"]], "Arrays": [[5, "arrays"]], "Arrays (2D)": [[5, "arrays-2d"]], "Bilinear Sobel Filtering in HLSL": [[14, null]], "Casting": [[5, "casting"]], "Census Transform in HLSL": [[2, null]], "Chromaticity in HLSL": [[3, null]], "Classes": [[5, "classes"]], "Constants": [[5, "constants"]], "Constructors": [[5, "constructors"]], "Content Creation Guide": [[0, null]], "Coordinate Spaces": [[4, "id1"]], "Coordinate Spaces: A Refresher": [[4, null]], "Correcting Outerra\u2019s Logarithmic Depth Buffering": [[10, null]], "Downloads": [[16, "downloads"]], "Exceptions": [[5, "exceptions"]], "Feedback": [[11, "feedback"]], "Fogging": [[13, "fogging"]], "For Loops": [[5, "for-loops"]], "Formulas": [[3, "formulas"]], "Functions": [[5, "functions"]], "Getters & Setters": [[5, "getters-setters"]], "GiraffeAcademy\u2019s C++ Examples": [[5, null]], "Graphics Programming Blog": [[0, null]], "Homepage": [[0, null]], "If Statements": [[5, "if-statements"]], "Inheritance": [[5, "inheritance"]], "Input Register Format": [[13, "input-register-format"]], "Instagram": [[15, null]], "Logarithmic Depth Buffering in HLSL": [[7, null]], "Lucas-Kanade Optical Flow in HLSL": [[9, null]], "Normalized Chromaticity": [[3, "normalized-chromaticity"]], "Numbers": [[5, "numbers"]], "Output Register Count": [[13, "output-register-count"]], "Personal Project": [[16, null]], "Pointers": [[5, "pointers"]], "Posts": [[15, "posts"]], "Precision Loss in RG Chromaticity": [[3, "precision-loss-in-rg-chromaticity"]], "Printing": [[5, "printing"]], "Project Reality: Shader Model 3.0 Considerations": [[13, null]], "RasterGrid\u2019s Gaussian Blur in HLSL": [[6, null]], "ReShadeFX for Beginners": [[12, null]], "Recommendation": [[11, "recommendation"]], "Register Assignments and Declarations": [[13, "register-assignments-and-declarations"]], "Requirements": [[15, "requirements"], [15, "id1"]], "Source Code": [[1, "source-code"], [2, "source-code"], [3, "source-code"], [3, "id1"], [6, "source-code"], [7, "source-code"], [8, "source-code"], [9, "source-code"], [10, "source-code"], [14, "source-code"]], "Spherical Chromaticity": [[3, "spherical-chromaticity"]], "Strings": [[5, "strings"]], "Switch Statements": [[5, "switch-statements"]], "Templates": [[15, "templates"]], "Temporal Auto-Exposure with Hardware Blending": [[1, null]], "Tools": [[16, "tools"]], "Turning a Nested 2D Loop into 1D": [[8, null]], "Uploading Images": [[15, "uploading-images"]], "Useful Commands": [[16, "useful-commands"]], "User Input": [[5, "user-input"]], "Variables": [[5, "variables"]], "Vectors": [[5, "vectors"]], "Video 1: Main Tutorial": [[11, "video-1-main-tutorial"]], "Video 2: SkyBox, Environment Mapping": [[11, "video-2-skybox-environment-mapping"]], "Video 3: Shadow Mapping, PCF": [[11, "video-3-shadow-mapping-pcf"]], "Video Requirements": [[17, "video-requirements"]], "Video Template": [[17, "video-template"]], "What is a Shader?": [[12, "what-is-a-shader"]], "While Loops": [[5, "while-loops"]], "YouTube": [[17, null]], "Your First Pixel Shader": [[12, "your-first-pixel-shader"]], "Your First Technique": [[12, "your-first-technique"]], "Your First Vertex Shader": [[12, "your-first-vertex-shader"]], "yt-dlp": [[16, "id1"]]}, "docnames": ["index", "source/blog/autoexposure", "source/blog/censustransform", "source/blog/chromaticity", "source/blog/coordinatespaces", "source/blog/cpp", "source/blog/gaussianblur", "source/blog/logdepth", "source/blog/loops", "source/blog/opticalflow", "source/blog/outerralogdepth", "source/blog/pythonengine", "source/blog/reshadefx", "source/blog/shadermodel3", "source/blog/sobel", "source/social/instagram", "source/social/project", "source/social/youtube"], "envversion": {"sphinx": 63, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2}, "filenames": ["index.rst", "source/blog/autoexposure.rst", "source/blog/censustransform.rst", "source/blog/chromaticity.rst", "source/blog/coordinatespaces.rst", "source/blog/cpp.rst", "source/blog/gaussianblur.rst", "source/blog/logdepth.rst", "source/blog/loops.rst", "source/blog/opticalflow.rst", "source/blog/outerralogdepth.rst", "source/blog/pythonengine.rst", "source/blog/reshadefx.rst", "source/blog/shadermodel3.rst", "source/blog/sobel.rst", "source/social/instagram.rst", "source/social/project.rst", "source/social/youtube.rst"], "indexentries": {}, "objects": {}, "objnames": {}, "objtypes": {}, "terms": {"": [0, 2, 3, 7, 9, 11, 12, 17], "0": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17], "00": 17, "00000": 9, "0000000": 2, "000000000": 9, "00am": 17, "01": 1, "01234": 5, "07": 7, "09": 1, "1": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17], "10": [3, 5, 9], "100": [1, 3, 5], "10000": [7, 10], "1109": [3, 9], "11111111": 2, "12": [1, 13, 17], "14": 5, "1415926535897932384626433832795f": 6, "1421433": [3, 9], "15": [5, 9], "16": 5, "1945": 5, "1988": 5, "1d": 0, "1e": [1, 10], "1st": 5, "2": [1, 2, 3, 5, 6, 8, 9, 12, 13, 17], "20": 5, "2004": [3, 9], "2006": 9, "2013": 7, "2016": 1, "23": 5, "2d": 0, "2j17wk": 12, "2nd": 5, "3": [0, 1, 2, 3, 5, 6, 7, 8, 9, 12, 15, 17], "30": 5, "32": 5, "39": 9, "3d": 0, "3x3": 8, "4": [2, 5, 8, 14], "40": 5, "4138051_robust_optical_flow_from_photometric_invari": [3, 9], "42": 5, "45": 9, "5": [1, 2, 3, 5, 8, 9, 14, 15, 17], "50": 5, "55": 5, "5f": 5, "5l": 5, "6": [2, 5, 8, 10], "60": 5, "64": 5, "7": [2, 7, 8], "8": [2, 5, 8, 13, 14], "90": 5, "99": [1, 5], "A": [0, 5, 9, 12, 14], "As": [2, 11], "At": [15, 17], "For": [3, 13, 17], "IT": 9, "If": [12, 13], "In": [3, 5, 8, 12, 13], "No": [12, 15, 17], "On": 4, "One": 5, "The": [2, 5, 7, 9, 11, 12, 13, 14], "To": 12, "_": 5, "__init__": 5, "_frametim": 1, "_manualbia": 1, "_smoothingspe": 1, "_worldviewproj": 7, "a11": 9, "a12": 9, "a21": 9, "a22": 9, "a_slightly_faster_bufferless_vertex_shader_trick": 12, "ab": [3, 9], "about": [11, 13, 15, 17], "ac": 9, "aco": [3, 9], "across": 17, "actual": 2, "ad": 5, "add": [1, 3, 11, 13], "adddress": 5, "addnumb": 5, "address": 5, "adipisc": [15, 17], "adopt": 11, "ag": 5, "age0": 5, "age1": 5, "age2": 5, "age3": 5, "algorithm": 3, "aliqua": [15, 17], "all": [2, 3, 5, 12, 17], "alloc": 11, "along": 12, "alreadi": [11, 17], "also": [11, 12], "alter": 6, "altern": 17, "amet": [15, 17], "an": [5, 7, 8, 9], "angela": 5, "angl": [3, 9], "angleshift": 9, "ani": [3, 13], "anoth": 1, "answer": 5, "app2ps_projectroad": 13, "app2v": [1, 7], "append": 5, "appli": 13, "applyautoexposur": 1, "applylogarithmicdepth": 7, "appropri": 17, "ar": [5, 11, 12, 13, 17], "arithmet": 5, "around": 14, "articl": 6, "asin": [3, 9], "asm": 13, "associ": 17, "atleast": 5, "audio": [16, 17], "author": [3, 5, 9, 17], "auto": 0, "autoexposur": 1, "automat": [1, 10], "avail": 13, "averag": [1, 2], "axi": 4, "b": [1, 2, 3, 5, 9, 12, 14], "b1": 9, "b2": 9, "ba": 16, "base": [3, 9, 11], "basi": 4, "basic": [5, 11], "becaus": [10, 13], "befor": 17, "begin": 5, "beginn": 0, "behavior": 3, "being": 11, "believ": 11, "best": [11, 16], "between": [3, 6, 9, 12, 14], "beyond": 12, "bia": [1, 9], "bicycl": 5, "bilinear": [0, 9], "binari": 2, "birth_year": 5, "bit": [2, 5, 9, 13], "blend": 0, "blenden": 1, "blendop": 1, "blog": 17, "blogspot": 7, "blue": [1, 3], "blur": [0, 9], "book": 5, "book1": 5, "book2": 5, "bool": 5, "boolean": 5, "bottom": 12, "bottura": 5, "break": 5, "bright": 1, "buffer": [0, 3, 11], "build": 9, "bullshit": 12, "bv": 16, "c": [0, 9, 13, 14], "c0": 13, "c1": 13, "c2": 13, "calcul": [3, 8, 9, 12], "camelcas": 5, "camera": 11, "can": [1, 3, 5, 7, 8, 11, 13, 14], "case": [5, 17], "cat": 5, "catch": 5, "categori": 17, "censu": 0, "center": [2, 4, 6, 14], "centersampl": 2, "cerr": 5, "certain": 13, "chang": [5, 9], "channel": [2, 3, 17], "char": 5, "charact": 5, "chef": 5, "chicken": 5, "chromat": [0, 9], "cin": 5, "claim": 17, "clamp": 9, "clip": 12, "cmath_gethalfmax": 9, "cmath_getrotationmatrix": 9, "cmath_halftonorm": 9, "cmath_normtohalf": 9, "cmotionestimation_getpixelpylk": 9, "cmotionestimation_normalizemv": 9, "cmotionestimation_unnormalizemv": 9, "code": [11, 12], "coder": 11, "color": [1, 2, 3, 7, 9, 12, 13], "color0": [1, 13], "column": 5, "columntex": 2, "com": [1, 7, 12], "comment": 12, "commerci": 17, "compar": 5, "comparison": [2, 5], "compat": 9, "compon": 1, "composit": 16, "compress": 9, "comput": [1, 3, 9, 10], "connect": 12, "consectetur": [15, 17], "consider": 0, "consist": 9, "const": [2, 3, 5, 6, 7, 8, 9, 10], "constant": 13, "constant0": 13, "constant1": 13, "constant2": 13, "construct": 5, "constuctor": 5, "contact": 17, "contain": 9, "content": [15, 17], "convent": 5, "convers": 16, "convert": [2, 7, 9], "coordin": [0, 9, 12, 13], "copi": 5, "correct": [0, 11], "countryoforigin": 5, "cout": 5, "cover": [7, 9, 11, 12], "cpu": [11, 12], "craft": 11, "creat": [5, 9, 11], "creator": 15, "crop": 15, "cse": 9, "cube": 11, "current": [1, 9], "d": [5, 9, 14], "data": [3, 5, 8, 9, 11, 12, 13], "datatyp": 5, "davinci": 16, "dcl_position0": 13, "ddx": 9, "ddy": 9, "de": [3, 9], "declar": 5, "def": 5, "default": 5, "defer": 11, "defin": [4, 5], "definit": 17, "delai": 1, "depend": 2, "depth": 0, "derefer": 5, "describ": [3, 9], "descript": [15, 17], "desktop": 16, "destblend": 1, "detect": 9, "determin": 9, "dice": 13, "did": 6, "didn": 13, "differ": [13, 15, 17], "difficult": 11, "direct": 4, "directli": 5, "disclaim": 17, "dish": 5, "distribut": 9, "divid": [3, 10], "divis": 5, "divisor": 3, "do": [1, 5, 7, 12, 13, 15, 17], "doe": [2, 12], "doi": [3, 9], "dolor": [15, 17], "dot": [3, 9, 12], "doubl": 5, "dp3": 3, "draw": 12, "drawback": 3, "dui": 17, "e": 9, "each": [2, 9, 12, 13], "edit": 16, "effect": 9, "eiusmod": [15, 17], "elimin": 3, "elit": [15, 17], "els": 5, "encod": [3, 9], "encount": 13, "end": 10, "endl": 5, "engin": 0, "enjoy": 11, "enter": 5, "entir": [3, 12], "equal": 2, "error": 5, "especi": 17, "essenti": 9, "estim": 9, "et": [15, 17], "ev100": 1, "even": 6, "event": 17, "everi": 12, "ew": 9, "exampl": [0, 8, 13], "exampleshad": 12, "execut": 5, "exp": [1, 6], "exp2": [1, 2, 9], "experi": 11, "expon": 9, "exponentbit": 9, "expos": 5, "exposur": 0, "extend": 5, "extenion": 5, "extern": 11, "f": [5, 16], "face": [4, 11], "fail": 5, "fals": 5, "farplan": [7, 10], "fcoef": [7, 10], "feel": 17, "fetch": [5, 9, 14], "ffmpeg": 16, "file": 16, "filter": [0, 2, 9, 15], "find": 5, "first": [5, 6, 11], "fit": 3, "fix": 13, "float": [1, 2, 3, 5, 6, 7, 9, 10], "float2": [1, 2, 3, 6, 8, 9, 12, 14], "float2x2": 9, "float3": [1, 2, 3, 9, 13], "float4": [1, 2, 6, 7, 9, 12, 13, 14], "float4x4": 7, "flow": [0, 3], "fly": 5, "follow": [3, 9, 11, 13, 17], "format": 9, "forward": 5, "found": 11, "frac": 3, "fragment": [7, 12], "frame": 9, "free": 17, "fridai": 17, "friend": 5, "from": [1, 2, 3, 5, 8, 9, 11, 12, 13, 16, 17], "function": [9, 12, 13], "fundament": 11, "g": [1, 2, 3, 9, 12], "gamedev": 12, "gamma": 11, "gaussian": [0, 9], "gave": 13, "gener": [1, 2, 9, 11, 12, 17], "generateaverageluma": 1, "geometri": 11, "get": [1, 5, 6, 8, 9, 11, 12], "getauthor": 5, "getautoexposur": 1, "getcensustransform": 2, "getdescript": 5, "getgaussianblur": 6, "getgaussianoffset": 6, "getgaussianweight": 6, "getgreyscal": 2, "getrgbchromat": 3, "getsobel": 14, "getsphericalrg": [3, 9], "gettitl": 5, "gever": [3, 9], "giraffeacademi": 0, "glsl": [7, 10], "gordon": 5, "gpa0": 5, "gpa1": 5, "gpa2": 5, "gpu": [7, 8, 10, 11, 12], "grade": 5, "gradient": 9, "graphic": [1, 11, 13], "greater": 2, "green": [1, 3, 12], "greet": 5, "ha": [7, 10], "half": [3, 9], "half2": 9, "halfmax": 9, "halfpi": [3, 9], "happen": [3, 7], "hardwar": 0, "harri": 5, "hashtag": [15, 17], "hashtag1": [15, 17], "hashtag2": [15, 17], "hashtag3": [15, 17], "have": [1, 11, 12, 13], "height": 9, "hello": 5, "here": [1, 7, 12, 13], "high": 17, "highest": 1, "hlsl": [0, 10], "holidai": 17, "homogen": 10, "how": [8, 11, 12], "howev": [8, 10, 11], "hpo": [1, 7, 10, 13], "html": 7, "http": [1, 3, 7, 9, 12, 17], "huji": 9, "i": [2, 3, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17], "i0": 9, "i1": 9, "icip": [3, 9], "id": 12, "ii": [9, 14], "il": 9, "illumin": 2, "imag": [2, 3, 9], "images": 9, "implement": [7, 9, 10, 11, 13], "incididunt": [15, 17], "includ": [5, 6, 17], "increment": 5, "index": 5, "ineffici": 8, "info": 5, "inform": 9, "initi": 9, "input": [1, 7], "insert": 5, "insid": 12, "instagram": 0, "instanc": [5, 11], "instruct": 3, "int": [2, 5, 8, 9], "integ": [2, 3, 5], "intens": [2, 6], "interpol": 12, "introduc": 3, "invalid": 5, "invari": [3, 9], "invsrcalpha": 1, "iostream": 5, "ipsum": [15, 17], "issmart": 5, "isstud": 5, "istal": 5, "itali": 5, "italianchef": 5, "its": [2, 5, 12], "itself": 1, "ix": [9, 14], "ixii": 9, "ixit": 9, "ixix": 9, "iyii": 9, "iyit": 9, "jim": 5, "jk": 5, "joost": [3, 9], "jrr": 5, "just": [11, 12], "justo": 17, "kanad": 0, "kevin": 5, "keyword": 17, "knarkowicz": 1, "known": [15, 17], "l1": [3, 9], "l2": [3, 9], "labor": [15, 17], "largest": 9, "ldexp": 2, "learn": 11, "least": [11, 15, 17], "left": [12, 17], "length": [3, 5, 9], "lesser": 2, "letter": 5, "level": [9, 13], "light": 11, "like": [1, 5, 12, 13], "linear": [7, 14], "linearoffset": 6, "linearweight": 6, "link": [3, 9, 15, 16, 17], "list": 16, "lk": 9, "llo": 5, "load": 11, "locat": 4, "lod": 6, "log": [1, 10], "log2": [1, 7, 10], "logarithm": 0, "long": 5, "longer": 13, "loop": [0, 9], "lord": 5, "lorem": [15, 17], "lower": [5, 17], "ltr": 9, "luca": 0, "luckynumb": 5, "luma": 1, "lumaaverag": 1, "m": 9, "magna": [15, 17], "mai": [5, 9], "main": [5, 8, 9], "maintex": 9, "major": [3, 10], "make": [5, 11, 12, 17], "makechicken": 5, "makepasta": 5, "makesalad": 5, "makespecialdish": 5, "mani": 6, "manipul": 5, "manual": 1, "map": 3, "mask": 9, "mass": 11, "massimo": 5, "math": 12, "matrix": 9, "max": [1, 2, 10], "maxexpon": 9, "maximum": 3, "maxsignificand": 9, "me": 11, "media": 16, "member": 5, "memori": [5, 11, 12], "method": [5, 13, 17], "might": 8, "mike": 5, "minimum": 3, "mipmap": [9, 11], "miss": 10, "mix": [12, 15, 17], "model": [0, 11], "modulu": 5, "more": [8, 13], "most": 17, "motion": 9, "mov": 13, "move": [5, 12], "msg": 5, "mul": [7, 9, 13], "multipli": 10, "must": [7, 10, 13, 15, 17], "mychef": 5, "mygrad": 5, "myitalianchef": 5, "myplan": 5, "mystr": 5, "myvari": 5, "n": 9, "name": [5, 12, 17], "namespac": 5, "nec": 17, "need": [7, 9, 17], "neg": 8, "neighbor": 2, "neighborhood": 2, "nequ": 17, "nest": 0, "net": [3, 9], "next": 9, "nich": [15, 17], "non": 17, "norm": 9, "normal": [6, 9, 11], "note": [1, 5, 12, 17], "notifi": 5, "num": 5, "num1": 5, "num2": 5, "number": [6, 13], "numbergrid": 5, "ob": 16, "object": [4, 5, 9, 11], "od": 13, "od0": 13, "offset": 8, "offset1": 6, "offset2": 6, "offsetew": 9, "offsetn": 9, "ofog": 13, "often": 3, "onli": [15, 17], "opengl": 11, "oper": 5, "opo": 13, "opt": 13, "optic": [0, 3], "optim": [3, 6, 7], "option": 1, "order": 5, "origin": 17, "oscar": 5, "ot": 13, "other": [11, 15, 17], "our": [7, 10], "out": [1, 5, 6, 12], "outerra": [0, 7], "outlin": 12, "output": [1, 3, 6, 7, 10, 12, 14], "outputcolor": [2, 6], "outputcolor0": 1, "overrid": 5, "overwrit": 1, "own": 17, "p": 13, "pack": 9, "paper": [3, 9], "parmesan": 5, "part": [9, 10, 12], "particular": 13, "pass": [1, 5, 12], "pass0": 1, "pass1": 1, "pasta": 5, "path": 16, "pdf": 9, "pecis": 3, "pedal": 5, "peleg": 9, "peopl": [11, 17], "per": [5, 7], "percis": 5, "person": 0, "phong": 11, "photometr": [3, 9], "pi": 6, "pipelin": [1, 11], "pixel": [1, 2, 6, 7, 13, 14], "pixels": [2, 6, 9, 14], "pixelshad": [1, 12, 13], "plane": [5, 11], "playlist": 17, "plu": 9, "pnum": 5, "po": [7, 13], "point": [3, 5, 13], "polymorph": 11, "port": 13, "posit": [1, 5, 7, 10, 12, 13], "position0": [7, 13], "possibl": [3, 15, 17], "post": [3, 6, 7, 8, 9, 13], "postprocessp": 12, "postprocessv": 12, "potenti": 13, "potter": 5, "pow": 9, "practic": 11, "precalcul": [3, 9], "precis": [5, 13], "prefix": 5, "prevent": [3, 6], "previou": 1, "previous": 1, "primit": 5, "privat": 5, "process": 8, "product": 17, "program": [5, 8, 11], "project": [0, 7, 17], "projpo": 13, "propag": 9, "ps2fb": 7, "ps_exposur": 1, "ps_generateaverageluma": 1, "ps_logdepth": 7, "ps_projectroad": 13, "public": [3, 5, 9], "pull": 9, "purpos": [11, 17], "push": 9, "push_back": 5, "pyramid": 9, "python": [0, 5], "r": [1, 2, 3, 12], "r0": 13, "r1": 13, "radii": 6, "ramsai": 5, "rang": [3, 9, 13], "rastergrid": 0, "re": [11, 17], "reach": 11, "read": [5, 13], "readbook": 5, "realiti": [0, 7, 16, 17], "recap": 12, "recognit": 9, "record": [16, 17], "red": [1, 3, 12], "reddit": 12, "refactor": 11, "refresh": 0, "relat": [11, 17], "relationship": 2, "relev": [15, 17], "remaind": 5, "render": [1, 11], "replac": 11, "repres": [2, 3, 12], "requir": [8, 9, 14], "researchg": [3, 9], "reshadefx": 0, "resolv": 16, "respect": 17, "rest": 5, "restrict": 9, "result": 2, "return": [1, 2, 3, 5, 6, 7, 9, 13, 14], "rg": 9, "rg8": 3, "rgb": [1, 2, 3, 9], "rhoncu": 17, "right": [3, 12, 17], "ring": 5, "robust": [2, 3, 9], "rotat": 9, "row": 5, "rowl": 5, "rsqrt": 6, "rule": 5, "sai": 11, "salad": 5, "sampl": [6, 8, 14], "samplecolortex": [1, 6], "samplei0": 9, "samplei1": 9, "sampleimag": [2, 14], "sampleindex": 6, "samplelumatex": 1, "sampleneighbor": 2, "sampler": [2, 14], "sampler2d": 9, "sapien": 17, "satur": [1, 3, 9, 10, 13], "saturdai": 17, "scene": 11, "schedul": 17, "screen": 12, "second": [5, 11], "sed": [15, 17], "see": 12, "semant": 7, "send": 12, "sensit": 5, "sentenc": [15, 17], "seri": 11, "set": [5, 9, 12, 15, 17], "setauthor": 5, "settitl": 5, "setup": 9, "shade": 1, "shader": [0, 1, 6, 7, 10], "share": 17, "short": 5, "should": 17, "side": 6, "sigma": 6, "sign": [5, 9], "signatur": 5, "signbit": 9, "significand": 9, "significandbit": 9, "similar": 17, "simpl": 7, "simplifi": 7, "singl": 5, "sit": [15, 17], "size": [5, 12, 13], "sky": 5, "smaller": 5, "smallest": 9, "smart": 5, "smooth": [1, 11], "so": [7, 8, 9, 13, 14], "sobel": 0, "solut": 13, "solv": [6, 9], "some": [1, 9], "someon": 11, "someth": 7, "song": 17, "sourc": [5, 17], "space": [0, 3, 10, 11, 12], "spatial": 9, "special": 5, "specif": 17, "specifi": 5, "spent": 11, "sqrt": [3, 9], "squar": 12, "srcalpha": 1, "srcblend": 1, "ssd": 9, "standalon": 17, "standard": 4, "start": [5, 8, 11], "std": 5, "step": [2, 9], "store": [1, 5, 9, 11], "straight": 11, "stretch": 12, "string": 2, "struct": [1, 7, 13, 14], "student": 5, "studio": 16, "subject": 17, "substr": 5, "sum": 5, "sumrgb": 3, "support": 13, "sv_posit": 12, "sv_target": 12, "sv_vertexid": 12, "syetem": 5, "system": 11, "t": [3, 5, 9, 13], "tag": 17, "tangent": [4, 11], "taught": 11, "team": [7, 13], "techniqu": 1, "templat": 16, "tempor": [0, 9, 15, 17], "test": 7, "testgrad": 5, "tex": [1, 2, 6, 14], "tex0": 1, "tex2d": [1, 2, 14], "tex2dgrad": 9, "tex2dlod": [1, 6], "texcoord": 12, "texcoord0": [1, 7, 13], "texii": 9, "texit": 9, "texix": 9, "textur": [1, 9, 12, 13, 14], "than": [2, 5, 8, 11], "thank": 11, "thei": 17, "them": 5, "thi": [1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 17], "through": 5, "throw": 5, "thumbnail": 17, "timecod": 17, "titl": [3, 5, 9, 17], "tolkien": 5, "tool": 17, "top": 12, "totalweight": 6, "trailer": 17, "trait": 5, "transform": [0, 7, 11], "transport": 5, "triangl": [3, 12], "true": [1, 5], "trunc": [8, 9], "try": 5, "turn": 0, "twice": 12, "txt": 16, "type": 13, "uint": 12, "ultric": 17, "undefin": 3, "unformat": 11, "uniform": 11, "unnecessari": 17, "unsign": [5, 13], "updat": [7, 13], "upload": 17, "upper": 5, "urna": 17, "us": [1, 5, 9, 11, 12, 13, 17], "usual": 7, "ut": [15, 17], "v": 13, "v0": 13, "valid": 9, "valu": [3, 5, 12], "van": [3, 9], "vari": 6, "variabl": [9, 13], "vbo": 11, "vector": 9, "vehicl": 5, "vendor": 5, "version": [7, 10], "vertex": [1, 4, 10, 11, 13], "vertexshad": [1, 12, 13], "vertic": 12, "video": [5, 9, 16], "view": 4, "viewer": 4, "virtual": 5, "viverra": 17, "vkyx41j6zba": 17, "void": [5, 12], "vs2p": [1, 7], "vs2ps_projectroad": 13, "vs_logdepth": 7, "vs_projectroad": 13, "vs_quad": 1, "w": [7, 9, 10, 13], "wa": [5, 11], "want": 11, "warp": 9, "warptex": 9, "we": [3, 5, 8, 10, 11, 12], "weekend": [0, 17], "weight": [1, 6], "weight1": 6, "weight2": 6, "weijer": [3, 9], "well": [15, 17], "what": [5, 15, 17], "when": [3, 13], "white": 3, "who": 11, "why": 5, "width": 9, "window": [8, 9], "windowhalf": [8, 9], "windows": [8, 9], "without": 5, "word": 5, "wordpress": 1, "world": [4, 5], "worldviewproj": 7, "www": [3, 9, 12], "x": [3, 4, 8, 9, 12, 13], "xw": 2, "xy": [2, 8, 9, 12], "xyw": 13, "xyxi": 9, "xyyi": 2, "xyz": [7, 13], "xyzw": 9, "xz": 2, "xzw": 13, "y": [3, 4, 8, 9, 12, 13], "ye": 17, "year": [3, 9], "you": [1, 3, 5, 7, 8, 9, 11, 12, 13, 14, 17], "your": [5, 9, 13], "youtu": 17, "youtub": 0, "z": [3, 4, 9, 10, 13], "zero": 5, "zw": 9}, "titles": ["Homepage", "Temporal Auto-Exposure with Hardware Blending", "Census Transform in HLSL", "Chromaticity in HLSL", "Coordinate Spaces: A Refresher", "GiraffeAcademy\u2019s C++ Examples", "RasterGrid\u2019s Gaussian Blur in HLSL", "Logarithmic Depth Buffering in HLSL", "Turning a Nested 2D Loop into 1D", "Lucas-Kanade Optical Flow in HLSL", "Correcting Outerra\u2019s Logarithmic Depth Buffering", "A Pythonic 3D Engine in 1 Weekend", "ReShadeFX for Beginners", "Project Reality: Shader Model 3.0 Considerations", "Bilinear Sobel Filtering in HLSL", "Instagram", "Personal Project", "YouTube"], "titleterms": {"": [5, 6, 10], "0": 13, "1": 11, "1d": 8, "2": 11, "2d": [5, 8], "3": [11, 13], "3d": 11, "A": [4, 11], "For": 5, "If": 5, "abstract": 5, "account": [15, 17], "algorithm": 9, "arrai": 5, "assign": 13, "auto": 1, "beginn": 12, "bilinear": 14, "blend": 1, "blog": 0, "blur": 6, "buffer": [7, 10], "c": 5, "cast": 5, "censu": 2, "chromat": 3, "class": 5, "code": [1, 2, 3, 6, 7, 8, 9, 10, 14], "command": 16, "consider": 13, "constant": 5, "constructor": 5, "content": 0, "coordin": 4, "correct": 10, "count": 13, "creation": 0, "declar": 13, "depth": [7, 10], "dlp": 16, "download": 16, "engin": 11, "environ": 11, "exampl": 5, "except": 5, "exposur": 1, "feedback": 11, "filter": 14, "first": 12, "flow": 9, "fog": 13, "format": 13, "formula": 3, "function": 5, "gaussian": 6, "getter": 5, "giraffeacademi": 5, "graphic": 0, "guid": 0, "hardwar": 1, "hlsl": [2, 3, 6, 7, 9, 14], "homepag": 0, "i": 12, "imag": 15, "inherit": 5, "input": [5, 13], "instagram": 15, "kanad": 9, "logarithm": [7, 10], "loop": [5, 8], "loss": 3, "luca": 9, "main": 11, "map": 11, "model": 13, "nest": 8, "normal": 3, "number": 5, "optic": 9, "outerra": 10, "output": 13, "pcf": 11, "person": 16, "pixel": 12, "pointer": 5, "post": 15, "precis": 3, "print": 5, "program": 0, "project": [13, 16], "python": 11, "rastergrid": 6, "realiti": 13, "recommend": 11, "refresh": 4, "regist": 13, "requir": [15, 17], "reshadefx": 12, "rg": 3, "setter": 5, "shader": [12, 13], "shadow": 11, "skybox": 11, "sobel": 14, "sourc": [1, 2, 3, 6, 7, 8, 9, 10, 14], "space": 4, "spheric": 3, "statement": 5, "string": 5, "switch": 5, "techniqu": 12, "templat": [15, 17], "tempor": 1, "tool": 16, "transform": 2, "turn": 8, "tutori": 11, "upload": 15, "us": 16, "user": 5, "variabl": 5, "vector": 5, "vertex": 12, "video": [11, 17], "weekend": 11, "what": 12, "while": 5, "your": 12, "youtub": 17, "yt": 16}}) \ No newline at end of file diff --git a/source/blog/autoexposure.html b/source/blog/autoexposure.html new file mode 100644 index 0000000..1d250c5 --- /dev/null +++ b/source/blog/autoexposure.html @@ -0,0 +1,262 @@ + + + + + + + + Temporal Auto-Exposure with Hardware Blending — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Temporal Auto-Exposure with Hardware Blending

+
+
Some graphics pipelines compute auto-exposure like this:
+
Textures:
+
    +
  1. Previous average brightness

  2. +
  3. Current average brightness

  4. +
+
+
Passes:
+
    +
  1. Store previously generated average brightness

  2. +
  3. Generates current average brightness

  4. +
  5. Smooth average brightnesses and compute auto-exposure

  6. +
+
+
+
+
You can use hardware blending for auto-exposure:
+
Textures:
+
    +
  1. Average brightnesses (previous + current)

  2. +
+
+
Passes:
+
    +
  1. Generate and smooth average brightnesses

  2. +
  3. Compute auto-exposure

  4. +
+
+
+
+
+
+

Source Code

+
/*
+   Automatic exposure shader using hardware blending
+*/
+
+/*
+   Vertex shaders
+*/
+
+struct APP2VS
+{
+   float4 HPos : POSITION;
+   float2 Tex0 : TEXCOORD0;
+};
+
+struct VS2PS
+{
+   float4 HPos : POSITION;
+   float2 Tex0 : TEXCOORD0;
+};
+
+VS2PS VS_Quad(APP2VS Input)
+{
+   VS2PS Output;
+   Output.HPos = Input.HPos;
+   Output.Tex0 = Input.Tex0;
+   return Output;
+}
+
+/*
+   Pixel shaders
+   ---
+   AutoExposure(): https://knarkowicz.wordpress.com/2016/01/09/automatic-exposure/
+*/
+
+float3 GetAutoExposure(float3 Color, float2 Tex)
+{
+   float LumaAverage = exp(tex2Dlod(SampleLumaTex, float4(Tex, 0.0, 99.0)).r);
+   float Ev100 = log2(LumaAverage * 100.0 / 12.5);
+   Ev100 -= _ManualBias; // optional manual bias
+   float Exposure = 1.0 / (1.2 * exp2(Ev100));
+   return Color * Exposure;
+}
+
+float4 PS_GenerateAverageLuma(VS2PS Input) : COLOR0
+{
+   float4 Color = tex2D(SampleColorTex, Input.Tex0);
+   float3 Luma = max(Color.r, max(Color.g, Color.b));
+
+   // OutputColor0.rgb = Output the highest brightness out of red/green/blue component
+   // OutputColor0.a = Output the weight for temporal blending
+   float Delay = 1e-3 * _Frametime;
+   return float4(log(max(Luma.rgb, 1e-2)), saturate(Delay * _SmoothingSpeed));
+}
+
+float3 PS_Exposure(VS2PS Input) : COLOR0
+{
+   float4 Color = tex2D(SampleColorTex, Input.Tex0);
+   return GetAutoExposure(Color.rgb, Input.Tex0);
+}
+
+technique AutoExposure
+{
+   // Pass0: This shader renders to a texture that blends itself
+   // NOTE: Do not have another shader overwrite the texture
+   pass GenerateAverageLuma
+   {
+      // Use hardware blending
+      BlendEnable = TRUE;
+      BlendOp = ADD;
+      SrcBlend = SRCALPHA;
+      DestBlend = INVSRCALPHA;
+
+      VertexShader = VS_Quad;
+      PixelShader = PS_GenerateAverageLuma;
+   }
+
+   // Pass1: Get the texture generated from Pass0
+   // Do autoexposure shading here
+   pass ApplyAutoExposure
+   {
+      VertexShader = VS_Quad;
+      PixelShader = PS_Exposure;
+   }
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/censustransform.html b/source/blog/censustransform.html new file mode 100644 index 0000000..08c468c --- /dev/null +++ b/source/blog/censustransform.html @@ -0,0 +1,183 @@ + + + + + + + + Census Transform in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Census Transform in HLSL

+

The census transform is a filter that represents the pixel’s neighborhood relationship in a binary string. The binary string will be 0000000 if the center pixel is lesser than all of its neighbors. The binary string will be 11111111 if the center pixel is greater than or equal to all of its neighbors.

+

The filter does not depend on the image’s actual intensity. As a result, the filter is robust to illumination.

+
+

Source Code

+
float GetGreyScale(float3 Color)
+{
+   return max(max(Color.r, Color.g), Color.b);
+}
+
+float GetCensusTransform(sampler SampleImage, float2 Tex, float2 PixelSize)
+{
+   float OutputColor = 0.0;
+   float4 ColumnTex[3];
+   ColumnTex[0] = Tex.xyyy + (float4(-1.0, +1.0, 0.0, -1.0) * PixelSize.xyyy);
+   ColumnTex[1] = Tex.xyyy + (float4( 0.0, +1.0, 0.0, -1.0) * PixelSize.xyyy);
+   ColumnTex[2] = Tex.xyyy + (float4(+1.0, +1.0, 0.0, -1.0) * PixelSize.xyyy);
+
+   const int Neighbors = 8;
+   float SampleNeighbor[Neighbors];
+   SampleNeighbor[0] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xy).rgb);
+   SampleNeighbor[1] = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xy).rgb);
+   SampleNeighbor[2] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xy).rgb);
+   SampleNeighbor[3] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xz).rgb);
+   SampleNeighbor[4] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xz).rgb);
+   SampleNeighbor[5] = GetGreyScale(tex2D(SampleImage, ColumnTex[0].xw).rgb);
+   SampleNeighbor[6] = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xw).rgb);
+   SampleNeighbor[7] = GetGreyScale(tex2D(SampleImage, ColumnTex[2].xw).rgb);
+   float CenterSample = GetGreyScale(tex2D(SampleImage, ColumnTex[1].xz).rgb);
+
+   // Generate 8-bit integer from the 8-pixel neighborhood
+   for(int i = 0; i < Neighbors; i++)
+   {
+      float Comparison = step(SampleNeighbor[i], CenterSample);
+      OutputColor += ldexp(Comparison, i);
+   }
+
+   // Convert the 8-bit integer to float, and average the results from each channel
+   return OutputColor * (1.0 / (exp2(8) - 1));
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/chromaticity.html b/source/blog/chromaticity.html new file mode 100644 index 0000000..c64e29e --- /dev/null +++ b/source/blog/chromaticity.html @@ -0,0 +1,247 @@ + + + + + + + + Chromaticity in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Chromaticity in HLSL

+

Images often represent color in 3 channels: (R, G, B) - red, green, and blue. You can represent (R, G, B) in any range. For this post, the range is a minimum of 0.0 and a maximum of 1.0.

+
+

Normalized Chromaticity

+
+

Formulas

+
+
Normalized RG/RGB
+\[\begin{split}r = \frac{R}{R+G+B}\\ +g = \frac{G}{R+G+B}\\ +b = \frac{B}{R+G+B}\\ +\\ +r+g+b = 1\end{split}\]
+
+
Output \((r,g,b)\)
+
(1.0, 0.0, 0.0):
+

100% red

+
+
(0.0, 1.0, 0.0):
+

100% green

+
+
(0.0, 0.0, 1.0):
+

100% blue

+
+
+
+
Output \((r,g)\)
+
(1.0, 0.0):
+

100% red

+
+
(0.0, 1.0):
+

100% green

+
+
(0.0, 0.0):
+

100% blue

+
+
+
+
+
+
Normalized RG/RGB White-Point
+\[\begin{split}R=1\\ +G=1\\ +B=1\\ +\\ +r = \frac{R}{R+G+B}\\ +g = \frac{G}{R+G+B}\\ +b = \frac{B}{R+G+B}\\ +\\ +r+g+b = 1\end{split}\]
+
+
+
+
+

Source Code

+
float3 GetRGBChromaticity(float3 Color)
+{
+   // Optimizes 2 ADD instructions 1 DP3 instruction
+   float SumRGB = dot(Color, 1.0);
+   float3 Chromaticity = saturate(Color / SumRGB);
+   // Output the chromaticity's white point if the divisor is 0.0
+   // Prevents undefined behavior happens when you divide by 0
+   Chromaticity = (SumRGB == 0.0) ? 1.0 / 3.0 : Chromaticity;
+   return Chromaticity;
+}
+
+
+
+
+
+

Spherical Chromaticity

+

This post introduces a color space that computes chromaticity with angles.

+
+

Precision Loss in RG Chromaticity

+

Pecision is a major drawback to RG chromaticity. In RG chromaticity, all possible values map into a right-triangle, eliminating half of the precision in integer buffers.

+

We can encode data that fits in the entire RG8 range by calculating the angles between the channels.

+
+
+

Source Code

+
/*
+    This code is based on the algorithm described in the following paper:
+    Author(s): Joost van de Weijer, T. Gevers
+    Title: "Robust optical flow from photometric invariants"
+    Year: 2004
+    DOI: 10.1109/ICIP.2004.1421433
+    Link: https://www.researchgate.net/publication/4138051_Robust_optical_flow_from_photometric_invariants
+*/
+
+float2 GetSphericalRG(float3 Color)
+{
+    const float HalfPi = 1.0 / acos(0.0);
+
+    // Precalculate (x*x + y*y)^0.5 and (x*x + y*y + z*z)^0.5
+    float L1 = length(Color.rg);
+    float L2 = length(Color.rgb);
+
+    float2 Angles = 0.0;
+    Angles[0] = (L1 == 0.0) ? 1.0 / sqrt(2.0) : Color.g / L1;
+    Angles[1] = (L2 == 0.0) ? 1.0 / sqrt(3.0) : L1 / L2;
+
+    return saturate(asin(abs(Angles)) * HalfPi);
+}
+
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/coordinatespaces.html b/source/blog/coordinatespaces.html new file mode 100644 index 0000000..99397d0 --- /dev/null +++ b/source/blog/coordinatespaces.html @@ -0,0 +1,183 @@ + + + + + + + + Coordinate Spaces: A Refresher — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Coordinate Spaces: A Refresher

+
+
Standard Basis

Defines the directions of the x-axis, y-axis, and z-axis.

+
+
(1.0, 0.0, 0.0):
+

x-axis

+
+
(0.0, 1.0, 0.0):
+

y-axis

+
+
(0.0, 0.0, 1.0):
+

z-axis

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Coordinate Spaces

Coordinate Space

Standard-Basis Location

(0.0, 0.0, 0.0) Location

Tangent-Space

On the face or vertex.

On the center of the face or vertex.

Object-Space

On the object.

On the center of the object.

World-Space

On the world.

On the center of the world.

View-Space

On the viewer.

On the center of the viewer.

+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/cpp.html b/source/blog/cpp.html new file mode 100644 index 0000000..88e2387 --- /dev/null +++ b/source/blog/cpp.html @@ -0,0 +1,866 @@ + + + + + + + + GiraffeAcademy’s C++ Examples — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

GiraffeAcademy’s C++ Examples

+

Sourced from: C++ Programming | In One Video

+
+

Abstract Classes

+
#include <iostream>
+using namespace std;
+
+class Vehicle
+{
+public:
+   virtual void move() = 0;
+   void getDescription()
+   {
+      cout << "Vehicles are used for transportation" << endl;
+   }
+};
+
+class Bicycle : public Vehicle
+{
+public:
+   void move()
+   {
+      cout << "The bicycle pedals forward" << endl;
+   }
+};
+
+class Plane : public Vehicle
+{
+public:
+   virtual void move()
+   {
+      cout << "The plane flys through the sky" << endl;
+   }
+};
+
+int main()
+{
+   Plane myPlane;
+   myPlane.move();
+   myPlane.getDescription();
+
+   return 0;
+}
+
+
+
+
+

Arrays

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   // Define an integer array
+   // int luckyNumbers[6];
+   int luckyNumbers[] = {4, 8, 15, 16, 23, 42};
+   // indexes:           0  1   2   3   4   5
+
+   // Set the number 99 at the 1st member
+   luckyNumbers[0] = 90;
+
+   // Print out the array's 1st and 2nd members
+   cout << luckyNumbers[0] << endl;
+   cout << luckyNumbers[1] << endl;
+
+   return 0;
+}
+
+
+
+
+

Arrays (2D)

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   // Define a 2D integer array
+   // int numberGrid[2][3];
+   int numberGrid[2][3] = {{1, 2, 3}, {4, 5, 6}};
+
+   // Set the number 99 at [row 1][column 2]
+   numberGrid[0][1] = 99;
+
+   // Print [row 1][column 1 and 2]
+   cout << numberGrid[0][0] << endl;
+   cout << numberGrid[0][1] << endl;
+
+   return 0;
+}
+
+
+
+
+

Casting

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   cout << (int)3.14 << endl;
+   cout << (double)3 / 2 << endl;
+
+   return 0;
+}
+
+
+
+
+

Classes

+
#include <iostream>
+#include <string>
+using namespace std;
+
+// Create the Book datatype
+class Book
+{
+public:
+   string title;
+   string author;
+
+   void readBook()
+   {
+      cout << "Reading " + this->title + " by " + this->author << endl;
+   }
+};
+
+int main()
+{
+   // Construct the book1 object instance
+   Book book1;
+   book1.title = "Harry Potter";
+   book1.author = "JK Rowling";
+
+   // Print out info from the book1 object instance
+   book1.readBook();
+   cout << book1.title << endl;
+
+   // Construct the book2 object instance
+   Book book2;
+   book2.title = "Lord of the Rings";
+   book2.author = "JRR Tolkien";
+
+   // Print out info from the book2 object instance
+   book2.readBook();
+   cout << book2.title << endl;
+
+   return 0;
+}
+
+
+
+
+

Constants

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   const int BIRTH_YEAR = 1945;
+   // BIRTH_YEAR = 1988; // Can't change BIRTH_YEAR
+   cout << BIRTH_YEAR;
+
+   return 0;
+}
+
+
+
+
+

Constructors

+
#include <iostream>
+#include <string>
+using namespace std;
+
+// Create the Book datatype
+class Book
+{
+public:
+   string title;
+   string author;
+
+   // Define the class' constuctor function
+   // NOTE: This is like `def __init__()` in Python :D
+   Book(string title, string author)
+   {
+      this->title = title;
+      this->author = author;
+   }
+
+   void readBook()
+   {
+      cout << "Reading " + this->title + " by " + this->author << endl;
+   }
+};
+
+int main()
+{
+   // Construct the book1 object instance
+   Book book1("Harry Potter", "JK Rowling");
+
+   // Print out info from the book1 object instance
+   book1.readBook();
+   cout << book1.title << endl;
+
+   // Construct the book2 object instance
+   Book book2("Lord of the Rings", "JRR Tolkien");
+
+   // Print out info from the book2 object instance
+   book2.readBook();
+   cout << book2.title << endl;
+
+   return 0;
+}
+
+
+
+
+

Exceptions

+
#include <iostream>
+using namespace std;
+
+double division(int a, int b)
+{
+   if (b == 0)
+   {
+      throw "Division by zero error!";
+   }
+   return (a / b);
+}
+
+int main()
+{
+   try
+   {
+      division(10, 0);
+   }
+   catch (const char *msg)
+   {
+      cerr << msg << endl;
+   }
+
+   return 0;
+}
+
+
+
+
+

For Loops

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   for (int i = 0; i < 5; i++)
+   {
+      cout << i << endl;
+   }
+
+   return 0;
+}
+
+
+
+
+

Functions

+
#include <iostream>
+using namespace std;
+
+// Specify a method signature
+int addNumbers(int num1, int num2);
+
+int main()
+{
+   // NOTE: We declare the function first
+   int sum = addNumbers(4, 60);
+   cout << sum << endl;
+
+   return 0;
+}
+
+int addNumbers(int num1, int num2)
+{
+   return num1 + num2;
+}
+
+
+
+
+

Getters & Setters

+
#include <iostream>
+#include <string>
+using namespace std;
+
+// Create the Book datatype
+class Book
+{
+private:
+   string title;
+   string author;
+
+public:
+   // Define the class' constuctor function
+   // NOTE: This is like `def __init__()` in Python :D
+   Book(string title, string author)
+   {
+      this->setTitle(title);
+      this->setAuthor(author);
+   }
+
+   string getTitle()
+   {
+      return this->title;
+   }
+
+   void setTitle(string title)
+   {
+      this->title = title;
+   }
+
+   string getAuthor(string author)
+   {
+      return this->author;
+   }
+
+   void setAuthor(string author)
+   {
+      this->author = author;
+   }
+
+   void readBook()
+   {
+      cout << "Reading " + this->title + " by " + this->author << endl;
+   }
+};
+
+int main()
+{
+   // Construct the book1 object instance
+   Book book1("Harry Potter", "JK Rowling");
+
+   // Print out info from the book1 object instance
+   book1.readBook();
+   cout << book1.getTitle() << endl;
+
+   // Construct the book2 object instance
+   Book book2("Lord of the Rings", "JRR Tolkien");
+
+   // Print out info from the book2 object instance
+   book2.readBook();
+   cout << book2.getTitle() << endl;
+
+   return 0;
+}
+
+
+
+
+

If Statements

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   // Define 2 booleans
+   bool isStudent = false;
+   bool isSmart = false;
+
+   if (isStudent && isSmart)
+   {
+      cout << "You are a student" << endl;
+   }
+   else if (isStudent && !isSmart)
+   {
+      cout << "You are not a smart student" << endl;
+   }
+   else
+   {
+      cout << "You are not a student and not smart" << endl;
+   }
+
+   // >, <, >=, <=, !=, ==
+   if (1 > 3)
+   {
+      cout << "Number comparison was true" << endl;
+   }
+
+   if ('a' > 'b')
+   {
+      cout << "Character comparison was true" << endl;
+   }
+
+   string myString = "cat";
+   if (myString.compare("cat") != 0)
+   {
+      cout << "string comparison was true" << endl;
+   }
+
+   return 0;
+}
+
+
+
+
+

Inheritance

+
#include <iostream>
+using namespace std;
+
+// Create a Chef datatype
+class Chef
+{
+public:
+   string name;
+   int age;
+
+   Chef(string name, int age)
+   {
+      this->name = name;
+      this->age = age;
+   }
+
+   void makeChicken()
+   {
+      cout << "The chef makes chicken" << endl;
+   }
+
+   void makeSalad()
+   {
+      cout << "The chef makes salad" << endl;
+   }
+
+   void makeSpecialDish()
+   {
+      cout << "The chef makes a special dish" << endl;
+   }
+};
+
+// Create an ItalianChef datatype that is an extenion of the Chef datatype
+class ItalianChef : public Chef
+{
+public:
+   string countryOfOrigin;
+
+   // Extended class' constructor from Chef's class constructor
+   ItalianChef(string name, int age, string countryOfOrigin) : Chef(name, age)
+   {
+      this->countryOfOrigin = countryOfOrigin;
+   }
+
+   void makePasta()
+   {
+      cout << "The chef makes pasta" << endl;
+   }
+
+   // Override the Chef class' makeSpecialDish()
+   void makeSpecialDish()
+   {
+      cout << "The chef makes chicken parmesan" << endl;
+   }
+};
+
+int main()
+{
+   // Example of the Chef class
+   Chef myChef("Gordon Ramsay", 50);
+   myChef.makeSpecialDish();
+
+   // Example of the extended ItalianChef class
+   ItalianChef myItalianChef("Massimo Bottura", 55, "Italy");
+   myItalianChef.makeSpecialDish();
+   cout << myItalianChef.age << endl;
+
+   return 0;
+}
+
+
+
+
+

Numbers

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   cout << 2 * 3 << endl;       // Basic arithmetic: +, -, /, *
+   cout << 10 % 3 << endl;      // Modulus operator: returns the remainder of 10 / 3
+   cout << (1 + 2) * 3 << endl; // Order of operations
+
+   /*
+      Division rules with ints and doubles:
+         f/f = f
+         i/i = i
+         i/f = f
+         f/i = f
+   */
+   cout << 10 / 3.0 << endl;
+
+   int num = 10;
+   num += 100; // +=, -=, /=, *=
+   cout << num << endl;
+
+   // Example: variable incrementation
+   num++;
+   cout << num << endl;
+
+   return 0;
+}
+
+
+
+
+

Pointers

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   /*
+      What pointers are:
+      - Exposes memory addresses
+      - Manipulates memory addresses
+      Why we use pointers:
+      - Memory addresses can change per-syetem
+      - Directly change data without copying it
+   */
+
+   // Print out an integer variable's memory address
+   int num = 10;
+   cout << &num << endl;
+
+   // Store the integer variable's memory address into memory
+   int *pNum = &num;
+   cout << pNum << endl;  // Print the memory adddress
+   cout << *pNum << endl; // Dereference the memory address to fetch its stored value
+
+   return 0;
+}
+
+
+
+
+

Printing

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   cout << "Hello World!" << endl;
+
+   return 0;
+}
+
+
+
+
+

Strings

+
#include <iostream>
+#include <string>
+using namespace std;
+
+int main()
+{
+   string greetings = "Hello";
+   //    char indexes: 01234
+
+   cout << greetings.length() << endl;     // Get string length
+   cout << greetings[0] << endl;           // Get 1st character of string
+   cout << greetings.find("llo") << endl;  // Find "llo"'s starting character position
+   cout << greetings.substr(2) << endl;    // Get all characters, starting from the 2nd character of the string
+   cout << greetings.substr(1, 3) << endl; // Get 3 characters, starting from the 1st character of the string
+
+   return 0;
+}
+
+
+
+
+

Switch Statements

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   char myGrade = 'A';
+   switch (myGrade)
+   {
+      case 'A':
+            cout << "You pass" << endl;
+            break;
+      case 'B':
+            cout << "You fail" << endl;
+            break;
+      default:
+            cout << "Invalid grade" << endl;
+   }
+
+   return 0;
+}
+
+
+
+
+

User Input

+
#include <iostream>
+#include <string>
+using namespace std;
+
+int main()
+{
+   string name;
+   cout << "Enter your name: ";
+   cin >> name;
+   cout << "Hello " << name << endl;
+
+   int num1, num2;
+   cout << "Enter first number: ";
+   cin >> num1;
+   cout << "Enter second number: ";
+   cin >> num2;
+   cout << "Answer: " << num1 + num2 << endl;
+
+   return 0;
+}
+
+
+
+
+

Variables

+
#include <iostream>
+#include <string>
+using namespace std;
+
+int main()
+{
+   /*
+      Traits:
+      - Case-sensitive
+      - May begin with letters
+      - Can include letters, numbers, or _
+     Convention:
+      - First word lower-case, rest upper-case (camelCase)
+      - Example: myVariable
+   */
+
+   string name = "Mike"; // string of characters, not primitive
+   char testGrade = 'A'; // single 8-bit character
+
+   // NOTE: You can make them unsigned by adding the "unsigned" prefix
+   short age0 = 10;     // atleast 16-bit signed integer
+   int age1 = 20;       // atleast 16-bits signed integer (not smaller than short)
+   long age2 = 30;      // atleast 32-bits signed integer
+   long long age3 = 40; // atleast 64-bits signed integer
+
+   float gpa0 = 2.5f;      // single percision floating point
+   double gpa1 = 3.5l;     // double-precision floating point
+   long double gpa2 = 3.5; // extended-precision floating point
+
+   bool isTall; // 1-bit -> true/false
+   isTall = true;
+
+   return 0;
+}
+
+
+
+
+

Vectors

+
#include <iostream>
+#include <string>
+#include <vector>
+using namespace std;
+
+int main()
+{
+   // Define a vector of strings
+   vector<string> friends;
+   // Append 3 strings into the vector
+   friends.push_back("Oscar");
+   friends.push_back("Angela");
+   friends.push_back("Kevin");
+   // Append "Jim" at the 2nd index of the vendor
+   friends.insert(friends.begin() + 1, "Jim");
+
+   // Print out the friend vector's first 3 members
+   cout << friends.at(0) << endl;
+   cout << friends.at(1) << endl;
+   cout << friends.at(2) << endl;
+   // Print out the friend vector's size
+   cout << friends.size() << endl;
+
+   return 0;
+}
+
+
+
+
+

While Loops

+
#include <iostream>
+using namespace std;
+
+int main()
+{
+   // Notify that this is a while loop
+   cout << "Executing while loop" << endl;
+
+   // Do while loop
+   int index = 1;
+   while (index <= 5)
+   {
+      cout << index << endl;
+      index++;
+   }
+
+   // Notify that this is a do-while loop
+   cout << "Executing do-while loop" << endl;
+
+   do
+   {
+      cout << index << endl;
+      index++;
+   } while (index <= 5);
+
+   return 0;
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/gaussianblur.html b/source/blog/gaussianblur.html new file mode 100644 index 0000000..7f811b8 --- /dev/null +++ b/source/blog/gaussianblur.html @@ -0,0 +1,182 @@ + + + + + + + + RasterGrid’s Gaussian Blur in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

RasterGrid’s Gaussian Blur in HLSL

+

Gaussian blurs sample many pixels. RasterGrid optimized Gaussian blur by sampling in-between pixels. RasterGrid’s article did not include shader code for varied Gaussian blur radii. This post solves that.

+
+

Source Code

+
float GetGaussianWeight(float SampleIndex, float Sigma)
+{
+   const float Pi = 3.1415926535897932384626433832795f;
+   float Output = rsqrt(2.0 * Pi * (Sigma * Sigma));
+   return Output * exp(-(SampleIndex * SampleIndex) / (2.0 * Sigma * Sigma));
+}
+
+float GetGaussianOffset(float SampleIndex, float Sigma, out float LinearWeight)
+{
+   float Offset1 = SampleIndex;
+   float Offset2 = SampleIndex + 1.0;
+   float Weight1 = GetGaussianWeight(Offset1, Sigma);
+   float Weight2 = GetGaussianWeight(Offset2, Sigma);
+   LinearWeight = Weight1 + Weight2;
+   return ((Offset1 * Weight1) + (Offset2 * Weight2)) / LinearWeight;
+}
+
+float4 GetGaussianBlur(float2 Tex, float LOD, float2 PixelSize, float Sigma)
+{
+   // Sample and weight center first to get even number sides
+   float TotalWeight = GetGaussianWeight(0.0, Sigma);
+   float4 OutputColor = tex2Dlod(SampleColorTex, float4(Tex, 0.0, LOD)) * TotalWeight;
+
+   for(float i = 1.0; i < Sigma * 3.0; i += 2.0)
+   {
+      float LinearWeight = 0.0;
+      float LinearOffset = GetGaussianOffset(i, Sigma, LinearWeight);
+      OutputColor += tex2Dlod(SampleColorTex, float4(Tex - (LinearOffset * PixelSize), 0.0, LOD)) * LinearWeight;
+      OutputColor += tex2Dlod(SampleColorTex, float4(Tex + (LinearOffset * PixelSize), 0.0, LOD)) * LinearWeight;
+      TotalWeight += LinearWeight * 2.0;
+   }
+
+   // Normalize intensity to prevent altered output
+   return OutputColor / TotalWeight;
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/logdepth.html b/source/blog/logdepth.html new file mode 100644 index 0000000..ff23dee --- /dev/null +++ b/source/blog/logdepth.html @@ -0,0 +1,201 @@ + + + + + + + + Logarithmic Depth Buffering in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Logarithmic Depth Buffering in HLSL

+

The Project Reality Team implemented logarithmic depth buffering for the 1.7.3 update. This post covers our implementation of simple logarithmic depth buffering in HLSL.

+

Outerra has an optimized 2013 implementation of logarithmic depth in GLSL. This is our simplified version of Outerra’s logarithmic depth in HLSL.

+
+

Source Code

+
float4x4 _WorldViewProj : WorldViewProj;
+
+struct APP2VS
+{
+   float4 Pos : POSITION0;
+};
+
+struct VS2PS
+{
+   float4 HPos : POSITION;
+   float Depth : TEXCOORD0;
+};
+
+struct PS2FB
+{
+   float4 Color : COLOR;
+   float Depth : DEPTH;
+};
+
+// Converts linear depth to logarithmic depth in the pixel shader
+// Source: https://outerra.blogspot.com/2013/07/logarithmic-depth-buffer-optimizations.html
+float ApplyLogarithmicDepth(float Depth)
+{
+   const float FarPlane = 10000.0;
+   const float FCoef = 1.0 / log2(FarPlane + 1.0);
+   return log2(Depth) * FCoef;
+}
+
+VS2PS VS_LogDepth(APP2VS Input)
+{
+   VS2PS Output = (VS2PS)0;
+
+   // Usually a transformation happens here
+   Output.HPos = mul(float4(Input.Pos.xyz, 1.0), _WorldViewProj);
+
+   // Output depth
+   Output.Depth = Output.HPos.w + 1.0;
+
+   return Output;
+}
+
+PS2FB PS_LogDepth(VS2PS Input)
+{
+   PS2FB Output;
+
+   // You need to output something to the color buffer
+   Output.Color = 0.0;
+
+   // You must output to the pixel shader’s DEPTH semantic so the GPU can do per-fragment depth testing.
+   Output.Depth = ApplyLogarithmicDepth(Input.Depth);
+
+   return Output;
+};
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/loops.html b/source/blog/loops.html new file mode 100644 index 0000000..249f991 --- /dev/null +++ b/source/blog/loops.html @@ -0,0 +1,223 @@ + + + + + + + + Turning a Nested 2D Loop into 1D — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Turning a Nested 2D Loop into 1D

+

In GPU programming, you might sample a 2D window with a nested. However, a nested loop might be more inefficient than 1 loop.

+

This post is an example of how to sample a 3x3 window of offsets in 1 loop.

+
+

Source Code

+
// Get required data to calculate main window data
+const int WindowSize = 3;
+const int WindowHalf = trunc(WindowSize / 2);
+
+// Start from the negative so we can process a window in 1 loop
+[loop] for (int i = 0; i < (WindowSize * WindowSize); i++)
+{
+   float2 XY = -WindowHalf + float2(i % WindowSize, trunc(i / WindowSize));
+}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

i#

X

Y

0

-1 + (0 % 3)

-1

-1 + trunc(0 / 3)

-1

1

-1 + (1 % 3)

0

-1 + trunc(1 / 3)

-1

2

-1 + (2 % 3)

1

-1 + trunc(2 / 3)

-1

3

-1 + (3 % 3)

-1

-1 + trunc(3 / 3)

0

4

-1 + (4 % 3)

0

-1 + trunc(4 / 3)

0

5

-1 + (5 % 3)

1

-1 + trunc(5 / 3)

0

6

-1 + (6 % 3)

-1

-1 + trunc(6 / 3)

1

7

-1 + (7 % 3)

0

-1 + trunc(7 / 3)

1

8

-1 + (8 % 3)

1

-1 + trunc(8 / 3)

1

+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/opticalflow.html b/source/blog/opticalflow.html new file mode 100644 index 0000000..c902cae --- /dev/null +++ b/source/blog/opticalflow.html @@ -0,0 +1,356 @@ + + + + + + + + Lucas-Kanade Optical Flow in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Lucas-Kanade Optical Flow in HLSL

+

An optical flow algorithm estimates the motion between frames. Optical flow is essential in object detection, object recognition, motion estimation, video compression, and video effects.

+

This post covers an HLSL implementation of Lucas-Kanade optical flow.

+
+

Algorithm

+

The pyramid LK algorithm consists of the following steps.

+
    +
  1. Build the current frame’s mipmap pyramid

    +

    Encode the image into chromaticity with GetSphericalRG()

    +
  2. +
  3. Filter the current frame with a Gaussian blur

  4. +
  5. Set the initial motion vector to <0.0, 0.0>

  6. +
  7. Compute optical flow from the smallest to largest pyramid level

    +

    Propagate the optical flow at each level

    +
  8. +
  9. Filter the optical flow with a Gaussian blur

  10. +
  11. Store the current frame for use in the next frame

  12. +
+
+

Note

+

The code contains generic functions, so you may need to change some parts of the code so it is compatible with your setup.

+
+
+
+

Source Code

+
/*
+    This code is based on the algorithm described in the following paper:
+    Author(s): Joost van de Weijer, T. Gevers
+    Title: "Robust optical flow from photometric invariants"
+    Year: 2004
+    DOI: 10.1109/ICIP.2004.1421433
+    Link: https://www.researchgate.net/publication/4138051_Robust_optical_flow_from_photometric_invariants
+*/
+
+float2 GetSphericalRG(float3 Color)
+{
+    const float HalfPi = 1.0 / acos(0.0);
+
+    // Precalculate (x*x + y*y)^0.5 and (x*x + y*y + z*z)^0.5
+    float L1 = length(Color.rg);
+    float L2 = length(Color.rgb);
+
+    float2 Angles = 0.0;
+    Angles[0] = (L1 == 0.0) ? 1.0 / sqrt(2.0) : Color.g / L1;
+    Angles[1] = (L2 == 0.0) ? 1.0 / sqrt(3.0) : L1 / L2;
+
+    return saturate(asin(abs(Angles)) * HalfPi);
+}
+
+float CMath_GetHalfMax()
+{
+    // Get the Half format distribution of bits
+    // Sign Exponent Significand
+    // 0    00000    000000000
+    const int SignBit = 0;
+    const int ExponentBits = 5;
+    const int SignificandBits = 10;
+
+    const int Bias = -15;
+    const int Exponent = exp2(ExponentBits);
+    const int Significand = exp2(SignificandBits);
+
+    const float MaxExponent = ((float)Exponent - (float)exp2(1)) + (float)Bias;
+    const float MaxSignificand = 1.0 + (((float)Significand - 1.0) / (float)Significand);
+
+    return (float)pow(-1, SignBit) * (float)exp2(MaxExponent) * MaxSignificand;
+}
+
+// [-HalfMax, HalfMax) -> [-1.0, 1.0)
+float2 CMath_HalfToNorm(float2 Half2)
+{
+    return clamp(Half2 / CMath_GetHalfMax(), -1.0, 1.0);
+}
+
+// [-1.0, 1.0) -> [-HalfMax, HalfMax)
+float2 CMath_NormToHalf(float2 Half2)
+{
+    return Half2 * CMath_GetHalfMax();
+}
+
+// [-1.0, 1.0] -> [Width, Height]
+float2 CMotionEstimation_UnnormalizeMV(float2 Vectors, float2 ImageSize)
+{
+    return Vectors / abs(ImageSize);
+}
+
+// [Width, Height] -> [-1.0, 1.0]
+float2 CMotionEstimation_NormalizeMV(float2 Vectors, float2 ImageSize)
+{
+    return clamp(Vectors * abs(ImageSize), -1.0, 1.0);
+}
+
+/*
+    Lucas-Kanade optical flow with bilinear fetches
+    ---
+    Calculate Lucas-Kanade optical flow by solving (A^-1 * B)
+    [A11 A12]^-1 [-B1] -> [ A11/D -A12/D] [-B1]
+    [A21 A22]^-1 [-B2] -> [-A21/D  A22/D] [-B2]
+    ---
+    [ Ix^2/D -IxIy/D] [-IxIt]
+    [-IxIy/D  Iy^2/D] [-IyIt]
+*/
+
+float2 CMotionEstimation_GetPixelPyLK
+(
+    float2 MainTex, // Texture coordinates in the [0.0, 1.0) range
+    float2 Vectors, // Vectors in the [-HalfMax, HalfMax) range
+    sampler2D SampleI0,
+    sampler2D SampleI1
+)
+{
+    // Initialize variables
+    float4 WarpTex;
+    float IxIx = 0.0;
+    float IyIy = 0.0;
+    float IxIy = 0.0;
+    float IxIt = 0.0;
+    float IyIt = 0.0;
+    float SSD = 0.0;
+
+    // Initiate main & warped texture coordinates
+    WarpTex = MainTex.xyxy;
+
+    // Calculate warped texture coordinates
+    WarpTex.zw -= 0.5; // Pull into [-0.5, 0.5) range
+    WarpTex.zw = CMath_NormToHalf(WarpTex.zw) + Vectors; // Warp in [-HalfMax, HalfMax) range
+    WarpTex.zw = CMath_HalfToNorm(WarpTex.zw) + 0.5; // Push into [0.0, 1.0) range
+    WarpTex.zw = saturate(WarpTex.zw); // Clamp into [0.0, 1.0) range
+
+    // Get gradient information
+    float4 TexIx = ddx(WarpTex);
+    float4 TexIy = ddy(WarpTex);
+    float2 PixelSize = abs(TexIx.xy) + abs(TexIy.xy);
+    float2x2 Rotation = CMath_GetRotationMatrix(45.0);
+
+    // Get required data to calculate main window data
+    const int WindowSize = 3;
+    const int WindowHalf = trunc(WindowSize / 2);
+
+    [loop] for (int i = 0; i < (WindowSize * WindowSize); i++)
+    {
+        float2 AngleShift = -WindowHalf + float2(i % WindowSize, trunc(i / WindowSize));
+        AngleShift = mul(Rotation, AngleShift);
+
+        // Get temporal gradient
+        float4 TexIT = WarpTex.xyzw + (AngleShift.xyxy * PixelSize.xyxy);
+        float2 I0 = tex2Dgrad(SampleI0, TexIT.xy, TexIx.xy, TexIy.xy).rg;
+        float2 I1 = tex2Dgrad(SampleI1, TexIT.zw, TexIx.zw, TexIy.zw).rg;
+        float2 IT = I0 - I1;
+
+        // Get spatial gradient
+        float4 OffsetNS = AngleShift.xyxy + float4(0.0, -1.0, 0.0, 1.0);
+        float4 OffsetEW = AngleShift.xyxy + float4(-1.0, 0.0, 1.0, 0.0);
+        float4 NS = WarpTex.xyxy + (OffsetNS * PixelSize.xyxy);
+        float4 EW = WarpTex.xyxy + (OffsetEW * PixelSize.xyxy);
+        float2 N = tex2Dgrad(SampleI0, NS.xy, TexIx.xy, TexIy.xy).rg;
+        float2 S = tex2Dgrad(SampleI0, NS.zw, TexIx.xy, TexIy.xy).rg;
+        float2 E = tex2Dgrad(SampleI0, EW.xy, TexIx.xy, TexIy.xy).rg;
+        float2 W = tex2Dgrad(SampleI0, EW.zw, TexIx.xy, TexIy.xy).rg;
+        float2 Ix = E - W;
+        float2 Iy = N - S;
+
+        // IxIx = A11; IyIy = A22; IxIy = A12/A22
+        IxIx += dot(Ix, Ix);
+        IyIy += dot(Iy, Iy);
+        IxIy += dot(Ix, Iy);
+
+        // IxIt = B1; IyIt = B2
+        IxIt += dot(Ix, IT);
+        IyIt += dot(Iy, IT);
+
+        SSD += dot(IT, IT);
+    }
+
+    /*
+        Calculate Lucas-Kanade matrix
+        ---
+        [ Ix^2/D -IxIy/D] [-IxIt]
+        [-IxIy/D  Iy^2/D] [-IyIt]
+    */
+
+    /*
+        Create a normalized SSD-based mask.
+        https://www.cs.huji.ac.il/~peleg/papers/HUJI-CSE-LTR-2006-39-LK-Plus.pdf
+    */
+
+    float M = (SSD / (IxIx + IyIy)) > 0.1;
+    IxIx *= M;
+    IyIy *= M;
+    IxIy *= M;
+    IxIt *= M;
+    IyIt *= M;
+
+    // Calculate A^-1 and B
+    float D = determinant(float2x2(IxIx, IxIy, IxIy, IyIy));
+    float2x2 A = float2x2(IyIy, -IxIy, -IxIy, IxIx) / D;
+    float2 B = float2(-IxIt, -IyIt);
+
+    // Calculate A^T*B
+    float2 Flow = (D > 0.0) ? mul(B, A) : 0.0;
+
+    // Convert motion vectors from Half -> Norm
+    Vectors = CMath_HalfToNorm(Vectors);
+
+    // Propagate normalized motion vectors in Norm Range
+    Vectors += CMotionEstimation_NormalizeMV(Flow, PixelSize);
+
+    // Clamp motion vectors to restrict range to valid lengths
+    Vectors = clamp(Vectors, -1.0, 1.0);
+
+    // Pack motion vectors to Half format
+    return CMath_NormToHalf(Vectors);
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/outerralogdepth.html b/source/blog/outerralogdepth.html new file mode 100644 index 0000000..ce6c141 --- /dev/null +++ b/source/blog/outerralogdepth.html @@ -0,0 +1,153 @@ + + + + + + + + Correcting Outerra’s Logarithmic Depth Buffering — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Correcting Outerra’s Logarithmic Depth Buffering

+

Outerra has a vertex shader implementation of log depth buffering in GLSL. However, Outerra missed a major part of their log depth buffering. This is our corrected version of Outerra’s log depth buffering in HLSL.

+

Outerra missed a multiply in the end. We must multiply log depth by W because the GPU automatically divides the vertex position HPos by W.

+
+

Source Code

+
// Output.HPos is the computed vertex position in homogeneous space
+const float FarPlane = 10000.0;
+const float FCoef = 1.0 / log2(FarPlane + 1.0);
+Output.HPos.z = saturate(log2(max(1e-6, Output.HPos.w)) * FCoef);
+Output.HPos.z *= Output.HPos.w;
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/pythonengine.html b/source/blog/pythonengine.html new file mode 100644 index 0000000..b75b467 --- /dev/null +++ b/source/blog/pythonengine.html @@ -0,0 +1,194 @@ + + + + + + + + A Pythonic 3D Engine in 1 Weekend — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

A Pythonic 3D Engine in 1 Weekend

+

I spent this weekend following Coder Space’s Python 3D engine tutorial series. The tutorial covered the fundamentals of the OpenGL pipeline, from the CPU to the GPU.

+
+

Video 1: Main Tutorial

+

I learned about the OpenGL pipeline, starting from the CPU to the GPU. The first tutorial taught me how to…

+
    +
  1. Render basic geometry

  2. +
  3. Add a camera to a scene

  4. +
  5. Add Phong lighting into a scene

  6. +
  7. Refactor code to re-use buffer object data

  8. +
  9. Use Uniform transformations

  10. +
  11. Adopt Best practices in rendering

    +
      +
    • Mipmapping

    • +
    • Gamma correction

    • +
    +
  12. +
  13. Load external 3D models

  14. +
+
+

Note

+

I learned that VBOs are unformatted, allocated spaces of memory that store vertex-related data. However, we can use buffer objects for purposes other than being a VBO.

+
+
+
+

Video 2: SkyBox, Environment Mapping

+

I created a skybox for the rendering scene. The second tutorial taught me how to…

+
    +
  1. Refactor code with polymorphism

  2. +
  3. Make cube-maps with faces

  4. +
  5. Replace cube-based skybox with plane-based skybox

  6. +
+
+

Note

+

Implementing a plane-based skybox was difficult, to say the least.

+
+
+
+

Video 3: Shadow Mapping, PCF

+

I just created a smooth shadow-mapping system for objects.

+
+
+

Feedback

+

As someone who wanted to learn the graphics programming fundamentals, I found this series enjoyable to follow. I believe this tutorial can reach the masses if it also covers…

+
    +
  • Instancing

  • +
  • Deferred rendering

  • +
  • Generating vertex normal and tangent

  • +
+
+
+

Recommendation

+

I recommend this tutorial for people who already have experience with Python and want to get straight to crafting graphics. Thank you, Coder Space!

+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/reshadefx.html b/source/blog/reshadefx.html new file mode 100644 index 0000000..1f53007 --- /dev/null +++ b/source/blog/reshadefx.html @@ -0,0 +1,262 @@ + + + + + + + + ReShadeFX for Beginners — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

ReShadeFX for Beginners

+

No bullshit, just move along.

+
+
Recap
+
Vertex Shader:
+

Code that does math on every vertex

+
+
Pixel Shader:
+

Code that does math on every pixel

+
+
+
+
+
+

What is a Shader?

+

A shader is code that does math.

+

A shader is like a drawing a square. Here is how you draw a red square:

+
    +
  1. You draw a dotted outline of the square.

  2. +
  3. You connect the dotted outline of the square.

  4. +
  5. You color red inside the square.

  6. +
+
+
+

Your First Vertex Shader

+
 1// Vertex shader generating a triangle covering the entire screen.
+ 2// See also https://www.reddit.com/r/gamedev/comments/2j17wk/a_slightly_faster_bufferless_vertex_shader_trick/
+ 3
+ 4// Make a function that calculate on each vertex.
+ 5// PostProcessVS() outputs a triangle that is twice the screen's size.
+ 6void PostProcessVS
+ 7(
+ 8    in uint id : SV_VertexID, // Get "id" from CPU memory named "SV_VertexID"
+ 9    out float4 position : SV_Position, // Send "position" to GPU memory named "SV_Position"
+10    out float2 texcoord : TEXCOORD // Send "texcoord" to GPU memory named "TEXCOORD"
+11)
+12{
+13    /*
+14        PART 1
+15        ---
+16        Use the vertex's ID to calculate its texture coordinates.
+17        NOTE: Texture coordinates are 0-1
+18        ---
+19        ID 0 -> texcoord (0.0, 0.0)
+20        ID 1 -> texcoord (0.0, 2.0)
+21        ID 2 -> texcoord (2.0, 0.0)
+22    */
+23
+24    // If the vertex's ID is 2, set the its texcoord's X position to 2.
+25    // If the vertex's ID is not 2, set its texcoord's X position to 0.
+26    texcoord.x = (id == 2) ? 2.0 : 0.0;
+27
+28    // If the vertex's ID is 1, set the its texcoord's Y position to 2.
+29    // If the vertex's ID is not 1, set its texcoord's Y position to 0.
+30    texcoord.y = (id == 1) ? 2.0 : 0.0;
+31
+32    /*
+33        PART 2
+34        ---
+35        We stretch the triangle to be twice the size of the screen.
+36        To do this, use the vertex's texture coordinates to calculate it's position in clip-space.
+37
+38        In clip-space, the values represent:
+39            Bottom-left of screen: (-1.0, -1.0)
+40            Bottom-right of screen: (1.0, -1.0)
+41            Top-left of screen: (-1.0, 1.0)
+42            Top-right of screen: (1.0, 1.0)
+43        ---
+44        texcoord (0.0, 0.0) -> position (-1.0, 1.0)
+45        texcoord (0.0, 2.0) -> position (-1.0, 3.0)
+46        texcoord (2.0, 0.0) -> position (3.0, 1.0)
+47    */
+48
+49    position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
+50
+51    /*
+52        PART 3
+53        ---
+54        1. The GPU will "clip" fragments that have a position beyond -1 or 1.
+55        2. The GPU will interpolate the "texcoord" and "position" data between vertices
+56    */
+57}
+
+
+
+
+

Your First Pixel Shader

+
 1// Make a function that calculate on each pixel.
+ 2// PostProcessPS() outputs a color on each of the triangle's pixel.
+ 3void PostProcessPS
+ 4(
+ 5    in float2 texcoord : TEXCOORD, // Get "texcoord" from GPU memory named "TEXCOORD"
+ 6    out float4 color : SV_Target // Send "color" to GPU memory named "SV_Target"
+ 7)
+ 8{
+ 9    /*
+10        Use the texcoord's XY value to set the triangle's red and green value.
+11            texcoord(1.0, 0.0) -> color(1.0, 0.0, 0.0, 1.0) -> all red
+12            texcoord(0.0, 1.0) -> color(1.0, 0.0, 0.0, 1.0) -> all green
+13            texcoord(1.0, 1.0) -> color(1.0, 1.0, 0.0, 1.0) -> mix of red and green
+14    */
+15    color.r = texcoord.x;
+16    color.g = texcoord.y;
+17    color.b = 0.0;
+18    color.a = 1.0;
+19}
+
+
+
+
+

Your First Technique

+
1technique ExampleShader
+2{
+3    pass
+4    {
+5        VertexShader = PostProcessVS;
+6        PixelShader = PostProcessPS;
+7    }
+8}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/shadermodel3.html b/source/blog/shadermodel3.html new file mode 100644 index 0000000..16e58a1 --- /dev/null +++ b/source/blog/shadermodel3.html @@ -0,0 +1,267 @@ + + + + + + + + Project Reality: Shader Model 3.0 Considerations — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Project Reality: Shader Model 3.0 Considerations

+

The Project Reality Team updated Project Reality to support Shader Model 3. The update gave Project Reality more graphical potential. This post considerations when porting shaders from Shader Model 2 to 3.

+
+

Fogging

+

From Shader Model 3, fogging is no longer fixed-function. You must implement your fogging method in the pixel shader.

+
+
+

Output Register Count

+ +
+
+

Input Register Format

+ +
+
+

Register Assignments and Declarations

+

If you encounter the following asm, with constants not declared in ASM.

+
VertexShader = asm
+{
+    vs.1.1
+
+    dcl_position0 v0
+
+    add r0.xyz, v0.xzw, -c[0].xyz
+    mul r0.xyz, r0.xyz, c[1].xyw // z = 0, w = 1
+    add oPos.x, r0.x, -c[1].w
+    add oPos.y, r0.y, -c[1].w
+    mov oPos.z, r0.z
+    mov oPos.w, c[1].w // z = 0, w = 1
+    add r1, v0.y, -c[2].x
+    mul oD0, r1, c[2].y
+    mov oD0.a, c[1].z // z = 0
+};
+
+PixelShader = asm
+{
+    ps.1.1
+    mov r0, v0
+};
+
+
+

The solution: use the : register() to a shader variable to a particular register. You can read more about it here.

+
// Assign variables to registers because DICE didn't do so in their ASM.
+float4 Constant0 : register(c0); // c[0]
+float4 Constant1 : register(c1); // c[1]
+float4 Constant2 : register(c2); // c[2]
+
+struct APP2PS_ProjectRoad
+{
+    float4 Pos : POSITION0;
+};
+
+struct VS2PS_ProjectRoad
+{
+    float4 HPos : POSITION;
+    float4 Color : TEXCOORD0;
+};
+
+// VertexShader
+VS2PS_ProjectRoad VS_ProjectRoad(APP2PS_ProjectRoad Input)
+{
+    VS2PS_ProjectRoad Output = (VS2PS_ProjectRoad)0.0;
+
+    // add r0.xyz, v0.xzw, -c[0].xyz
+    // mul r0.xyz, r0.xyz, c[1].xyw // z = 0, w = 1
+    float3 ProjPos = Input.Pos.xzw - Constant0.xyz;
+    ProjPos *= Constant1.xyw; // z = 0, w = 1
+
+    // add oPos.x, r0.x, -c[1].w
+    // add oPos.y, r0.y, -c[1].w
+    // mov oPos.z, r0.z
+    // mov oPos.w, c[1].w // z = 0, w = 1
+    Output.HPos.x = ProjPos.x - Constant1.w;
+    Output.HPos.y = ProjPos.y - Constant1.w;
+    Output.HPos.z = ProjPos.z;
+    Output.HPos.w = Constant1.w; // z = 0, w = 1
+
+    // add r1, v0.y, -c[2].x
+    // mul oD0, r1, c[2].y
+    // mov oD0.a, c[1].z // z = 0
+    float4 Color = Input.Pos.y - Constant2.x;
+    Output.Color = Color * Constant2.y;
+    Output.Color.a = Constant1.z; // z = 0
+    Output.Color = saturate(Output.Color);
+
+    return Output;
+}
+
+// PixelShader
+float4 PS_ProjectRoad(VS2PS_ProjectRoad Input) : COLOR0
+{
+    // mov r0, v0
+    return Input.Color;
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/blog/sobel.html b/source/blog/sobel.html new file mode 100644 index 0000000..8899571 --- /dev/null +++ b/source/blog/sobel.html @@ -0,0 +1,158 @@ + + + + + + + + Bilinear Sobel Filtering in HLSL — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Bilinear Sobel Filtering in HLSL

+

The Sobel filter requires you to sample 8 pixels around the center pixel. The filter is linear, so you can sample 8 pixels in 4 texture fetches by sampling in-between pixels.

+
+

Source Code

+
struct Sobel
+{
+   float4 Ix;
+   float4 Iy;
+};
+
+Sobel GetSobel(sampler SampleImage, float2 Tex, float2 PixelSize)
+{
+   Sobel Output;
+   float4 A = tex2D(SampleImage, Tex + (float2(-0.5, +0.5) * PixelSize));
+   float4 B = tex2D(SampleImage, Tex + (float2(+0.5, +0.5) * PixelSize));
+   float4 C = tex2D(SampleImage, Tex + (float2(-0.5, -0.5) * PixelSize));
+   float4 D = tex2D(SampleImage, Tex + (float2(+0.5, -0.5) * PixelSize));
+   Output.Ix = (B + D) - (A + C);
+   Output.Iy = (A + B) - (C + D);
+   return Output;
+}
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/social/instagram.html b/source/social/instagram.html new file mode 100644 index 0000000..53ad577 --- /dev/null +++ b/source/social/instagram.html @@ -0,0 +1,179 @@ + + + + + + + + Instagram — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Instagram

+
+

Account

+
+

Requirements

+
    +
  1. Description of the creator

  2. +
  3. Other links (if possible)

  4. +
+
+
+
+

Posts

+
+

Requirements

+
    +
  1. No Instagram filters or cropping

  2. +
  3. At least 1 sentence on what the content is about

  4. +
  5. Only 3 to 5 hashtags

    +
      +
    • Hashtags must be relevant

    • +
    • Hashtags must be different

    • +
    • Hashtag set must be mix of well known and niche

    • +
    +
  6. +
+
+
+
+

Templates

+
+

Uploading Images

+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+#hashtag1 #hashtag2 #hashtag3
+
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/social/project.html b/source/social/project.html new file mode 100644 index 0000000..1f84670 --- /dev/null +++ b/source/social/project.html @@ -0,0 +1,178 @@ + + + + + + + + Personal Project — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

Personal Project

+
+

Tools

+
+
Davinci Resolve

Editing and compositing Video

+
+
FFmpeg

Media conversion, used with yt-dlp

+
+
OBS Studio

Desktop recording

+
+
yt-dlp

Downloading media

+
+
+
+
+

Downloads

+ +
+
+

Useful Commands

+
+

yt-dlp

+
+
+yt-dlp -f bv+ba <link path>
+

Downloads the best video and audio from a link.

+
+ +
+
+yt-dlp -f bv+ba -a <.txt file path>
+

Downloads the best video and audio from a list.

+
+ +
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/source/social/youtube.html b/source/social/youtube.html new file mode 100644 index 0000000..9244fdc --- /dev/null +++ b/source/social/youtube.html @@ -0,0 +1,254 @@ + + + + + + + + YouTube — A Shaderboy's Collection documentation + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+ +
+

YouTube

+
+

Account Requirements

+
    +
  1. Description of the channel

  2. +
  3. Methods of contact (if possible)

  4. +
  5. Other links (if possible)

  6. +
+
+
+

Video Requirements

+
    +
  1. Description

    +
      +
    1. At least 1 sentence on what the video is about

    2. +
    3. Timecodes (if needed)

    4. +
    5. All sources used in the video, including their respective authors

    6. +
    7. Only 3 hashtags related to the video

      +
        +
      • Hashtags must be relevant

      • +
      • Hashtags must be different

      • +
      • Hashtag set must be mix of well known and niche

      • +
      • Re-use hashtags across similar videos, especially if they share a playlist.

      • +
      +
    8. +
    9. No unnecessary keywords

    10. +
    +
  2. +
  3. High-definition thumbnails

  4. +
  5. Associated playlist(s)

  6. +
  7. Only 3 to 5 tags

    +
      +
    • Tags should be lower-case

    • +
    • Tags should be left-to-right, from least-to-most specific

    • +
    • Re-use hashtags across similar videos, especially if they share a playlist.

    • +
    +
  8. +
  9. Appropriate category

  10. +
  11. Scheduled at 12:00am before the following..

    +
      +
    • Weekends (Friday and Saturday)

    • +
    • Related events, such as holidays

    • +
    +
  12. +
+
+
+

Video Template

+ + + + + + + + + + + + + + + +

Title

Playlist

Tags

Category

Video Name • Video Subject

Generic Playlist

alternative title 1, alternative title 2, alternative title 3

People & Blogs

+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+0:00 | Event 1
+1:00 | Event 2
+
+*Links*
+• Link 1 Name: Link
+• Link 2 Name: Link
+
+*Products in This Video*
+• Product Link 1: Link
+• Product Link 2: Link
+
+Product description...
+
+*Audio Sources*
+• Recording Name (Author Name): Link
+• Song Name (Author Name): Link
+
+*Video Sources*
+• Channel Name: Link
+• Video Name (Author Name): Link
+• Video Re-upload Name (Re-upload Author Name, Original Author: Original Author Name): Link
+
+*What I Used to Make This Video*
+• Tool 1: Link
+• Tool 2: Link
+
+*Notes*
+• Rhoncus urna neque viverra justo nec ultrices dui sapien.
+
+*Disclaimer*
+• For non-commercial purposes only. Feel free to claim this video content if you own the song.
+
+#hashtag1 #hashtag2 #hashtag3
+
+
+
+

Note

+

Do not include Author Name if they are already included in the source’s name.

+
+
No:
+

Project Reality Standalone Trailer (Project Reality): https://youtu.be/vkYX41j6ZbA

+
+
Yes:
+

Project Reality Standalone Trailer: https://youtu.be/vkYX41j6ZbA

+
+
+
+
+
+ + +
+ + +
+
+
+
+ + + + + + + \ No newline at end of file