ChaosGroup / vray_gltf

A Python script for rendering glTF files with V-Ray App SDK
MIT License
29 stars 6 forks source link

KHR_material_anistropy: missing extension support #20

Open bhouston opened 1 year ago

bhouston commented 1 year ago

This project is currently missing support for KHR_materials_anisotropy.

Khronos has some test models for this here:

model-viewer-golden

babylon-golden

model-viewer-golden-2

I do not have comparison model-viewer render fidelity results yet as my PR to add anisotropy models to the test suite hasn't been accepted yet: https://github.com/google/model-viewer/pull/4493

bhouston commented 1 year ago

@vkoylazov we are looking to implement this in this project ourselves. The main challenge with this one is that the use of a "direction" texture where RG channels in the anisotropy texture refer to the direction as a vector and B channel is the strength factor. I do not know how to extract the RG channels as vector and convert to a rotation parameter that V-Ray requires.

Text from the extension itself:

"The anisotropy texture. Red and green channels represent the anisotropy direction in [-1, 1] tangent, bitangent space, to be rotated by anisotropyRotation. The blue channel contains strength as [0, 1] to be multiplied by anisotropyStrength."

bhouston commented 1 year ago

This maps onto the anisotropy BRDF properties in V-Ray MTL: https://docs.chaos.com/display/VMAX/VRayMtl#heading-BRDF

jasondavies commented 1 year ago

I'm going to work on this.

jasondavies commented 1 year ago
Screenshot 2023-10-06 at 17 16 03

This is the result of setting brdf.anisotropy = anisotropy_strength (this is the only thing this test really tests). It seems to work for non-zero roughness, but not for anisotropyStrength=1.0? So it remains to fix this for roughnessFactor=0.0 and for anisotropyStrength=1.0?

Of course the other tests will also need looking at.