SingularInversions / FaceGenBaseLibrary

A simple cross-platform C++17 library for developing computational 3D graphics applications.
MIT License
46 stars 25 forks source link

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

Closed ab-cpp closed 4 years ago

ab-cpp commented 4 years ago

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

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.

ab-cpp commented 4 years ago

See 'index.html' to get started.

mul1sh commented 4 years ago

@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?

ab-cpp commented 4 years ago

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.

mul1sh commented 4 years ago

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.

ab-cpp commented 4 years ago

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.

mul1sh commented 4 years ago

Ok got it, thanks for clarifying.

denim2x commented 4 years ago

There's some progress here

ab-cpp commented 4 years ago

That doesn't compile.

ab-cpp commented 4 years ago

Issue solved elsewhere and bounty withdrawn.