FXAA Help
#2 Members - Reputation: 303
Posted 30 August 2011 - 02:41 PM
Download the shader from the website http://timothylottes.blogspot.com/
The FXAA shader only needs your color buffer as input, but this means you need an extra render target.
So, create an extra render target the same size as your backbuffer.
the FXAA pass should be after all of your game drawing and effects are done.
Copy the color buffer to a temp buffer.
Then, use the copied buffer as input to create the final image.
I am not sure which part you are having a difficult time with.
As for the shader itself, it contains many different implementations for Playstatio, XBox and PC versions. Read the comments, you can safely remove the unneeded code, which will improve your compile times.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
#3 Members - Reputation: 118
Posted 31 August 2011 - 07:38 AM
smasherprog, on 30 August 2011 - 02:41 PM, said:
I am not sure which part you are having a difficult time with.
The download is a "h" file (header) with tons of macro's (defines). I only need it for the PC. My existing shaders are all FX files and for this specific application (not a game) that requires the AA, it is not written in C++.
Prior to the new requirements, hardware multisampling was sufficient but now they want to take screenshots. I was unable to provide multisampling when rendering to a surface for screen shots- hence, I need an AA alternative.
Will FXAA work with PS v2.0?
Does FXAA access require C++ implementation?
How does FXAA hold up on non- nvidia hardware?
These are the things I'm having a difficult time with...
#7 Members - Reputation: 158
Posted 02 September 2011 - 07:26 AM
DJTN, on 01 September 2011 - 10:12 AM, said:
DJTN, on 01 September 2011 - 10:12 AM, said:
IS FXAA SM 2.0 Compatible?
#8 Members - Reputation: 118
Posted 02 September 2011 - 10:03 AM
B_old, on 02 September 2011 - 07:26 AM, said:
Yes, at the top of my shader I put the following:
#define FXAA_PC 1
#include "Fxaa3_11.h"
and it fails to compile. If I only add the include or only the define, then it compiles but with both of them it fails.
#10 Members - Reputation: 138
Posted 02 September 2011 - 10:48 AM
DJTN, on 31 August 2011 - 07:38 AM, said:
smasherprog, on 30 August 2011 - 02:41 PM, said:
The download is a "h" file (header) with tons of macro's (defines). I only need it for the PC. My existing shaders are all FX files and for this specific application (not a game) that requires the AA, it is not written in C++.
Prior to the new requirements, hardware multisampling was sufficient but now they want to take screenshots. I was unable to provide multisampling when rendering to a surface for screen shots- hence, I need an AA alternative.
Will FXAA work with PS v2.0?
Does FXAA access require C++ implementation?
How does FXAA hold up on non- nvidia hardware?
These are the things I'm having a difficult time with...
FXAA works great, even on non NV hw. We used it in our commercial project, and this was a concern for us as well. Turns out it was not a problem.
FXAA requires no c++ side implementation, other than a full screen pass. (draw fullscreen quad, set shader, pass in main RT, output to backbuffer or RT of choice).
I don't remember any problems with FXAA on sm2, other than we had to disable the higher quality versions as it resulted in more instructions than supported by sm2. (Memory is a bit hazy though, so don't take my word for it).
#11 Members - Reputation: 118
Posted 02 September 2011 - 10:53 AM
B_old, on 02 September 2011 - 10:33 AM, said:
PIX is being buggy as hell and I cannot get it working -however, I did notice that if I switch the order it compiles, I.E.
#include "Fxaa3_11.h"
#define FXAA_PC 1
Once I get pass that problem, how do I call it's method? Looking through to the define I'm working with (FXAA_PC 1) the method ask for all these inputs:
FxaaFloat2 fxaaQualityRcpFrame,
FxaaFloat4 fxaaConsoleRcpFrameOpt,
FxaaFloat4 fxaaConsoleRcpFrameOpt2,
FxaaFloat4 fxaaConsole360RcpFrameOpt2,
FxaaFloat fxaaQualitySubpix,
FxaaFloat fxaaQualityEdgeThreshold,
FxaaFloat fxaaQualityEdgeThresholdMin,
FxaaFloat fxaaConsoleEdgeSharpness,
FxaaFloat fxaaConsoleEdgeThreshold,
FxaaFloat fxaaConsoleEdgeThresholdMin,
FxaaFloat4 fxaaConsole360ConstDir
The documentation says:
Then call the FXAA pixel shader from within your desired shader.
Look at the FXAA Quality FxaaPixelShader() for docs on inputs.
As for FXAA 3.11 all inputs for all shaders are the same
to enable easy porting between platforms.
return FxaaPixelShader(...);
I searched the entire doc for "FXAA Quality FxaaPixelShader()" and never found anything that resembles definitions for these constants / inputs.
SMASHERPROG posted the following earlier in this post saying "The FXAA shader only needs your color buffer as input". Am I missing something here?
#12 Members - Reputation: 118
Posted 02 September 2011 - 11:07 AM
#define FXAA_PC 1
#include "Fxaa3_11.h"
//texture
texture ScreenTexture;
sampler2D TextureSampler = sampler_state
{
Texture = <ScreenTexture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0
{
float4 color = tex2D(TextureSampler, TextureCoordinate);
return color;
}
technique TransformTexture
{
pass P0
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
I'd like to simplify the Fxaa3_11.h file but not sure what I can and cannot remove since all the methods have inputs to handle every major platform.
#13 Members - Reputation: 158
Posted 02 September 2011 - 11:18 AM
The function you want to call inside your full screen pass is FxaaPixelShader. Try defining #define FXAA_QUALITY__PRESET 10 and see if it helps, as ATEFred said something about running out of instructions.
#14 Members - Reputation: 118
Posted 02 September 2011 - 11:29 AM
B_old, on 02 September 2011 - 11:18 AM, said:
The function you want to call inside your full screen pass is FxaaPixelShader. Try defining #define FXAA_QUALITY__PRESET 10 and see if it helps, as ATEFred said something about running out of instructions.
If I replace #define FXAA_PC 1 with #define FXAA_QUALITY__PRESET 10 it compiles. Should I have added the define or replaced it?
#16 Members - Reputation: 118
Posted 02 September 2011 - 12:08 PM
#define FXAA_PC 1
#define FXAA_QUALITY__PRESET 10
#define FXAA_HLSL_3 1
#include "Fxaa3_11.h"
//texture
texture ScreenTexture;
sampler2D TextureSampler = sampler_state
{
Texture = <ScreenTexture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0
{
float4 color = tex2D(TextureSampler, TextureCoordinate);
float value = (color.r + color.g + color.b) / 3;
color.r = value;
color.g = value;
color.b = value;
return color;
}
technique TransformTexture
{
pass P0
{
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}
It compiles but now I'm only getting one color returned and I havn't called any FXAA methods. I need to look at the specs on SM 3 vers SM 2 to see what's going on with that.
I wonder if an older version of FXAA supports SM 2.0? At this time the 3_11 version of FXAA does not. I'm not sure if I can get the requirments lifted to SM 3.0 and how will that impact other areas of this project.
At least I've made "some" progress : - /
Any input would be greatly appreciated....
#18 Members - Reputation: 118
Posted 02 September 2011 - 12:22 PM
B_old, on 02 September 2011 - 12:13 PM, said:
What do you mean by only getting one color returned? Your shader looks like it outputs different shades of gray.
Actully it's returning a black and white image. I passed in a simple cloud texture and it when it's Sm 2.0 it returns the texture black and white like it should. When I switch to Sm 3 it returns one color for the entire image.
SM 2.0:

SM 3.0:
#20 Members - Reputation: 118
Posted 02 September 2011 - 02:18 PM
B_old, on 02 September 2011 - 02:04 PM, said:
Yes, I think the issue is that you cannot ignore a vertex shader on a PS 3.0 target. To make sure FXAA wold work with my current rig, I simply rendered everything to a rendertarget/surface and then took that texture and used the Sprite class to draw a full screen sprite with that texture. It works fine for PS 2.0 but not 3.0.
Uggg it's one probelm after another.


















