project: Apply Coding Guidelines

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2021-09-07 02:58:17 +02:00
parent 041989df91
commit 91c9df3097
13 changed files with 167 additions and 168 deletions

View file

@ -232,13 +232,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (WIN32 AND CMAKE_CXX_COMPILER_ID STR
# - Enable multi-processor compiling.
# Build with dynamic MSVC linkage.
add_compile_options(
$<$<CONFIG:>:/MD>
$<$<CONFIG:Debug>:/MDd>
$<$<CONFIG:Release>:/MD>
$<$<CONFIG:RelWithDebInfo>:/MD>
$<$<CONFIG:MinSizeRel>:/MD>
)
add_compile_options(
$<$<CONFIG:>:/MD>
$<$<CONFIG:Debug>:/MDd>
$<$<CONFIG:Release>:/MD>
$<$<CONFIG:RelWithDebInfo>:/MD>
$<$<CONFIG:MinSizeRel>:/MD>
)
# Enable most useful warnings.
set(DISABLED_WARNINGS

View file

@ -8,26 +8,26 @@
//
// Instead of sampling every texel like this:
//
// |Tx|Tx|Tx|Tx|Tx|
// Tx|-2|-1| 0|+1|+2|
// |Tx|Tx|Tx|Tx|Tx|
// Tx|-2|-1| 0|+1|+2|
//
// Linear optimization will sample like this:
//
// |Tx|Tx|Tx|Tx|Tx|
// Tx| -1 | 0| +1 |
// |Tx|Tx|Tx|Tx|Tx|
// Tx| -1 | 0| +1 |
//
// This effectively removes half the necessary samples and looks identical when
// when used with box blur. However there is an edge case when the blur width
// is not a multiple of two, where two additional samples have to be spent on
// reading the outer edge:
//
// |Tx|Tx|Tx|Tx|Tx|Tx|Tx|
// Tx|-2| -1 | 0| +1 |+2|
// |Tx|Tx|Tx|Tx|Tx|Tx|Tx|
// Tx|-2| -1 | 0| +1 |+2|
//
// or this alternative pattern that uses two less samples:
//
// |Tx|Tx|Tx|Tx|Tx|Tx|Tx|
// Tx| 0 | +1 | +2 |+3|
// |Tx|Tx|Tx|Tx|Tx|Tx|Tx|
// Tx| 0 | +1 | +2 |+3|
//
// With careful planning this can even be used for other types of Blur, such as
// Gaussian Blur, which suffers a larger hit - however there are better and
@ -46,14 +46,14 @@ float4 PSBlur1D(VertexInformation vtx) : TARGET {
// y = yes, s = skip, b = break
// Size-> | 1| 2| 3| 4| 5| 6| 7|
// -------+--+--+--+--+--+--+--+
// n=1 | b| y| y| y| y| y| y|
// n=2 | |bs| s| s| s| s| s|
// n=3 | | b| b| y| y| y| y|
// n=4 | | | |bs| s| s| s|
// n=5 | | | | b| b| y| y|
// n=6 | | | | | |bs| s|
// n=7 | | | | | | b| b|
// n=8 | | | | | | | |
// n=1 | b| y| y| y| y| y| y|
// n=2 | |bs| s| s| s| s| s|
// n=3 | | b| b| y| y| y| y|
// n=4 | | | |bs| s| s| s|
// n=5 | | | | b| b| y| y|
// n=6 | | | | | |bs| s|
// n=7 | | | | | | b| b|
// n=8 | | | | | | | |
float4 final = pImage.Sample(LinearClampSampler, vtx.uv);
for (uint n = 1u; (n < uint(pSize)) && (n < MAX_BLUR_SIZE); n += 2u) {

View file

@ -53,11 +53,11 @@ struct VertexInformation {
};
sampler_state LinearClampSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
};
//------------------------------------------------------------------------------

View file

@ -38,7 +38,7 @@ float4 RGBAtoHSLA(float4 rgba) {
}
float3 HSLtoRGB(float3 hsl) {
float3 rgb = clamp(
float3 rgb = clamp(
abs(
fmod(
hsl.x * 6.0 + float3(0.0, 4.0, 2.0),
@ -48,7 +48,7 @@ float3 HSLtoRGB(float3 hsl) {
0.0,
1.0
);
return hsl.z + hsl.y * (rgb - 0.5) * (1.0 - abs(2.0 * hsl.z - 1.0));
return hsl.z + hsl.y * (rgb - 0.5) * (1.0 - abs(2.0 * hsl.z - 1.0));
};
float4 HSLAtoRGBA(float4 hsla) {

View file

@ -7,7 +7,7 @@ float3 RGBtoHSV(float3 rgb) {
const float e = 1.0e-10;
#ifdef RGB_HSV_FASTCONDITIONALMOVE
float4 p = rgb.g < rgb.b ? float4(rgb.bg, K.wz) : float4(rgb.gb, K.xy);
float4 q = rgb.r < p.x ? float4(p.xyw, rgb.r) : float4(rgb.r, p.yzx);
float4 q = rgb.r < p.x ? float4(p.xyw, rgb.r) : float4(rgb.r, p.yzx);
#else
float4 p = lerp(float4(rgb.bg, K.wz), float4(rgb.gb, K.xy), step(rgb.b, rgb.g));
float4 q = lerp(float4(p.xyw, rgb.r), float4(rgb.r, p.yzx), step(p.x, rgb.r));

View file

@ -1,7 +1,7 @@
sampler_state __LUTSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 generate_lut(uint bit_depth, float2 uv) {

View file

@ -17,19 +17,19 @@ uniform float mask_multiplier;
// Data
sampler_state pointSampler {
Filter = Point;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
Filter = Point;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
};
sampler_state linearSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
MinLOD = 0;
MaxLOD = 0;
};
struct VertDataIn {

View file

@ -4,9 +4,9 @@ uniform float2 imageTexel;
uniform int level;
sampler_state def_sampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertexData {

View file

@ -107,10 +107,10 @@ float4 PS_SDFGenerator_v1(VertDataOut v_in) : TARGET
}
}
}
if (lowest < NEAR_INFINITE) {
outval.g = lowest;
outval.ba = lowest_origin;
}
if (lowest < NEAR_INFINITE) {
outval.g = lowest;
outval.ba = lowest_origin;
}
} else {
// Outside
// TODO: Optimize to be O(n*n) instead of (2n*2n)
@ -132,10 +132,10 @@ float4 PS_SDFGenerator_v1(VertDataOut v_in) : TARGET
}
}
}
if (lowest < NEAR_INFINITE) {
outval.r = lowest;
outval.ba = lowest_origin;
}
if (lowest < NEAR_INFINITE) {
outval.r = lowest;
outval.ba = lowest_origin;
}
}
return outval;
@ -178,10 +178,10 @@ float4 PS_SDFGenerator_v1_1(VertDataOut v_in) : TARGET
}
}
}
if (lowest < NEAR_INFINITE) {
outval.g = lowest;
outval.ba = lowest_origin;
} else {
if (lowest < NEAR_INFINITE) {
outval.g = lowest;
outval.ba = lowest_origin;
} else {
outval.g = self.g + step;
}
} else {
@ -205,10 +205,10 @@ float4 PS_SDFGenerator_v1_1(VertDataOut v_in) : TARGET
}
}
}
if (lowest < NEAR_INFINITE) {
outval.r = lowest;
outval.ba = lowest_origin;
} else {
if (lowest < NEAR_INFINITE) {
outval.r = lowest;
outval.ba = lowest_origin;
} else {
outval.r = self.r + step;
}
}
@ -224,4 +224,3 @@ technique Draw
pixel_shader = PS_SDFGenerator_v1_1(v_in);
}
}

