uinosoft / t3d.js

ThingJS 3D Engine (t3d) is a lightweight, web-first, and extendable 3D rendering library.
BSD 3-Clause "New" or "Revised" License
184 stars 23 forks source link

Optimize specular AA. #15

Open wzw9803 opened 1 year ago

wzw9803 commented 1 year ago

In this commit, we optimized the anti-aliasing of specular. Instead of only filtering geometryNormal before, we added filtering for normalMap.

企业微信截图_16818765469656

This is a small change. We plan to do another optimization in the future. We may add some parameters to the material to control the strength of anti-aliasing to meet the different needs of different scenarios.

And thanks again for the relevant information provided by @VanderSP!

Reference : Tokuyoshi and Kaplanya, Stable Geometric Specular Antialiasing with Projected-Space NDF Filtering, 2021 Tokuyoshi and Kaplanyan, Improved Geometric Specular Antialiasing, 2019 Tokuyoshi, Error Reduction and Simplification for Shading Anti-Aliasing, 2017 Kaplanyan, Rendering Highly Specular Materials, 2016 Kaplanyan, NDFFiltering, 2016 Rock-Solid Shading, Dan Baker and Stephen Hill, 2012 Stephen Hill, Specular Showdown, 2011

wzw9803 commented 1 year ago

I tested Oasis, Three, T3d - master, T3d - feat-specular-antiAliasing - SPECULAR_AA2, Babylon, PlayCanvas antialiasing with the same model. PlayCanvas uses TAA anti-aliasing. I think the effect is the best when the camera is still, so we take the effect of PlayCanvas as the standard and have the following conclusions: image image

  1. Babylon anti-aliasing works best, but maybe a bit too much, some highlight details seem to be lost. (maybe caused by different lighting) image

  2. T3d - feat-specular-antiAliasing - SPECULAR_AA2 Anti-aliasing effect Second, the advantage is that the anti-aliasing strength is adjustable, you can choose between anti-aliasing and highlight details, and adjust it to the highest strength, which is closer to the Babylon effect. image

  3. Oasis is slightly better than Three because Oasis handles NormalMap. image

  4. Three. image

  5. T3d - master image

Now we are still not sure which anti-aliasing method to use, so this branch is temporarily reserved, and more scenarios may be needed for testing.

Resources: Test Model: dreadroamer