Jump to content

ported nvidia's fxaa 3.11 shader to unigine


photo

Recommended Posts

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.

Link to comment

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.

Link to comment

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.

Link to comment

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

Link to comment

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

Link to comment
  • 3 weeks later...
  • 2 weeks later...

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

Link to comment

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

Link to comment

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.

Link to comment
×
×
  • Create New...