光の量へ変換する前処理のシェーダーを追加する
このコミットが含まれているのは:
5ファイル変更
+66
検索条件に一致するファイルはありません
@@ -156,6 +156,15 @@
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="SpectrumColorShiftLinearize.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Srgb.hlsli" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -21,5 +21,13 @@
|
||||
<FxCompile Include="SpectrumColorShiftPhysical.hlsl">
|
||||
<Filter>ソース ファイル</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="SpectrumColorShiftLinearize.hlsl">
|
||||
<Filter>ソース ファイル</Filter>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Srgb.hlsli">
|
||||
<Filter>ヘッダー ファイル</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -63,6 +63,7 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="$(ShaderDirPath)SpectrumColorShift.cso" Link="Resources\Shader\SpectrumColorShift.cso" />
|
||||
<Resource Include="$(ShaderDirPath)SpectrumColorShiftPhysical.cso" Link="Resources\Shader\SpectrumColorShiftPhysical.cso" />
|
||||
<Resource Include="$(ShaderDirPath)SpectrumColorShiftLinearize.cso" Link="Resources\Shader\SpectrumColorShiftLinearize.cso" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする