Jump to content

ported nvidia's fxaa 3.11 shader to unigine


photo

Recommended Posts

Posted

I've successfully ported nvidia's fxaa shader to unigine. Because I have no knowledge of glsl, so, there is no opengl support, but I think some guys here have better knowledge of glsl, hope you can help me finish the shader.

 

I just used a bad way to port this shader so the directx part are almost same except texture sampling, and I hope unigine can integrate it as a standard shader.

 

add this material dedeclaration into data\core\materials\default\unigine_post.mat

 

and save attachment shader to data\core\shaders\default\post and use it!

 

use the shader files below.

Posted

forgot to say, it's based on the first release of FXAA, I'm trying to port lastest fxaa 3.11 to unigine.

Posted

Maybe there is a simpler way via tfarrar@nvidia.com, see Timothy Lottes blog on FXAA

 

Game developers who want to check out a mixed DX9/DX11/OpenGL sample pack (includes source and white paper) can email me directly via tfarrar at NVIDIA.

Posted

BTW I am quite sure that frustum will supply full Unigine FXAA version as he already implemented other post-processing-AA shaders quickly

Posted

done, Ported FXAA ver 3.11, but still no opengl support, I don't know about glsl, sorry, material definition:

 

tested a previous version on a scene, it maks fps drop about 20%, new shader on that scene only drops about %5 fps.

 

I've heard that fxaa algorithm 3.12 will be released soon, hope this shader will get into standard unigine post shader.

Posted

BTW, I can not figure out how to use #if preprocessor in this shader, tested with this pixel shader

 

##if TEST_VAL==3
  return half4(0, 0, 0, 0);
##else
  return half4(0.5, 0.5, 0.5, 0.5)
##endif

 

no matter how I define the TEST_VAL, the above code only return 0.5, it seems Parser.cpp has stripped the ##if preprocessor. or TEST_VAL=3 define

Posted

final version, opengl and directx 9/10/11 all supported. don't have a ps3. waiting unigine guys to integrated into unigine.

 

use this material def:

<!--
/* Nvidia AntiAliasing filter material version 3
*/
-->
<material name="post_filter_fxaa">
 <!-- states -->
 <state name="preset" type="switch" items="preset_10,preset_11,preset_12,preset_13,preset_14,preset_15,preset_20,preset_21,preset_22,preset_23,preset_24,preset_25,preset_26,preset_27,preset_28,preset_29,preset_39">3</state>
 <!-- shaders -->
 <shader pass="post"
preset_defines="FXAA_QUALITY__PRESET_10,FXAA_QUALITY__PRESET_11,FXAA_QUALITY__PRESET_12,FXAA_QUALITY__PRESET_13,FXAA_QUALITY__PRESET_14,FXAA_QUALITY__PRESET_15,FXAA_QUALITY__PRESET_20,FXAA_QUALITY__PRESET_21,FXAA_QUALITY__PRESET_22,FXAA_QUALITY__PRESET_23,FXAA_QUALITY__PRESET_24,FXAA_QUALITY__PRESET_25,FXAA_QUALITY__PRESET_26,FXAA_QUALITY__PRESET_27,FXAA_QUALITY__PRESET_28,FXAA_QUALITY__PRESET_29,FXAA_QUALITY__PRESET_39"
vertex="core/shaders/default/post/vertex_filter_antialiasing.shader"
fragment="core/shaders/default/post/fragment_filter_fxaa3.shader"/>
 <!-- textures -->
 <texture name="color" pass="post" type="procedural"/>
 <!-- parameters -->
 <parameter name="fxaaQualitySubpix" type="slider" shared="1" min="0.0" max="1.0" flags="max_expand">0.75</parameter>
 <parameter name="fxaaQualityEdgeThreshold" type="slider" shared="1" min="0.063" max="0.333" flags="max_expand">0.166</parameter>
 <parameter name="fxaaQualityEdgeThresholdMin" type="slider" shared="1" min="0.0" max="0.0833" flags="max_expand">0.0625</parameter>
</material>

fragment_filter_fxaa3.shader

Posted

Thanks, we will try to integrate fxaa in the next SDK update.

Posted

There is special render materials list (render.setRenderMaterials()) which is applied before post-processing.

  • 3 weeks later...
  • 2 weeks later...
Posted

This is a FXAA 2 (http://timothylottes...or-console.html) implementation.

 

I tested your shader and it seems to be much more blurry than steve3d implementation with exactly same performance impact. Of course it is much better than previous buggy 'post_filter_antialiasing' but I'd suggest using FXAA 3 instead.

Posted

When I get home I'll try to modify shader to use #if preprocessor to improve performance.

Posted

I have made a new sample with fxaa 3.11 integration. This sample will available in the updated SDK on days.

Posted

wow, that's quick, so this means I can wait then.

Posted

done! using some defines actually boost a little performance. just use this shader.

 

frustum, I have a question, now shader code support #if preprocessor, how should I use the value define in material definition, use this seems not work:

preset_defines="FXAA_QUALITY__PRESET=10,FXAA_QUALITY__PRESET=11,FXAA_QUALITY__PRESET=12,FXAA_QUALITY__PRESET=13,FXAA_QUALITY__PRESET=14,FXAA_QUALITY__PRESET=15,FXAA_QUALITY__PRESET=20,FXAA_QUALITY__PRESET=21,FXAA_QUALITY__PRESET=22,FXAA_QUALITY__PRESET=23,FXAA_QUALITY__PRESET=24,FXAA_QUALITY__PRESET=25,FXAA_QUALITY__PRESET=26,FXAA_QUALITY__PRESET=27,FXAA_QUALITY__PRESET=28,FXAA_QUALITY__PRESET=29,FXAA_QUALITY__PRESET=39"

 

shader complains no define of FXAA_QUALITY__PRESET

fragment_filter_fxaa3.shader

Posted

It isn't possible to declare value of define in the material configuration file.

Attached files will be presented in the SDK samples directory.

post_filter_fxaa requires core post_filter_rgb2rgbl material.

The list of render materials should be: "post_filter_rgb2rgbl,post_filter_fxaa".

post_filter_fxaa.zip

Posted

looks perfect, thats original fxaa shader, will be easier for later versions, thanks :)

Posted

your zip packages lacks of post_filter_rgb2rgbl material.. :)

Posted

frustum

after all needed modifications I put you shader to /core/ directory and it works now. Speed is exactly the same as in steve3d latest shader. Overall image is somewhat more sharper.

It would be great to see this shader built-in to next SDK. Also I tested your FXAA 2.0 shader once again and found it is slightly faster while having worse quality picture. I think we could use it as an option for medium quality settings.

Posted

the image quality should be same, the only difference between my shader and frustum's is default parameter value and default preset.

×
×
  • Create New...