方式ごとに分けたシェーダーで64ステップの描画と初回描画を速くする

・直線、放射、回転の方式ごとにコンパイルしたシェーダーを選んで使うよう変更-M
このコミットが含まれているのは:
routersys committed 2026-10-13 11:12:46 +09:00
1 親 d5a114d14c
コミット 307acd1f22
6ファイル変更
+105 -42

検索条件に一致するファイルはありません

+24 -4
ファイルの表示
@@ -163,13 +163,33 @@
<ItemGroup>
<FxCompile Include="SpectrumColorShift.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity)</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShift%(StepCount.Identity).cso</ObjectFileOutput>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=1</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftLinear%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="SpectrumColorShift.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=2</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftRadial%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="SpectrumColorShift.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=4</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftRotational%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="SpectrumColorShiftPhysical.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity)</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftPhysical%(StepCount.Identity).cso</ObjectFileOutput>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=1</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftPhysicalLinear%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="SpectrumColorShiftPhysical.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=2</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftPhysicalRadial%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="SpectrumColorShiftPhysical.hlsl">
<ShaderType>Pixel</ShaderType>
<PreprocessorDefinitions>StepCount=%(StepCount.Identity);ShaderMode=4</PreprocessorDefinitions>
<ObjectFileOutput>$(OutDir)SpectrumColorShiftPhysicalRotational%(StepCount.Identity).cso</ObjectFileOutput>
</FxCompile>
</ItemGroup>
</Target>
+11 -6
ファイルの表示
@@ -2,12 +2,17 @@
#error StepCount must be defined by the build.
#endif
#ifndef ShaderMode
#error ShaderMode must be defined by the build.
#endif
Texture2D SourceTexture : register(t0);
SamplerState SourceSampler : register(s0);
static const int MaxSteps = 64;
static const int ModeRadial = 2;
static const int ModeRotational = 4;
static const int CompiledMode = ShaderMode;
static const float MaxRadialShift = 0.5;
static const float InteriorGuard = 0.51;
@@ -29,13 +34,13 @@ float2 SamplePosition(float2 scenePosition, float2 offset, float coefficient)
{
float shift = coefficient * shiftDistance;
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
{
float scale = 1.0 - clamp(shift / radius, -MaxRadialShift, MaxRadialShift);
return center + offset * scale;
}
if (mode == ModeRotational)
if (CompiledMode == ModeRotational)
{
float sine;
float cosine;
@@ -48,10 +53,10 @@ float2 SamplePosition(float2 scenePosition, float2 offset, float coefficient)
float2 Spread(float2 offset)
{
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
return abs(offset) * spreadScale;
if (mode == ModeRotational)
if (CompiledMode == ModeRotational)
return length(offset) * spreadScale;
return abs(shiftDistance) * abs(direction);
@@ -124,7 +129,7 @@ float4 GatherInside(float2 uv, float2 pixelStep, float2 scenePosition)
float3 color = 0.0;
float3 coverage = 0.0;
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
{
float2 offsetStep = offset * pixelStep;
float rate = shiftDistance / radius;
@@ -133,7 +138,7 @@ float4 GatherInside(float2 uv, float2 pixelStep, float2 scenePosition)
for (int index = 0; index < StepCount; index++)
AccumulateRadial(index, uv, offsetStep, rate, color, coverage);
}
else if (mode == ModeRotational)
else if (CompiledMode == ModeRotational)
{
float rate = shiftDistance / radius;
+11 -6
ファイルの表示
@@ -2,6 +2,10 @@
#error StepCount must be defined by the build.
#endif
#ifndef ShaderMode
#error ShaderMode must be defined by the build.
#endif
#include "Srgb.hlsli"
Texture2D LinearTexture : register(t1);
@@ -11,6 +15,7 @@ static const int MaxSteps = 64;
static const int TableSize = 128;
static const int ModeRadial = 2;
static const int ModeRotational = 4;
static const int CompiledMode = ShaderMode;
static const float MaxRadialShift = 0.5;
static const float InteriorGuard = 0.51;
@@ -32,13 +37,13 @@ float2 SamplePosition(float2 scenePosition, float2 offset, float coefficient)
{
float shift = coefficient * shiftDistance;
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
{
float scale = 1.0 - clamp(shift / radius, -MaxRadialShift, MaxRadialShift);
return center + offset * scale;
}
if (mode == ModeRotational)
if (CompiledMode == ModeRotational)
{
float sine;
float cosine;
@@ -51,10 +56,10 @@ float2 SamplePosition(float2 scenePosition, float2 offset, float coefficient)
float2 Spread(float2 offset)
{
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
return abs(offset) * spreadScale;
if (mode == ModeRotational)
if (CompiledMode == ModeRotational)
return length(offset) * spreadScale;
return abs(shiftDistance) * abs(direction);
@@ -135,7 +140,7 @@ float4 GatherInside(float2 uv, float2 pixelStep, float2 scenePosition)
float3 color = 0.0;
float alpha = 0.0;
if (mode == ModeRadial)
if (CompiledMode == ModeRadial)
{
float2 offsetStep = offset * pixelStep;
float rate = shiftDistance / radius;
@@ -144,7 +149,7 @@ float4 GatherInside(float2 uv, float2 pixelStep, float2 scenePosition)
for (int index = 0; index < StepCount; index++)
AccumulateRadial(index, uv, offsetStep, rate, color, alpha);
}
else if (mode == ModeRotational)
else if (CompiledMode == ModeRotational)
{
float rate = shiftDistance / radius;