在 XNA 4.0 winforms 中使用 Nvidia FXAA(着色器抗锯齿)的示例?
我在我正在编写的应用程序中使用此示例项目的 XNA 4.0 表单控件: http: //creators.xna.com/en-US/sample/winforms_series1
如果您不熟悉 FXAA,请查看创建者的网站: http://timothylottes.blogspot.com/2011/03/nvidia-fxaa.html到目前为止
,我花了相当多的时间试图弄清楚如何使用它,但没有任何运气(到目前为止......)。确实,我在图形编程方面没有太多经验,但我目前正在运行一个不错的应用程序,它的锯齿线看起来真的很差。我知道 AA 的内置方法,但对我和我的笔记本电脑不起作用。所以我的请求是关于使用 FXAA 而不是内置方法。
在此刻: 我的内容项目中有 FXAA 3.11 头文件。 我有一个由 Visual Studio 生成的通用 FX 文件,其中包含以下内容:
#define FXAA_PC_CONSOLE 1
#define FXAA_HLSL_5 1
#define FXAA_QUALITY__PRESET 12
#include "Includes/Fxaa3_11.h"
我只是在这里询问是否有人可以提供一些 XNA 4.0 示例,特别是使用自定义 Windows 窗体方法。
我很感激有人能够提供的任何帮助。
编辑3: 自从我发布此消息以来,我一直在努力研究如何让 FXAA 正常工作。 我发现了这个: http://www.gamedev.net/topic/609638-fxaa-help/page__st__20 还有这个: http://fxaa-pp-inject.assembla.me/trunk/DirectX9 /shader.fx
我将 FXAA 精简为基本的 FXAA_PC_CONSOLE 类型并进行编译。我只需要找出参数fxaaConsolePosPos,即每个像素的左上角和右下角位置。无论如何,看起来 FXAA_PC_CONSOLE 可能与着色器模型 2.0 一起使用,我需要将其与 REACH 和基于 winforms 的 XNA 一起使用。
I'm using this example project's XNA 4.0 form control in an application I'm writing: http://creators.xna.com/en-US/sample/winforms_series1
If you are unfamiliar with FXAA, check out the creator's site:
http://timothylottes.blogspot.com/2011/03/nvidia-fxaa.html
I've spent quite a bit of time so far trying to figure out to use it without any luck (so far...). It's true I don't have much experience at all with graphics programming, but I do currently have a nice application running, it just looks really really poor with the jagged lines. I know about the built-in method for AA, but doesn't work for me and my laptop computer. So my request is about using FXAA and not the built-in methods.
At this point:
I have FXAA 3.11 header file in my Content project.
I have a generic FX file generated by visual studio with a few things like:
#define FXAA_PC_CONSOLE 1
#define FXAA_HLSL_5 1
#define FXAA_QUALITY__PRESET 12
#include "Includes/Fxaa3_11.h"
I'm just asking here to see if anyone could provide some XNA 4.0 examples, specifically with using that custom windows forms method.
I appreciate any help someone might be able to provide.
Edit 3:
I've been trying to work out how to get FXAA working since I posted this message.
I found this:
http://www.gamedev.net/topic/609638-fxaa-help/page__st__20
and this:
http://fxaa-pp-inject.assembla.me/trunk/DirectX9/shader.fx
I striped down FXAA to bare bones FXAA_PC_CONSOLE type and it compiles. I just need to figure out the parameter fxaaConsolePosPos that is the top left and bottom right position of each pixel. Anyways, it looks like FXAA_PC_CONSOLE might work with shader model 2.0 that I need to use with REACH and winforms based XNA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以我想通了,至少使用专为游戏机和低端 PC 设计的 FXAA 的较小版本。我不能保证着色器代码的参数是正确的,但在运行时我确实看到了明显的差异。
以下是完整的解决方案,包含我切碎的着色器和 C# XNA 4.0 代码片段:
首先是着色器代码(将其放入内容子项目的 .fx 文件中):
请注意,根据 SM2.0 不支持第一种类型的建议,我将 tex2Dlod 替换为 tex2D
下面是应用着色器的 C-sharp 代码片段:
So I figured it out, at least using the lesser version of FXAA designed for consoles and low-end PCs. I can't guarantee my parameters to the shader code are correct, but I do see a noticeable difference when it is running.
Here is the complete solution with my chopped up shader and pieces of the C# XNA 4.0 code:
The shader code first (put that in a .fx file in your Content sub-project):
note that I replaced tex2Dlod with tex2D as per a suggestion that SM2.0 doesn't support the first type
Here is a snippet of C-sharp code to apply the shader:
我最近在我的游戏中实现了这种技术,但由于某种原因,我的边缘仍然“锯齿状”。有没有办法在某处调整代码以稍微软化锯齿状边缘?谢谢。
I implemented this technique into my game recently but for some reason my edges remain "jaggy" still. Is there a way to tweak the code somewhere to soften the jagged edges somewhat? Thank you.