galacean / engine

A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and glTF.
https://galacean.antgroup.com/engine
MIT License
4.28k stars 305 forks source link

sheen #2348

Open hhhhkrx opened 2 months ago

hhhhkrx commented 2 months ago

GLTF

https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen

three.js

https://github.com/mrdoob/three.js/blob/3f2956c35e1bd1fc8cbe35f1430e475fd848e6a2/src/nodes/functions/BSDF/BRDF_Sheen.js#L3 image

babylon

1723202302527-6fa6699c-0ca9-471a-b522-77c35bd06793

技术细节 直接光部分: https://github.com/BabylonJS/Babylon.js/blob/7fd025d4fbb4ea0b6f4f108788cd312a613b38d8/packages/dev/core/src/Shaders/ShadersInclude/pbrDirectLightingFunctions.fx#L160 间接光部分: https://github.com/BabylonJS/Babylon.js/blob/7fd025d4fbb4ea0b6f4f108788cd312a613b38d8/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSheen.fx#L42

filament

https://github.com/google/filament/blob/06f9626429bca811f459bc9286059fa710689dfc/shaders/src/shading_model_standard.fs#L5 image 技术细节

float distributionCloth(float roughness, float NoH) {
#if BRDF_CLOTH_D == SPECULAR_D_CHARLIE
    return D_Charlie(roughness, NoH);
#endif
}

float visibilityCloth(float NoV, float NoL) {
#if BRDF_CLOTH_V == SPECULAR_V_NEUBELT
    return V_Neubelt(NoV, NoL);
#endif
}

#if defined(MATERIAL_HAS_SHEEN_COLOR)
vec3 sheenLobe(const PixelParams pixel, float NoV, float NoL, float NoH) {
    float D = distributionCloth(pixel.sheenRoughness, NoH);
    float V = visibilityCloth(NoV, NoL);

    return (D * V) * pixel.sheenColor;
}
#endif

技术对比

sheen由于没什么特别难的算法,所以三个引擎都使用了基本相同的brdf算法,只是一些api调用不太一样

方案

按照sheen标准brdf算法内置到引擎,uniform一一对应GLTF2.0标准。

zhuxudong commented 2 months ago

Sheen 只需要注意一下间接光部分使用曲线拟合方法,引擎没有 LUT 贴图。另外可以参考/关闭这个陈年老PR: #692