Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sheen #2348

Open
hhhhkrx opened this issue Aug 20, 2024 · 1 comment
Open

sheen #2348

hhhhkrx opened this issue Aug 20, 2024 · 1 comment
Assignees
Labels
glTF Rendering Rendering related functions shader Shader related functions
Milestone

Comments

@hhhhkrx
Copy link
Contributor

hhhhkrx commented Aug 20, 2024

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标准。

@hhhhkrx hhhhkrx added glTF material Rendering Rendering related functions shader Shader related functions labels Aug 20, 2024
@hhhhkrx hhhhkrx self-assigned this Aug 20, 2024
@GuoLei1990 GuoLei1990 added this to the 1.4 milestone Aug 21, 2024
@zhuxudong
Copy link
Member

zhuxudong commented Sep 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
glTF Rendering Rendering related functions shader Shader related functions
Projects
None yet
Development

No branches or pull requests

3 participants