HSLT 自定义 Direct2D 效果中分辨率高时的纹理拆分

Texture split when resolution is high in HSLT custom Direct2D effect

这很奇怪。我正在尝试将转换实现为 Direct2d 效果。

关于实现来自 gl-transitions 的简单像素着色器:

fxc /Zi /T ps_4_0 warp.hlsl /D D2D_FULL_SHADER /D D2D_ENTRY=main /E main /Fo warp.cso /Fh "warp.h" /nologo /I "c:\wk\Include.0.19041.0\um"

#define D2D_INPUT_COUNT 2
#define D2D_INPUT0_COMPLEX
#define D2D_INPUT1_COMPLEX
#define D2D_REQUIRES_SCENE_POSITION // The pixel shader requires the SCENE_POSITION input.
#include "d2d1effecthelpers.hlsli"
cbuffer constants : register(b0)
{
 ....
};

float4 transition(float2 uv)
{
    float2 direction = float2(p1, p2);
    const float smoothness = p3;
    const float2 center = float2(p4, p5);
    
    float2 v = normalize(direction);
    v /= abs(v.x) + abs(v.y);
    float d = v.x * center.x + v.y * center.y;
    float m = 1.0f - smoothstep(-smoothness, 0.0, v.x * uv.x + v.y * uv.y - (d - 0.5f + progress * (1.0f + smoothness)));
    return lerp(D2DSampleInput(0, (uv - 0.5f) * (1.0f - m) + 0.5f), D2DSampleInput(1,(uv - 0.5f) * m + 0.5f), m);
}
D2D_PS_ENTRY(main)
{  
float4 s = D2DGetInputCoordinate(0);
float4 v = transition(s.xy);
return v;
}

当我的预览器中的输入纹理较小时,它可以正确渲染。这是 974x548 预览:

渲染图大了,就拆分,看渲染图有多大: 这是 1696x954 的预览:

这是更大的预览图 (2730x1536):

可能是什么原因,我该如何解决?有没有可能不是整个贴图都传给了shader?

我又看了看“Custom D2D Effects”,我可以通过实现 MapInputRectsToOutputRect() 来扩展矩形。但是,我是否只需要传递一个空的 {0,0,0,0} 不透明矩形,这样效果就会占用整个输出。

在我看来,Direct2D 通过分步传递来并行化效果,但我不希望这样,因为没有 1:1 效果。

非常感谢。

我又找到答案了

它是 rendering controls,默认情况下以 1024x1024 的图块开头。在绘制到上下文的实际 width/height 之前改变它工作正常。