我一直要求分割我問的問題在這裏:Pix的,一對夫婦的我不理解的問題
HLSL and Pix number of questions
我認爲兩個和三個都將在適合作爲同樣的問題一個解決方案可能有助於解決另一個。我試圖調試着色器,似乎遇到了問題。首先,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實時調試嗎?我想知道這個方法是否會揭示更多的信息。
乾杯,
好吧,我認爲循環線是我擺弄東西,所以這是我忘記切換值回來。我基本上試圖達到在這裏找到的運動模糊效果:http://http.developer.nvidia.com/GPUGems3/gpugems3_ch27.html我試圖儘可能複製這種方法,但我擔心,如果編譯器正在優化它,這種方法是不可能的。 – Bushes 2013-02-14 10:52:56
固定循環後,不應刪除上面的行;它在循環中使用該數據。修復循環後,你仍然遇到問題嗎? – Goose 2013-02-15 17:15:49
啊,好吧,你是對的,我現在似乎正在得到某種效果,所以大概可以從那裏解決。乾杯 – Bushes 2013-02-18 11:56:01