ฉันกำลังทำงานกับเกมใน XNA 4 และฉันเพิ่งเปลี่ยนไปใช้การแรเงาที่รอการตัดบัญชีตามคู่มือนี้ มีโครงร่างสีขาวแปลก ๆ ปรากฏขึ้นในแบบจำลองของฉันในตอนนี้และฉันไม่แน่ใจว่าเกิดจากอะไร ฉันคิดว่าบางทีการขาดความแม่นยำของเป้าหมายการเรนเดอร์ปกติหรือการเรนเดอร์เป้าหมายแบบลึก แต่การเพิ่มพวกมันเป็น 64 บิต (Rgba64) แทนที่จะเป็น 32 (สี) ไม่ได้ช่วยอะไรเลย ฉันก็คิดว่ามันอาจจะมีปัญหากับการคำนวณแบบ specular ดังนั้นฉันจึงลองตั้ง specular เป็น 0 แต่นั่นก็ไม่ได้ช่วยเช่นกัน การดีบักพิกเซลใน PIX แสดงว่าค่าการกระจายกำลังถูกคำนวณเป็นสีขาวเกือบสำหรับพิกเซลนั้น ความคิดใด ๆ ฉันรวมรูปภาพของปัญหาไว้ด้านล่างแล้วจะเห็นได้ง่ายขนาดเต็ม
Pixel Shader:
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    input.ScreenPosition.xy /= input.ScreenPosition.w;
    float2 texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1) - halfPixel;
    float4 normalData = tex2D(normalSampler, texCoord);
    //Transform normal back into [-1, 1] range
    float3 normal = normalize(2.0f * normalData.xyz - 1.0f);
    float specularPower = normalData.a;
    float specularHardness = tex2D(colorSampler, texCoord).a * 255;
    float depthVal = tex2D(depthSampler, texCoord).r;
    //Compute screen-space position
    float4 position = float4(input.ScreenPosition.xy, depthVal, 1.0f);
    //Transform to world space
    position = mul(position, InvertViewProjection);
    position /= position.w;
    //Surface-to-light vector
    float3 lightVector = lightPosition - position;
    float3 projectedTexCoords = position - lightPosition;
    projectedTexCoords = mul(projectedTexCoords, float3x3(
                            float3(-1, 0, 0),
                            float3(0, 1, 0),
                            float3(0, 0, 1)));
    float distanceToLight = length(lightVector) / lightRadius;
    float shadow = ShadowContribution(projectedTexCoords, distanceToLight);
    float attenuation = saturate(1.0f - distanceToLight);
    lightVector = normalize(lightVector);
    //Compute diffuse light
    float normalDotLight = max(0, dot(normal, lightVector));
    float3 diffuseLight = normalDotLight * Color.rgb;
    float3 reflectionVector = normalize(reflect(-lightVector, normal));
    float3 directionToCamera = normalize(cameraPosition - position);
    float specularLight = specularPower * pow(saturate(dot(reflectionVector, directionToCamera)), specularHardness);
    return shadow * attenuation * lightIntensity * float4(diffuseLight.rgb, specularLight);
}แก้ไข : ขออภัยเกี่ยวกับ JPG ผู้อัปโหลดของ stackexchange ทำเช่นนั้นด้วยตนเอง Roy T: จริงๆแล้วฉันอ้างอิงการแปลง XNA4 ของคุณสำหรับการสอนเกี่ยวกับชิ้นส่วนที่เปลี่ยนจาก XNA3 เนื่องจากฉันไม่ได้ทำการเปลี่ยนแปลงครั้งใหญ่กับรหัสฉันคิดว่าอาจมีข้อผิดพลาดนี้อยู่ในต้นฉบับ แต่เป็นไปไม่ได้ที่จะเห็นด้วยแสงจำนวนมากเคลื่อนที่ไปมาดังนั้นฉันจึงลบออกทั้งหมดยกเว้นหนึ่งไฟและข้อผิดพลาดปรากฏขึ้นอีกครั้ง ใกล้ข้อศอกของจิ้งจก)

นี่คือเนื้อหาของ GBuffer สำหรับฉากของฉัน:
Color Buffer:
  Depth Buffer:
Depth Buffer:
  Normal Buffer:
Normal Buffer:
  Final Render:
Final Render:

แก้ไข 2 :
ฉันเริ่มสงสัยว่าปัญหาคือ CombineFinal.fx เมื่อมันตัวอย่างแผนที่สี นี่คือการคำนวณสำหรับพิกเซลสีที่เหมาะสมติดกับพิกเซลสีขาว:
diffuseColor        : (0.435, 0.447, 0.412)
diffuseLight        : (1.000, 1.000, 0.902)
light               : (1.000, 1.000, 0.902, 0.000)
PixelShaderFunction : (0.435, 0.447, 0.371, 1.000)
specularLight       : 0.000และนี่คือผลลัพธ์จากพิกเซลสีขาวที่มีสีไม่ถูกต้องติดกับ:
diffuseColor        : (0.824, 0.792, 0.741)
diffuseLight        : (1.000, 1.000, 0.902)
light               : (1.000, 1.000, 0.902, 0.000)
PixelShaderFunction : (0.824, 0.792, 0.669, 1.000)
specularLight       : 0.000diffuseColor เป็นความแตกต่างเพียงอย่างเดียวและสีนี้จะนำมาจากแผนที่สีโดยตรง อาจมีข้อผิดพลาดเล็กน้อยในการคำนวณพิกัดของพื้นผิวที่ต้องการตัวอย่างจาก?
แสงสว่างผ่าน:
