diff --git a/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj b/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj
index 2c6ea7e..2253d57 100644
--- a/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj
+++ b/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj
@@ -156,6 +156,15 @@
Pixel
Pixel
+
+ Pixel
+ Pixel
+ Pixel
+ Pixel
+
+
+
+
diff --git a/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj.filters b/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj.filters
index 0055461..f943c89 100644
--- a/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj.filters
+++ b/SpectrumColorShift.Shader/SpectrumColorShift.Shader.vcxproj.filters
@@ -21,5 +21,13 @@
ソース ファイル
+
+ ソース ファイル
+
+
+
+
+ ヘッダー ファイル
+
diff --git a/SpectrumColorShift.Shader/SpectrumColorShiftLinearize.hlsl b/SpectrumColorShift.Shader/SpectrumColorShiftLinearize.hlsl
new file mode 100644
index 0000000..cffd895
--- /dev/null
+++ b/SpectrumColorShift.Shader/SpectrumColorShiftLinearize.hlsl
@@ -0,0 +1,13 @@
+#include "Srgb.hlsli"
+
+Texture2D SourceTexture : register(t0);
+SamplerState SourceSampler : register(s0);
+
+float4 main(
+ float4 position : SV_POSITION,
+ float4 scenePosition : SCENE_POSITION,
+ float4 uv0 : TEXCOORD0
+) : SV_TARGET
+{
+ return DecodePremultiplied(SourceTexture.SampleLevel(SourceSampler, uv0.xy, 0));
+}
diff --git a/SpectrumColorShift.Shader/Srgb.hlsli b/SpectrumColorShift.Shader/Srgb.hlsli
new file mode 100644
index 0000000..f01a79c
--- /dev/null
+++ b/SpectrumColorShift.Shader/Srgb.hlsli
@@ -0,0 +1,35 @@
+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;
+
+float3 Decode(float3 encoded)
+{
+ float3 low = encoded / LowSlope;
+ float3 high = pow((encoded + Offset) / Scale, Exponent);
+ return encoded <= DecodeThreshold ? low : high;
+}
+
+float3 Encode(float3 linearColor)
+{
+ float3 low = linearColor * LowSlope;
+ float3 high = Scale * pow(linearColor, 1.0 / Exponent) - Offset;
+ return linearColor <= EncodeThreshold ? low : high;
+}
+
+float3 Unpremultiply(float4 premultiplied)
+{
+ return premultiplied.a > 0.0 ? saturate(premultiplied.rgb / premultiplied.a) : 0.0;
+}
+
+float4 DecodePremultiplied(float4 encoded)
+{
+ return float4(Decode(Unpremultiply(encoded)) * encoded.a, encoded.a);
+}
+
+float4 EncodePremultiplied(float4 linearColor)
+{
+ return float4(Encode(Unpremultiply(linearColor)) * linearColor.a, linearColor.a);
+}
diff --git a/SpectrumColorShift/SpectrumColorShift.csproj b/SpectrumColorShift/SpectrumColorShift.csproj
index bc2333a..ad2da52 100644
--- a/SpectrumColorShift/SpectrumColorShift.csproj
+++ b/SpectrumColorShift/SpectrumColorShift.csproj
@@ -63,6 +63,7 @@
+