SingularInversions/FaceGenBaseLibrary

Windows only: Add transparency support to D3D11 rendering via depth peeling.

Closed this issue · 9 comments

The existing interactive rendering can be seen (Windows only) by:

  • Build using visual studio and set path to resulting binary (eg. ~FGBL/bin/win/x64/vs19/release)
  • cd ~FGBL\data\base
  • fgbl view mesh Jane.tri Jane.jpg Hair.tri Hair.tga

You should be able to see a head with hair, but the hair doesn't render properly because the facets are rendering in random order with depth culling which of course doesn't work with transparency. The goal is to have this render properly; ie. as if each pixel was rendered back to front (or at least for the 3 nearest intersections...)

My limited understanding is that the best way to do this is depth peeling. It doesn't have to be perfect - for example just peeling the closest 3 surfaces may work well enough.

The existing rendering code renders opaque surfaces before ones containing transparency, but that's it. You can find it in source/LibFgWin/FgGui3dWin.cpp and the main render function is renderBackBuffer(...). It uses Direct3D 11.0. Feel free to add shaders (compute dynamically) as required, and please make use of the RAII abstractions provided (eg. Unique).

Visual Studio 19 is recommended (I think free community version will work).

Don't hesitate to post any questions.

See 'index.html' to get started.

@ab-cpp i've started working on this issue. Just so that i'm clear you want depth peeling instead of culling implemented with 4 passes to add the desired transparency in the rendered image, correct?

Actually, all I want is for the hair to render properly. My very limited understanding is that this is done by "depth peeling" but actually I don't care how it's done as long as it's done on GPU. Please feel free to let me know what approach you think is best.

Ok no worries, i'll try to render the hair with depth peeling and if it doesn't work i'll try using tessellation which i've used before with great results, so either way i'll get it done.

Thanks for that link. It appears that the tessellation approach generates hair geometry on the fly from guide hairs so would not work with our existing collection of polygonal hair models, such as the one in the example above. This may be something we could do in a future project but for this project we need to render existing polygonal transparency mapped hair meshes.

Ok got it, thanks for clarifying.

There's some progress here

That doesn't compile.

Issue solved elsewhere and bounty withdrawn.