View file

@ -17,27 +17,27 @@ uniform float4x4 ViewProj;
// Samplers
//------------------------------------------------------------------------------
sampler_state PointRepeatSampler {
Filter = Point;
AddressU = Repeat;
AddressV = Repeat;
Filter = Point;
AddressU = Repeat;
AddressV = Repeat;
};
sampler_state PointClampSampler {
Filter = Point;
AddressU = Clamp;
AddressV = Clamp;
Filter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
sampler_state LinearRepeatSampler {
Filter = Linear;
AddressU = Repeat;
AddressV = Repeat;
Filter = Linear;
AddressU = Repeat;
AddressV = Repeat;
};
sampler_state LinearClampSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
//------------------------------------------------------------------------------

View file

@ -169,7 +169,7 @@ float3 RGBtoHSV(float3 RGBA) {
const float e = 1.0e-10;
#ifdef RGB_HSV_FASTCONDITIONALMOVE
float4 p = RGBA.g < RGBA.b ? float4(RGBA.bg, K.wz) : float4(RGBA.gb, K.xy);
float4 q = RGBA.r < p.x ? float4(p.xyw, RGBA.r) : float4(RGBA.r, p.yzx);
float4 q = RGBA.r < p.x ? float4(p.xyw, RGBA.r) : float4(RGBA.r, p.yzx);
#else
float4 p = lerp(float4(RGBA.bg, K.wz), float4(RGBA.gb, K.xy), step(RGBA.b, RGBA.g));
float4 q = lerp(float4(p.xyw, RGBA.r), float4(RGBA.r, p.yzx), step(p.x, RGBA.r));
@ -221,42 +221,42 @@ technique HSV
//------------------------------------------------------------------------------
// XYZ <-> RGB
float4 RGBtoXYZ( float4 c ) {
float3 tmp;
tmp.x = ( c.r > 0.04045 ) ? pow( ( c.r + 0.055 ) / 1.055, 2.4 ) : c.r / 12.92;
tmp.y = ( c.g > 0.04045 ) ? pow( ( c.g + 0.055 ) / 1.055, 2.4 ) : c.g / 12.92,
tmp.z = ( c.b > 0.04045 ) ? pow( ( c.b + 0.055 ) / 1.055, 2.4 ) : c.b / 12.92;
const float3x3 mat = float3x3(
float3 tmp;
tmp.x = ( c.r > 0.04045 ) ? pow( ( c.r + 0.055 ) / 1.055, 2.4 ) : c.r / 12.92;
tmp.y = ( c.g > 0.04045 ) ? pow( ( c.g + 0.055 ) / 1.055, 2.4 ) : c.g / 12.92,
tmp.z = ( c.b > 0.04045 ) ? pow( ( c.b + 0.055 ) / 1.055, 2.4 ) : c.b / 12.92;
const float3x3 mat = float3x3(
0.4124, 0.3576, 0.1805,
0.2126, 0.7152, 0.0722,
0.0193, 0.1192, 0.9505
0.2126, 0.7152, 0.0722,
0.0193, 0.1192, 0.9505
);
float3 r = 100.0 * mul(tmp, mat);
return float4(r.r, r.g, r.b, c.a);
return float4(r.r, r.g, r.b, c.a);
}
float4 XYZtoRGB( float4 c ) {
const float3x3 mat = float3x3(
3.2406, -1.5372, -0.4986,
-0.9689, 1.8758, 0.0415,
0.0557, -0.2040, 1.0570
3.2406, -1.5372, -0.4986,
-0.9689, 1.8758, 0.0415,
0.0557, -0.2040, 1.0570
);
float3 v = mul(c.rgb / 100.0, mat);
float4 r;
r.x = ( v.r > 0.0031308 ) ? (( 1.055 * pow( v.r, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.r;
r.y = ( v.g > 0.0031308 ) ? (( 1.055 * pow( v.g, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.g;
r.z = ( v.b > 0.0031308 ) ? (( 1.055 * pow( v.b, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.b;
float3 v = mul(c.rgb / 100.0, mat);
float4 r;
r.x = ( v.r > 0.0031308 ) ? (( 1.055 * pow( v.r, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.r;
r.y = ( v.g > 0.0031308 ) ? (( 1.055 * pow( v.g, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.g;
r.z = ( v.b > 0.0031308 ) ? (( 1.055 * pow( v.b, ( 1.0 / 2.4 ))) - 0.055 ) : 12.92 * v.b;
r.a = c.a;
return r;
return r;
}
// XYZ <-> L*a*b
float4 XYZtoLAB( float4 c ) {
float3 n = c.rgb / float3(95.047, 100, 108.883);
float3 v;
v.x = ( n.x > 0.008856 ) ? pow( n.x, 1.0 / 3.0 ) : ( 7.787 * n.x ) + ( 16.0 / 116.0 );
v.y = ( n.y > 0.008856 ) ? pow( n.y, 1.0 / 3.0 ) : ( 7.787 * n.y ) + ( 16.0 / 116.0 );
v.z = ( n.z > 0.008856 ) ? pow( n.z, 1.0 / 3.0 ) : ( 7.787 * n.z ) + ( 16.0 / 116.0 );
return float4(
float3 n = c.rgb / float3(95.047, 100, 108.883);
float3 v;
v.x = ( n.x > 0.008856 ) ? pow( n.x, 1.0 / 3.0 ) : ( 7.787 * n.x ) + ( 16.0 / 116.0 );
v.y = ( n.y > 0.008856 ) ? pow( n.y, 1.0 / 3.0 ) : ( 7.787 * n.y ) + ( 16.0 / 116.0 );
v.z = ( n.z > 0.008856 ) ? pow( n.z, 1.0 / 3.0 ) : ( 7.787 * n.z ) + ( 16.0 / 116.0 );
return float4(
( 116.0 * v.y ) - 16.0,
500.0 * ( v.x - v.y ),
200.0 * ( v.y - v.z ),
@ -265,21 +265,21 @@ float4 XYZtoLAB( float4 c ) {
}
float4 LABtoXYZ( float4 c ) {
float fy = ( c.x + 16.0 ) / 116.0;
float fx = c.y / 500.0 + fy;
float fz = fy - c.z / 200.0;
return float4(
95.047 * (( fx > 0.206897 ) ? fx * fx * fx : ( fx - 16.0 / 116.0 ) / 7.787),
100.000 * (( fy > 0.206897 ) ? fy * fy * fy : ( fy - 16.0 / 116.0 ) / 7.787),
108.883 * (( fz > 0.206897 ) ? fz * fz * fz : ( fz - 16.0 / 116.0 ) / 7.787),
float fy = ( c.x + 16.0 ) / 116.0;
float fx = c.y / 500.0 + fy;
float fz = fy - c.z / 200.0;
return float4(
95.047 * (( fx > 0.206897 ) ? fx * fx * fx : ( fx - 16.0 / 116.0 ) / 7.787),
100.000 * (( fy > 0.206897 ) ? fy * fy * fy : ( fy - 16.0 / 116.0 ) / 7.787),
108.883 * (( fz > 0.206897 ) ? fz * fz * fz : ( fz - 16.0 / 116.0 ) / 7.787),
c.a
);
);
}
// L*a*b <-> RGB
float4 RGBtoLAB( float4 c ) {
float4 lab = XYZtoLAB(RGBtoXYZ(c));
return float4(
float4 lab = XYZtoLAB(RGBtoXYZ(c));
return float4(
lab.x / 100.0,
0.5 + 0.5 * ( lab.y / 127.0 ),
0.5 + 0.5 * ( lab.z / 127.0 ),
@ -288,7 +288,7 @@ float4 RGBtoLAB( float4 c ) {
}
float4 LABtoRGB( float4 c ) {
return XYZtoRGB(
return XYZtoRGB(
LABtoXYZ(
float4(
100.0 * c.x,

View file

@ -86,11 +86,11 @@ VertData VSDefault(VertData v_in) {
}
float4 PSDefault(VertData v_in) : TARGET {
static const float2 center = float2(.5, .5);
float4 smp = InputA.Sample(def_sampler, v_in.uv);
static const float2 center = float2(.5, .5);
float4 smp = InputA.Sample(def_sampler, v_in.uv);
float borderFade = clamp(((1. - distance(v_in.uv, center)) - (_00_vignette_area - .5)), 0., 1.);
float4 vignette_color = _01_vignette_color;
float4 vignette_color = _01_vignette_color;
return lerp(smp, vignette_color, (1. - borderFade) / max(1. - _02_vignette_strength, 0.0001));
}
@ -104,20 +104,20 @@ technique Draw
}
float4 PSRectangle(VertData v_in) : TARGET {
static const float2 center = float2(.5, .5);
float4 smp = InputA.Sample(def_sampler, v_in.uv);
static const float2 center = float2(.5, .5);
float4 smp = InputA.Sample(def_sampler, v_in.uv);
if (_00_vignette_area < 0.01)
return smp;
if (_00_vignette_area < 0.01)
return smp;
float2 borderArea = center * _00_vignette_area;
float2 borderDistance = center;
borderDistance -= abs(v_in.uv - center);
borderDistance /= center;
borderDistance -= center * _00_vignette_area;
borderDistance = min(borderDistance, 0);
borderDistance += borderArea;
borderDistance /= borderArea;
borderDistance -= abs(v_in.uv - center);
borderDistance /= center;
borderDistance -= center * _00_vignette_area;
borderDistance = min(borderDistance, 0);
borderDistance += borderArea;
borderDistance /= borderArea;
// Now apply a modifier so that we only get the border area.
float borderFade = sin(borderDistance.x * HalfPI) * sin(borderDistance.y * HalfPI);

View file

@ -85,13 +85,13 @@ VertData VSDefault(VertData v_in) {
}
float4 PSDefault(VertData v_in) : TARGET {
float animProgress = TransitionTime;
float animProgress = TransitionTime;
// Progress as a bounce value (0..1..0)
float animStuff = 1.0 - (abs(animProgress - 0.5) * 2.0);
// There are two ways to calculate this, one is pixel aligned the other is block aligned.
float animStuff = 1.0 - (abs(animProgress - 0.5) * 2.0);
// There are two ways to calculate this, one is pixel aligned the other is block aligned.
float animBlockSize = 0;
if (_0_oldStyle) {
if (_0_oldStyle) {
// Block Size, always a multiple of 2. (Block Aligned)
animBlockSize = pow(2.0, floor(_2_maximumBlockSize * animStuff));
} else {