Skip to content

Commit

Permalink
Shader licensing 1
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jan 10, 2022
1 parent 3d85131 commit 5ffe3d4
Show file tree
Hide file tree
Showing 31 changed files with 683 additions and 274 deletions.
25 changes: 14 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
+ Fluid simulation
+ V-Cycle multigrid algorithm

## Shader List
## Shaders

Name|Description
----|-----------
Expand Down Expand Up @@ -45,13 +45,16 @@ kVignette | Natural vignetting effect

## Coding Convention

+ Descriptive variables, please
+ Prefix `_` to uniform objects and variables (except for user functions)
+ Suffix `VS` for `VertexShader`, `PS` for `PixelShader`
+ Use **ALLCAPS** semantics and state parameters
+ Use **Pascal_Case** for System-Value Semantics (`SV_Position`)
+ Use **PascalCase** for
+ Namespaces
+ Structs
+ User function name, parameters, and variables
+ Use **SNAKE_CASE** for macros and preprocessor defines
Practice | Variable
-------- | --------
Prefix `_` | Global objects and parameters
Respectively suffix `VS` and `PS` | `PixelShader and VertexShader`
**ALLCAPS** | Semantics and state parameters
**Pascal_Case** | System-Value Semantics (`SV_Position`)
**PascalCase** | Namespaces, structs, methods, and local parameters
**SNAKE_CASE** | Macros and preprocessor defines

## Acknowledgements

MartinBFFan and Pao on Discord for reporting bugs
BSD for bug propaganda and helping to solve my issue
41 changes: 28 additions & 13 deletions shaders/cAbberation.fx
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@

/*
Simple color shifting effect
MIT License
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform float2 _ShiftRed <
ui_type = "drag";
> = -1.0;
Expand All @@ -17,7 +43,7 @@ sampler2D _SampleColor
#endif
};

/* [Vertex Shaders] */
// Vertex shaders

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 TexCoord : TEXCOORD0)
{
Expand All @@ -26,18 +52,7 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position,
Position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

/*
[Pixel Shaders]
NOTES
PixelSize = 1.0 / screensize
TexCoord + _ShiftRed * pixelsize == TexCoord + _ShiftRed / screensize
QUESTION
"Why do we have to divide our shifting value with screensize?"
ANSWER
Texture coordinates in window-space is between 0.0 - 1.0.
Thus, just doing TexCoord + 1.0 moves the texture to the window's other sides, rendering it out of sight
*/
// Pixel shaders

void AbberationPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_Target0)
{
Expand Down
30 changes: 25 additions & 5 deletions shaders/cAutoExposure.fx
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@

/*
Adaptive, temporal exposure by Brimson
Based on https://github.com/TheRealMJP/BakingLab
THIS EFFECT IS DEDICATED TO THE BRAVE SHADER DEVELOPERS OF RESHADE
Simple adaptive exposure based on https://github.com/TheRealMJP/BakingLab
MIT License
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform float _TimeRate <
Expand Down Expand Up @@ -43,7 +63,7 @@ sampler2D _SampleLumaLOD
Texture = _RenderLumaLOD;
};

/* [Vertex Shaders] */
// Vertex shaders

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 TexCoord : TEXCOORD0)
{
Expand All @@ -52,7 +72,7 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position,
Position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

/* [Pixel Shaders] */
// Pixel shaders

void BlitPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_Target0)
{
Expand Down
57 changes: 36 additions & 21 deletions shaders/cBloom.fx
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@

/*
Dual-filtering bloom
Kernels
http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
Thresholding
https://github.com/keijiro/Kino [MIT]
Tonemap
https://github.com/TheRealMJP/BakingLab [MIT]
Dual-filtering Bloom
MIT License
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform float _Threshold <
Expand Down Expand Up @@ -146,7 +162,8 @@ sampler2D _SampleBloom8
Texture = _RenderBloom8;
};

/* [ Vertex Shaders ] */
// Vertex shaders
// Sampling kernels: http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 TexCoord : TEXCOORD0)
{
Expand Down Expand Up @@ -253,17 +270,17 @@ void UpsampleVS2(in uint ID : SV_VertexID, out float4 Position : SV_Position, ou
UpsampleVS(ID, Position, TexCoord, 2.0);
}

/* [Pixel Shaders] */
// Pixel shaders
// Thresholding: https://github.com/keijiro/Kino [MIT]
// Tonemapping: https://github.com/TheRealMJP/BakingLab [MIT]

float4 DownsamplePS(sampler2D Source, float4 TexCoord[4])
{
/*
A0 B0 C0
D0 D1
A1 B1 C1
D2 D3
A2 B2 C2
*/
// A0 B0 C0
// D0 D1
// A1 B1 C1
// D2 D3
// A2 B2 C2

float4 D0 = tex2D(Source, TexCoord[0].xw);
float4 D1 = tex2D(Source, TexCoord[0].zw);
Expand Down Expand Up @@ -294,11 +311,9 @@ float4 DownsamplePS(sampler2D Source, float4 TexCoord[4])

float4 UpsamplePS(sampler2D Source, float4 TexCoord[3])
{
/*
A0 B0 C0
A1 B1 C1
A2 B2 C2
*/
// A0 B0 C0
// A1 B1 C1
// A2 B2 C2

float4 A0 = tex2D(Source, TexCoord[0].xy);
float4 A1 = tex2D(Source, TexCoord[0].xz);
Expand Down
30 changes: 28 additions & 2 deletions shaders/cCheckerBoard.fx
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@

/* [Vertex Shaders] */
/*
Simple 2-color checkerboarding shader
MIT License
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform float4 _Color1 <
ui_min = 0.0;
Expand All @@ -18,14 +42,16 @@ uniform bool _InvertCheckerboard <
ui_label = "Invert Checkerboard Pattern";
> = false;

// Vertex shaders

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 TexCoord : TEXCOORD0)
{
TexCoord.x = (ID == 2) ? 2.0 : 0.0;
TexCoord.y = (ID == 1) ? 2.0 : 0.0;
Position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

/* [Pixel Shaders] */
// Pixel shaders

void CheckerBoardPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_Target0)
{
Expand Down
24 changes: 22 additions & 2 deletions shaders/cColorBlendOp.fx
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@

/*
Color tinting without texture fetches
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform float4 _Color <
Expand All @@ -9,7 +29,7 @@ uniform float4 _Color <
ui_type = "color";
> = 1.0;

/* [Vertex Shaders] */
// Vertex shaders

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position)
{
Expand All @@ -20,7 +40,7 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position)
Position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

/* [Pixel Shaders] */
// Pixel shaders

void ColorPS(in float4 Position : SV_Position, out float4 OutputColor0 : SV_Target0)
{
Expand Down
52 changes: 38 additions & 14 deletions shaders/cColorNormalization.fx
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

/*
Various types of color normalization
Various color normalization algorithms
Sources
Angle-Retaining Chromaticity
Title = "ARC: Angle-Retaining Chromaticity diagram for color constancy error analysis"
Authors = Marco Buzzelli and Simone Bianco and Raimondo Schettini
Year = 2020
Link = http://www.ivl.disco.unimib.it/activities/arc/
Jamie Wong's Chromaticity
Title = "Color: From Hexcodes to Eyeballs"
Authors = Jamie Wong
Year = 2018
Link = http://jamie-wong.com/post/color/
MIT License
Copyright (c) 2022 brimson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

uniform int _Select <
Expand All @@ -32,7 +42,7 @@ sampler2D _SampleColor
#endif
};

/* [Vertex Shaders] */
// Vertex shaders

void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, out float2 TexCoord : TEXCOORD0)
{
Expand All @@ -41,7 +51,21 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position,
Position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

/* [Pixel Shaders] */
// Pixel shaders

/*
Sources
Angle-Retaining Chromaticity
Title = "ARC: Angle-Retaining Chromaticity diagram for color constancy error analysis"
Authors = Marco Buzzelli and Simone Bianco and Raimondo Schettini
Year = 2020
Link = http://www.ivl.disco.unimib.it/activities/arc/
Jamie Wong's Chromaticity
Title = "Color: From Hexcodes to Eyeballs"
Authors = Jamie Wong
Year = 2018
Link = http://jamie-wong.com/post/color/
*/

void NormalizationPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float3 OutputColor0 : SV_Target0)
{
Expand Down
Loading

0 comments on commit 5ffe3d4

Please sign in to comment.