mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
project: Apply Coding Guidelines
This commit is contained in:
parent
041989df91
commit
91c9df3097
13 changed files with 167 additions and 168 deletions
|
@ -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
|
||||
|
|
|
@ -7,27 +7,27 @@
|
|||
// the actual thing.
|
||||
//
|
||||
// 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) {
|
||||
|
|
|
@ -39,7 +39,7 @@ uniform float2 pImageSize;
|
|||
uniform float2 pImageTexel;
|
||||
uniform float pSize;
|
||||
uniform float pSizeInverseMul;
|
||||
uniform float pAngle;
|
||||
uniform float pAngle;
|
||||
uniform float2 pCenter;
|
||||
uniform float2 pStepScale;
|
||||
uniform float4 pKernel[KERNEL_SIZE];
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -13,10 +13,10 @@ float3 RGBtoHSL(float3 rgb) {
|
|||
l = ( cMax + cMin ) / 2.0;
|
||||
if ( cMax > cMin ) {
|
||||
float cDelta = cMax - cMin;
|
||||
|
||||
|
||||
//s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
|
||||
s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
|
||||
|
||||
|
||||
if ( r == cMax ) {
|
||||
h = ( g - b ) / cDelta;
|
||||
} else if ( g == cMax ) {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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) {
|
||||
|
@ -12,7 +12,7 @@ float4 generate_lut(uint bit_depth, float2 uv) {
|
|||
uint2 xy = uint2(floor(uv * container_size));
|
||||
uint2 rg = xy % size;
|
||||
uint2 bb = xy / size;
|
||||
|
||||
|
||||
return float4(
|
||||
rg.xy / float(size - 1),
|
||||
((bb.y * z_size) + bb.x) / float(size - 1),
|
||||
|
@ -28,7 +28,7 @@ float4 generate_lut2(float2 uv, uint4 params0) {
|
|||
uint2 xy = uint2(floor(uv * container_size));
|
||||
uint2 rg = xy % size;
|
||||
uint2 bb = xy / size;
|
||||
|
||||
|
||||
return float4(
|
||||
rg.xy / float(size - 1),
|
||||
((bb.y * z_size) + bb.x) / float(size - 1),
|
||||
|
@ -69,7 +69,7 @@ float3 sample_lut(float3 color, uint bit_depth, texture2D lut_texture) {
|
|||
// 6. Figure out the Y location of the cell in the grid.
|
||||
uint z_lo_y = z_lo / z_size;
|
||||
uint z_hi_y = z_hi / z_size;
|
||||
|
||||
|
||||
// 7. Convert the X and Y locations into UV coordinates.
|
||||
float2 z_lo_uv = float2(z_lo_x, z_lo_y) * inverse_z_size;
|
||||
float2 z_hi_uv = float2(z_hi_x, z_hi_y) * inverse_z_size;
|
||||
|
@ -115,7 +115,7 @@ float3 sample_lut2(float3 color, texture2D lut_texture, int4 params0, float4 par
|
|||
// 6. Figure out the Y location of the cell in the grid.
|
||||
uint z_lo_y = z_lo / z_size;
|
||||
uint z_hi_y = z_hi / z_size;
|
||||
|
||||
|
||||
// 7. Convert the X and Y locations into UV coordinates.
|
||||
float2 z_lo_uv = float2(z_lo_x, z_lo_y) * inverse_z_size;
|
||||
float2 z_hi_uv = float2(z_hi_x, z_hi_y) * inverse_z_size;
|
||||
|
|
|
@ -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 {
|
||||
|
@ -74,28 +74,28 @@ float RegionFeathered(float2 uv) {
|
|||
float4 PSRegion(VertDataOut v_out) : TARGET {
|
||||
float alpha = Region(v_out.uv);
|
||||
float4 orig = image_orig.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
return lerp(orig, blur, alpha);
|
||||
}
|
||||
|
||||
float4 PSRegionInverted(VertDataOut v_out) : TARGET {
|
||||
float alpha = 1.0 - Region(v_out.uv);
|
||||
float4 orig = image_orig.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
return lerp(orig, blur, alpha);
|
||||
}
|
||||
|
||||
float4 PSRegionFeather(VertDataOut v_out) : TARGET {
|
||||
float alpha = RegionFeathered(v_out.uv);
|
||||
float4 orig = image_orig.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
return lerp(orig, blur, alpha);
|
||||
}
|
||||
|
||||
float4 PSRegionFeatherInverted(VertDataOut v_out) : TARGET {
|
||||
float alpha = 1.0 - RegionFeathered(v_out.uv);
|
||||
float4 orig = image_orig.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
return lerp(orig, blur, alpha);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ float4 PSImage(VertDataOut v_out) : TARGET {
|
|||
float4 mask = mask_image.Sample(linearSampler, v_out.uv) * mask_color * mask_multiplier;
|
||||
float alpha = clamp(mask.r + mask.g + mask.b + mask.a, 0.0, 1.0);
|
||||
float4 orig = image_orig.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
float4 blur = image_blur.Sample(pointSampler, v_out.uv);
|
||||
return lerp(orig, blur, alpha);
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,6 @@ technique Image
|
|||
pass
|
||||
{
|
||||
vertex_shader = VSDefault(v_out);
|
||||
pixel_shader = PSImage(v_out);
|
||||
pixel_shader = PSImage(v_out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// - R: If outside, distance to nearest wall, otherwise 0.
|
||||
// - G: If inside, distance to nearest wall, otherwise 0.
|
||||
// - BA: UV coordinates of nearest wall.
|
||||
//
|
||||
//
|
||||
// Version 1.1:
|
||||
// - See Version 1.0
|
||||
// - Adjusted R, G to be 0..1 range, multiply by 65536.0 to get proper results.
|
||||
|
@ -75,17 +75,17 @@ VertDataOut VSDefault(VertDataIn v_in)
|
|||
float4 PS_SDFGenerator_v1(VertDataOut v_in) : TARGET
|
||||
{
|
||||
float4 outval = float4(0.0, 0.0, v_in.uv.x, v_in.uv.y);
|
||||
|
||||
|
||||
// utility values
|
||||
float2 uv_step = 1.0 / _size;
|
||||
float lowest = NEAR_INFINITE;
|
||||
float2 lowest_source = float2(NEAR_INFINITE, NEAR_INFINITE);
|
||||
float2 lowest_origin = float2(NEAR_INFINITE, NEAR_INFINITE);
|
||||
|
||||
// inputs
|
||||
float imageA = _image.Sample(imageSampler, v_in.uv).a;
|
||||
|
||||
// inputs
|
||||
float imageA = _image.Sample(imageSampler, v_in.uv).a;
|
||||
// sdf contains 4 values: R = Positive Distance, G = Negative Distance, BA = UV of nearest edge.
|
||||
|
||||
|
||||
if (imageA > _threshold) {
|
||||
// Inside
|
||||
// TODO: Optimize to be O(n*n) instead of (2n*2n)
|
||||
|
@ -94,12 +94,12 @@ float4 PS_SDFGenerator_v1(VertDataOut v_in) : TARGET
|
|||
if ((x == 0) && (y == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
float2 dtr = float2(x, y);
|
||||
float2 dt = uv_step * dtr;
|
||||
float4 here = _sdf.Sample(sdfSampler, v_in.uv + dt);
|
||||
float dst = abs(distance(float2(0., 0.), dtr));
|
||||
|
||||
|
||||
if (lowest > (here.g + dst)) {
|
||||
lowest = here.g + dst;
|
||||
lowest_source = v_in.uv + dt;
|
||||
|
@ -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)
|
||||
|
@ -119,12 +119,12 @@ float4 PS_SDFGenerator_v1(VertDataOut v_in) : TARGET
|
|||
if ((x == 0) && (y == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
float2 dtr = float2(x, y);
|
||||
float2 dt = uv_step * dtr;
|
||||
float4 here = _sdf.Sample(sdfSampler, v_in.uv + dt);
|
||||
float dst = abs(distance(float2(0., 0.), dtr));
|
||||
|
||||
|
||||
if (lowest > (here.r + dst)) {
|
||||
lowest = here.r + dst;
|
||||
lowest_source = v_in.uv + dt;
|
||||
|
@ -132,12 +132,12 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -146,17 +146,17 @@ float4 PS_SDFGenerator_v1_1(VertDataOut v_in) : TARGET
|
|||
const float step = 1.0 / MAX_DISTANCE;
|
||||
|
||||
float4 outval = float4(0.0, 0.0, v_in.uv.x, v_in.uv.y);
|
||||
|
||||
|
||||
// utility values
|
||||
float2 uv_step = 1.0 / _size;
|
||||
float lowest = NEAR_INFINITE;
|
||||
float2 lowest_source = float2(NEAR_INFINITE, NEAR_INFINITE);
|
||||
float2 lowest_origin = float2(NEAR_INFINITE, NEAR_INFINITE);
|
||||
|
||||
// inputs
|
||||
|
||||
// inputs
|
||||
float imageA = _image.Sample(imageSampler, v_in.uv).a;
|
||||
float4 self = _sdf.Sample(sdfSampler1_1, v_in.uv);
|
||||
|
||||
|
||||
if (imageA > _threshold) {
|
||||
// Inside
|
||||
// TODO: Optimize to be O(n*n) instead of (2n*2n)
|
||||
|
@ -165,12 +165,12 @@ float4 PS_SDFGenerator_v1_1(VertDataOut v_in) : TARGET
|
|||
if ((x == 0) && (y == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
float2 dtr = float2(x, y);
|
||||
float2 dt = uv_step * dtr;
|
||||
float4 here = _sdf.Sample(sdfSampler1_1, v_in.uv + dt);
|
||||
float dst = abs(distance(float2(0., 0.), dtr)) * step;
|
||||
|
||||
|
||||
if (lowest > (here.g + dst)) {
|
||||
lowest = here.g + dst;
|
||||
lowest_source = v_in.uv + dt;
|
||||
|
@ -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 {
|
||||
|
@ -192,12 +192,12 @@ float4 PS_SDFGenerator_v1_1(VertDataOut v_in) : TARGET
|
|||
if ((x == 0) && (y == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
float2 dtr = float2(x, y);
|
||||
float2 dt = uv_step * dtr;
|
||||
float4 here = _sdf.Sample(sdfSampler1_1, v_in.uv + dt);
|
||||
float dst = abs(distance(float2(0., 0.), dtr)) * step;
|
||||
|
||||
|
||||
if (lowest > (here.r + dst)) {
|
||||
lowest = here.r + dst;
|
||||
lowest_source = v_in.uv + dt;
|
||||
|
@ -205,14 +205,14 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return outval;
|
||||
}
|
||||
|
||||
|
@ -224,4 +224,3 @@ technique Draw
|
|||
pixel_shader = PS_SDFGenerator_v1_1(v_in);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -33,7 +33,7 @@ uniform int2 TransitionSize<
|
|||
|
||||
uniform bool _0_oldStyle<
|
||||
string name = "Retro Style";
|
||||
|
||||
|
||||
> = false;
|
||||
uniform float2 _1_pixelateCenter<
|
||||
string name = "Pixelation Center";
|
||||
|
@ -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 {
|
||||
|
@ -128,6 +128,6 @@ technique Draw
|
|||
pass
|
||||
{
|
||||
vertex_shader = VSDefault(v_in);
|
||||
pixel_shader = PSDefault(v_in);
|
||||
pixel_shader = PSDefault(v_in);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue