开发者

Depth of Field issue

I have converted a Depth Of Field shader from XNA 3.1 to 4.0. The problem is, it is completely drai开发者_如何转开发ning my colours and not rendering anything else. You can see the problem here:

Project Vanquish - Depth of Field issue

Any ideas would be very grateful.

EDIT

I thought it best to add the Render method too:

public void PostProcess(GraphicsDevice device)
{
   // Gaussian Blur Horizontal
   device.SetRenderTarget(this.GaussianHRT);
   device.Clear(Color.White);
   device.SetRenderTarget(null);
   this.SetBlurEffectParameters(1.0f / this.device.Viewport.Width, 0);
   this.DrawQuad(this.resolveTarget, this.gaussianBlur.Effect);

   // Gaussian Blur Vertical
   device.SetRenderTarget(this.GaussianVRT);
   device.Clear(Color.White);
   device.SetRenderTarget(null);
   this.SetBlurEffectParameters(0, 1.0f / this.device.Viewport.Height);
   this.DrawQuad(this.GaussianHRT, this.gaussianBlur.Effect);

   // Render result
   device.Textures[0] = this.resolveTarget;
   device.Textures[1] = this.GaussianVRT;
   device.Textures[2] = this.depthRT;
   this.DrawQuad(this.resolveTarget, this.combine.Effect);

   // Reset RenderStates
   this.ResetRenderStates();
}

By outputting this to seperate RenderTargets, I can see some potential issues, but I can't understand why I get a blank RenderTarget even though I set the resolveTarget RenderTarget before I render all of the scene. This is then rendered after the scene has been rendered.


are you saying that you ported it line for line to xna 4 and it now exhibits this behavior, or did you make code changes? I mean, it looks to me like the pixel shader is just returning invalid color values.

can you give us some details about what changed in your shader from 3.1 -> 4 ?

Edit: To go down a different line of thought ... another reason that you'd see black rendering such as this is around lighting. I would double check and verify that all of your light parameters are being passed into the shader, and that they are calculating accordingly.


You call DrawQuad function before setting the textures; this should result in invalid textures bound to Combine shader inputs.

There is a number of other things that can go wrong here, but this is the most likely suspect.


The problem existed in a function before this where I set the DepthBuffer. Thanks for the assistance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