sRGBの変換の名前に接頭辞を付け、使われない定数を除く
このコミットが含まれているのは:
3ファイル変更
+26
-28
検索条件に一致するファイルはありません
@@ -7,7 +7,6 @@
|
||||
Texture2D LightTexture : register(t1);
|
||||
SamplerState LightSampler : register(s1);
|
||||
|
||||
static const int MaxSteps = 64;
|
||||
static const int TableSize = 128;
|
||||
static const int FilterTableSize = 132;
|
||||
static const int ModeRadial = 2;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
static const float DecodeThreshold = 0.04045;
|
||||
static const float EncodeThreshold = 0.0031308;
|
||||
static const float LowSlope = 12.92;
|
||||
static const float Offset = 0.055;
|
||||
static const float Scale = 1.055;
|
||||
static const float Exponent = 2.4;
|
||||
static const float SrgbDecodeThreshold = 0.04045;
|
||||
static const float SrgbEncodeThreshold = 0.0031308;
|
||||
static const float SrgbLowSlope = 12.92;
|
||||
static const float SrgbOffset = 0.055;
|
||||
static const float SrgbScale = 1.055;
|
||||
static const float SrgbExponent = 2.4;
|
||||
|
||||
float3 Decode(float3 encoded)
|
||||
float3 SrgbDecode(float3 encoded)
|
||||
{
|
||||
float3 low = encoded / LowSlope;
|
||||
float3 high = pow((encoded + Offset) / Scale, Exponent);
|
||||
return encoded <= DecodeThreshold ? low : high;
|
||||
float3 low = encoded / SrgbLowSlope;
|
||||
float3 high = pow((encoded + SrgbOffset) / SrgbScale, SrgbExponent);
|
||||
return encoded <= SrgbDecodeThreshold ? low : high;
|
||||
}
|
||||
|
||||
float3 Encode(float3 linearColor)
|
||||
float3 SrgbEncode(float3 linearColor)
|
||||
{
|
||||
float3 low = linearColor * LowSlope;
|
||||
float3 high = Scale * pow(linearColor, 1.0 / Exponent) - Offset;
|
||||
return linearColor <= EncodeThreshold ? low : high;
|
||||
float3 low = linearColor * SrgbLowSlope;
|
||||
float3 high = SrgbScale * pow(linearColor, 1.0 / SrgbExponent) - SrgbOffset;
|
||||
return linearColor <= SrgbEncodeThreshold ? low : high;
|
||||
}
|
||||
|
||||
float3 Unpremultiply(float4 premultiplied)
|
||||
@@ -26,10 +26,10 @@ float3 Unpremultiply(float4 premultiplied)
|
||||
|
||||
float4 DecodePremultiplied(float4 encoded)
|
||||
{
|
||||
return float4(Decode(Unpremultiply(encoded)) * encoded.a, encoded.a);
|
||||
return float4(SrgbDecode(Unpremultiply(encoded)) * encoded.a, encoded.a);
|
||||
}
|
||||
|
||||
float4 EncodePremultiplied(float4 linearColor)
|
||||
{
|
||||
return float4(Encode(Unpremultiply(linearColor)) * linearColor.a, linearColor.a);
|
||||
return float4(SrgbEncode(Unpremultiply(linearColor)) * linearColor.a, linearColor.a);
|
||||
}
|
||||
@@ -52,7 +52,6 @@ public sealed partial class SpectralShaderContractTests
|
||||
[Fact]
|
||||
public void TheShaderAndTheEffectAgreeOnTheConstants()
|
||||
{
|
||||
Assert.Equal(Spectrum.MaxSteps, Constant("MaxSteps"));
|
||||
Assert.Equal(Spectrum.SpectralTableLength, Constant("TableSize"));
|
||||
Assert.Equal(SpectralFilter.TableLength, Constant("FilterTableSize"));
|
||||
Assert.Equal((int)ShiftMode.Radial, Constant("ModeRadial"));
|
||||
@@ -75,23 +74,23 @@ public sealed partial class SpectralShaderContractTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("DecodeThreshold", 0.04045f)]
|
||||
[InlineData("EncodeThreshold", 0.0031308f)]
|
||||
[InlineData("LowSlope", 12.92f)]
|
||||
[InlineData("Offset", 0.055f)]
|
||||
[InlineData("Scale", 1.055f)]
|
||||
[InlineData("Exponent", 2.4f)]
|
||||
[InlineData("SrgbDecodeThreshold", 0.04045f)]
|
||||
[InlineData("SrgbEncodeThreshold", 0.0031308f)]
|
||||
[InlineData("SrgbLowSlope", 12.92f)]
|
||||
[InlineData("SrgbOffset", 0.055f)]
|
||||
[InlineData("SrgbScale", 1.055f)]
|
||||
[InlineData("SrgbExponent", 2.4f)]
|
||||
public void TheSrgbHeaderHoldsTheStandardTransferConstants(string name, float expected)
|
||||
=> Assert.Equal(expected, Constant(SrgbSource, name));
|
||||
|
||||
[Fact]
|
||||
public void TheSrgbCurvesMeetAtTheThresholds()
|
||||
{
|
||||
var slope = Constant(SrgbSource, "LowSlope");
|
||||
var linearEnd = Constant(SrgbSource, "EncodeThreshold");
|
||||
var power = Constant(SrgbSource, "Scale") * MathF.Pow(linearEnd, 1f / Constant(SrgbSource, "Exponent")) - Constant(SrgbSource, "Offset");
|
||||
var slope = Constant(SrgbSource, "SrgbLowSlope");
|
||||
var linearEnd = Constant(SrgbSource, "SrgbEncodeThreshold");
|
||||
var power = Constant(SrgbSource, "SrgbScale") * MathF.Pow(linearEnd, 1f / Constant(SrgbSource, "SrgbExponent")) - Constant(SrgbSource, "SrgbOffset");
|
||||
|
||||
Assert.Equal(Constant(SrgbSource, "DecodeThreshold"), slope * linearEnd, 1e-5f);
|
||||
Assert.Equal(Constant(SrgbSource, "SrgbDecodeThreshold"), slope * linearEnd, 1e-5f);
|
||||
Assert.Equal(slope * linearEnd, power, 1e-5f);
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする