Skip to content

Commit

Permalink
Added sections to code
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jun 8, 2023
1 parent ed28e95 commit 3754d49
Show file tree
Hide file tree
Showing 34 changed files with 301 additions and 95 deletions.
6 changes: 5 additions & 1 deletion shaders/cshade/cAbberation.fx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "shared/cGraphics.fxh"

/*
Construct options
[Shader Options]
*/

uniform float2 _ShiftRed <
Expand All @@ -16,6 +16,10 @@ uniform float2 _ShiftBlue <
ui_type = "drag";
> = 1.0;

/*
[Pixel Shaders]
*/

float4 PS_Abberation(VS2PS_Quad Input) : SV_TARGET0
{
const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
Expand Down
10 changes: 9 additions & 1 deletion shaders/cshade/cAutoExposure.fx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Automatic exposure shader using hardware blending
*/

/*
[Shader Options]
*/

uniform float _Frametime < source = "frametime"; >;

uniform float _SmoothingSpeed <
Expand Down Expand Up @@ -53,11 +57,15 @@ uniform bool _Debug <
ui_type = "radio";
> = false;

/*
[Textures & Samplers]
*/

CREATE_TEXTURE(LumaTex, int2(256, 256), R16F, 9)
CREATE_SAMPLER(SampleLumaTex, LumaTex, LINEAR, CLAMP)

/*
Pixel shaders
[Pixel Shaders]
---
TODO: Add average, spot, and center-weighted metering with adjustable radius and slope
---
Expand Down
12 changes: 11 additions & 1 deletion shaders/cshade/cBlending.fx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "shared/cGraphics.fxh"

/*
[Shader Options]
*/

uniform int _Blend <
ui_label = "Blend Mode";
ui_type = "combo";
Expand All @@ -16,14 +20,20 @@ uniform float3 _DestFactor <
ui_type = "drag";
> = 1.0;

/*
[Textures & Samplers]
*/

// Output in cCopyBuffer
CREATE_TEXTURE(SrcTex, BUFFER_SIZE_0, RGBA8, 1)

// Inputs in cBlendBuffer
CREATE_SRGB_SAMPLER(SampleSrcTex, SrcTex, LINEAR, CLAMP)
CREATE_SRGB_SAMPLER(SampleDestTex, CShade_ColorTex, LINEAR, CLAMP)

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

float4 PS_Copy(VS2PS_Quad Input) : SV_TARGET0
{
Expand Down
14 changes: 8 additions & 6 deletions shaders/cshade/cBlockMatching.fx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace cBlockMatching
{
/*
Construct options
[Shader Options]
*/

uniform float _MipBias <
Expand All @@ -22,6 +22,10 @@ namespace cBlockMatching
ui_max = 0.9;
> = 0.5;

/*
[Textures & Samplers]
*/

CREATE_TEXTURE(Tex1, BUFFER_SIZE_1, RG8, 3)
CREATE_SAMPLER(SampleTex1, Tex1, LINEAR, MIRROR)

Expand All @@ -46,22 +50,21 @@ namespace cBlockMatching
CREATE_TEXTURE(Tex6, BUFFER_SIZE_6, RG16F, 1)
CREATE_SAMPLER(SampleTex6, Tex6, LINEAR, MIRROR)

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

float2 PS_Normalize(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
return GetRG(Color);
}

// Copy-back
float4 PS_Copy_0(VS2PS_Quad Input) : SV_TARGET0
{
return tex2D(SampleTex1, Input.Tex0.xy);
}

// Run motion estimation

float2 PS_MFlow_Level5(VS2PS_Quad Input) : SV_TARGET0
{
float2 Vectors = 0.0;
Expand Down Expand Up @@ -92,7 +95,6 @@ namespace cBlockMatching
return float4(GetPixelMFlow(Input.Tex0, Vectors, SampleTex2b, SampleTex2a, 0), 0.0, _BlendFactor);
}

// Copy-back
float4 PS_Copy_1(VS2PS_Quad Input) : SV_TARGET0
{
return tex2D(SampleTex2a, Input.Tex0.xy);
Expand Down
8 changes: 4 additions & 4 deletions shaders/cshade/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace cBloom
{
/*
Construct options
[Shader Options]
*/

uniform float _Threshold <
Expand Down Expand Up @@ -42,7 +42,7 @@ namespace cBloom
> = 5.0;

/*
Construct textures and its samplers
[Textures & Samplers]
*/

CREATE_TEXTURE(Tex0, BUFFER_SIZE_0, RGB10A2, 1)
Expand Down Expand Up @@ -73,7 +73,7 @@ namespace cBloom
CREATE_SAMPLER(SampleTex8, Tex8, LINEAR, CLAMP)

/*
Construct vertex shaders
[Vertex Shaders]
*/

struct VS2PS_Downscale
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace cBloom
CREATE_VS_UPSCALE(VS_Upscale1, 1.0 / BUFFER_SIZE_1)

/*
Pixel shaders
[Pixel Shaders]
---
Thresholding: https://github.com/keijiro/Kino [MIT]
Tonemapping: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
Expand Down
8 changes: 8 additions & 0 deletions shaders/cshade/cCensusTransform.fx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "shared/cGraphics.fxh"

/*
[Vertex Shaders]
*/

struct VS2PS_Census
{
float4 HPos : SV_POSITION;
Expand Down Expand Up @@ -28,6 +32,10 @@ VS2PS_Census VS_Census(APP2VS Input)
return Output;
}

/*
[Pixel Shaders]
*/

float Med3(float A, float B, float C)
{
return clamp(A, min(B, C), max(B, C));
Expand Down
5 changes: 4 additions & 1 deletion shaders/cshade/cCheckerBoard.fx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "shared/cGraphics.fxh"

/*
Construct options
[Shader Options]
*/

uniform float4 _Color1 <
Expand All @@ -21,6 +21,9 @@ uniform bool _InvertCheckerboard <
ui_type = "radio";
> = false;

/*
[Pixel Shaders]
*/

float4 PS_Checkerboard(VS2PS_Quad Input) : SV_TARGET0
{
Expand Down
6 changes: 4 additions & 2 deletions shaders/cshade/cChromaticity.fx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "shared/cGraphics.fxh"

/*
Construct options
[Shader Options]
*/

uniform int _Select <
Expand All @@ -11,7 +11,9 @@ uniform int _Select <
ui_items = " Length (RG)\0 Length (RGB)\0 Average (RG)\0 Average (RGB)\0 Sum (RG)\0 Sum (RGB)\0";
> = 0;

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

float4 PS_Chromaticity(VS2PS_Quad Input) : SV_TARGET0
{
Expand Down
6 changes: 5 additions & 1 deletion shaders/cshade/cCircles.fx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "shared/cMacros.fxh"

/*
Construct options
[Shader Options]
*/

uniform float _TileAmount <
Expand All @@ -19,6 +19,10 @@ uniform float _TileRadius <
ui_max = 0.5;
> = 0.45;

/*
[Pixel Shaders]
*/

float2 GetTiles(float2 Tex)
{
Tex *= _TileAmount;
Expand Down
6 changes: 5 additions & 1 deletion shaders/cshade/cColorBlendOp.fx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "shared/cGraphics.fxh"

/*
Construct options
[Shader Options]
*/

uniform float4 _Color <
Expand All @@ -10,6 +10,10 @@ uniform float4 _Color <
ui_min = 0.0;
> = 1.0;

/*
[Pixel Shaders]
*/

float4 PS_Color(VS2PS_Quad Input) : SV_TARGET0
{
return _Color;
Expand Down
9 changes: 6 additions & 3 deletions shaders/cshade/cDiscBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace cDiscBlur
{
/*
Construct options
[Shader Options]
*/

uniform float _Offset <
Expand All @@ -25,12 +25,15 @@ namespace cDiscBlur
ui_min = 0;
> = 16;

CREATE_TEXTURE(Tex1, BUFFER_SIZE_1, RGBA8, 8)
/*
[Textures & Samplers]
*/

CREATE_TEXTURE(Tex1, BUFFER_SIZE_1, RGBA8, 8)
CREATE_SRGB_SAMPLER(SampleTex1, Tex1, LINEAR, CLAMP)

/*
Pixel shaders
[Pixel Shaders]
---
Repurposed Wojciech Sterna's shadow sampling code as a screen-space convolution
---
Expand Down
11 changes: 7 additions & 4 deletions shaders/cshade/cFilmGrain.fx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "shared/cImageProcessing.fxh"

/*
Construct options
[Shader Options]
*/

uniform float _Time < source = "timer"; >;
Expand All @@ -22,9 +22,12 @@ uniform float _Intensity <
ui_type = "drag";
> = 0.005;

// Pixel shaders
// "Well ill believe it when i see it."
// Yoinked code by Luluco250 (RIP) [https://www.shadertoy.com/view/4t2fRz] [MIT]
/*
[Pixel Shaders]
---
"Well ill believe it when i see it."
Yoinked code by Luluco250 (RIP) [https://www.shadertoy.com/view/4t2fRz] [MIT]
*/

float4 PS_FilmGrain(VS2PS_Quad Input) : SV_TARGET0
{
Expand Down
13 changes: 11 additions & 2 deletions shaders/cshade/cFrameBlending.fx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#include "shared/cGraphics.fxh"

/*
[Shader Options]
*/

uniform float _BlendFactor <
ui_label = "Blend Factor";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.5;

CREATE_TEXTURE(BlendTex, BUFFER_SIZE_0, RGBA8, 1)
/*
[Textures & Samplers]
*/

CREATE_TEXTURE(BlendTex, BUFFER_SIZE_0, RGBA8, 1)
CREATE_SRGB_SAMPLER(SampleBlendTex, BlendTex, 1, CLAMP)

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

float4 PS_Blend(VS2PS_Quad Input) : SV_TARGET0
{
Expand Down
8 changes: 8 additions & 0 deletions shaders/cshade/cGaussianBlur.fx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#include "shared/cGraphics.fxh"
#include "shared/cImageProcessing.fxh"

/*
[Shader Options]
*/

uniform float _Sigma <
ui_type = "drag";
ui_min = 0.0;
> = 1.0;

/*
[Pixel Shaders]
*/

float4 GetGaussianBlur(float2 Tex, bool IsHorizontal)
{
float2 Direction = IsHorizontal ? float2(1.0, 0.0) : float2(0.0, 1.0);
Expand Down
8 changes: 8 additions & 0 deletions shaders/cshade/cGrayscale.fx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#include "shared/cGraphics.fxh"

/*
[Shader Options]
*/

uniform int _Select <
ui_label = "Method";
ui_type = "combo";
ui_tooltip = "Select Luminance";
ui_items = " Average\0 Min\0 Median\0 Max\0 Length\0 None\0";
> = 0;

/*
[Pixel Shaders]
*/

float4 PS_Luminance(VS2PS_Quad Input) : SV_TARGET0
{
float4 OutputColor = 0.0;
Expand Down
Loading

0 comments on commit 3754d49

Please sign in to comment.