English 中文(简体)
2D Pixel 从色谱中除去甲型
原标题:2D Pixel Shader removing alpha channel from color

So, I m trying to make a game in XNA, and I m applying a pixel shader to my level so I can add effects to the gameplay screen. The shader itself is working nicely, but it has one flaw that really pushes back performance. As long as the shader is active, anything I draw to the screen acts as though it was drawn with it s alpha channel at the maximum. I m drawing a lot of things using XNA s built in Color class, and much of it has varying alpha. However, the shader seems to ignore all of this. This occurs even if I just return the source from the shader.

我看到了一些可能的解决办法。 其中第一个是引向RenderTarget2D,虽然这确实解决了这一问题,但它造成了更严重的甲型问题,我甚至不想去做。

I have seen a few people claim that multiplying the colours by the alpha value in the shader seems to help, but that made absolutely no difference, which suggests to me that the alpha value input is always being read as 1.

Here are some images to illustrate my problem:

“The“

希望有人知道如何解决这一问题。

问题回答

In your Draw() method, you need to call: GraphicsDevice.BlendState = BlendState.NonPremultiplied; before calling any methods that invoke your shader (i.e. DrawUserIndexedPrimitives, etc.).

否则,框架假定甲型六氯环己烷的价值被高估,它只会使欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-欧洲-





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签