我被要求拆分我在这里提出的问题:
我认为两个和三个都适合同一个问题,因为一个解决方案可能有助于解决另一个问题。我正在尝试调试着色器,但似乎遇到了问题。首先,当我运行分析模式时,Pix 似乎跳过了大量代码。这是分析 F12 捕获和关闭 D3DX 分析的实验。我在使用 XNA 时必须将其关闭。有问题的着色器代码如下:
float4 PixelShaderFunction(float2 OriginalUV : TEXCOORD0) : COLOR0
{
// Get the depth buffer value at this pixel.
float4 color = float4 (0, 0,0,0);
float4 finalColor = float4(0,0,0,0);
float zOverW = tex2D(mySampler, OriginalUV);
// H is the viewport position at this pixel in the range -1 to 1.
float4 H = float4(OriginalUV.x * 2 - 1, (1 - OriginalUV.y) * 2 - 1,
zOverW, 1);
// Transform by the view-projection inverse.
float4 D = mul(H, xViewProjectionInverseMatrix);
// Divide by w to get the world position.
float4 worldPos = D / D.w;
// Current viewport position
float4 currentPos = H;
// Use the world position, and transform by the previous view-
// projection matrix.
float4 previousPos = mul(worldPos, xPreviousViewProjectionMatrix);
// Convert to nonhomogeneous points [-1,1] by dividing by w.
previousPos /= previousPos.w;
// Use this frame's position and last frame's to compute the pixel
// velocity.
float2 velocity = (currentPos - previousPos)/2.f;
// Get the initial color at this pixel.
color = tex2D(sceneSampler, OriginalUV);
OriginalUV += velocity;
for(int i = 1; i < 1; ++i, OriginalUV += velocity)
{
// Sample the color buffer along the velocity vector.
float4 currentColor = tex2D(sceneSampler, OriginalUV);
// Add the current color to our color sum.
color += currentColor;
}
// Average all of the samples to get the final blur color.
finalColor = color / xNumSamples;
return finalColor;
}
使用捕获的帧并在调试像素时,我只能看到两行工作。它们是 color = tex2D(sceneSampler, OriginalUV) 和 finalColor = color / xNumSamples。Pix 的其余部分只是跳过或不做。
我也可以使用 Pix 进行实时调试吗?我想知道这种方法是否会揭示更多信息。
干杯,