-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
volume #2351
Comments
现阶段考虑到性能,以及不支持立方体探针,我建议先屏幕空间,Three 的这个效果在移动端上可以接受:https://threejs.org/examples/?q=transmission#webgl_loader_gltf_transmission |
管线部分可能需要改造的地方,直接写这里了,到时候一起讨论下: 1. 是否只允许 PBR 才支持 Volume + transmission2. opaque pass 执行时机更改把这行本来基于 opaqueTextureEnabled 开关判断: 改为开关 + 队列数量判断 if(camera.opaqueTextureEnabled || transmissionQueue.elements.length) 3. RenderQueue 队列新增 Transmission 队列4. Material 新增属性
5. 其他
|
这个是从哪里来?需要引擎提供啥 |
https://github.com/BabylonJS/Babylon.js/blob/5a96272de06104f2fd793e4a8a6cbd05362623f7/packages/dev/core/src/Materials/Textures/refractionTexture.ts#L7 |
这个效果我也觉得ok的,可以先屏幕空间,后续等有了探针再加cubemap。 |
GLTF
https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_volume
https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_transmission
根据gltf官方给出的参考,volume的算法需要和KHR_materials_transmission相结合,transmission只模拟了光的透射,volume增加了厚度的算法,折射率的输入则是需要和KHR_materials_ior结合,最终暴露给用户的uniform:
KHR_materials_transmission参考:
three.js
https://github.com/mrdoob/three.js/blob/e6f98724943459ea395c856a253200e8aac61ceb/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js#L170
https://github.com/mrdoob/three.js/blob/3f2956c35e1bd1fc8cbe35f1430e475fd848e6a2/src/renderers/WebGLRenderer.js#L1444
https://github.com/mrdoob/three.js/blob/3f2956c35e1bd1fc8cbe35f1430e475fd848e6a2/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js#L1
https://github.com/mrdoob/three.js/blob/3f2956c35e1bd1fc8cbe35f1430e475fd848e6a2/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js#L178
babylon
https://github.com/BabylonJS/Babylon.js/blob/1e2bc74ead52b91030a6abd9695e5a5f175b0758/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSubSurface.fx#L36
折射坐标
https://github.com/BabylonJS/Babylon.js/blob/ba1b14818cbcfbc244b96ca2b127544fd19b5c15/packages/dev/core/src/ShadersWGSL/default.fragment.fx#L224
htthttps://github.com/BabylonJS/Babylon.js/blob/e98b900a49b989f3215b002eeb65d0e23cf005b5/packages/dev/core/src/Materials/Textures/refractionTexture.ts#L9
filament
(IOR、absorption(吸收系数)、Micro-thickness and thickness)
https://github.com/google/filament/blob/1c2ffc9ed4581080e53b23dda63ed7bfee6311e7/shaders/src/shading_lit.fs#L102
折射的具体算法放在了间接光部分:
包含了采样 cubemap 和 screenspace 两种算法
https://github.com/google/filament/blob/1c2ffc9ed4581080e53b23dda63ed7bfee6311e7/shaders/src/light_indirect.fs#L493
screenspace下的折射uv通过相应的矩阵转换取到:
UNITY HDRP
https://docs.unity3d.com/Packages/[email protected]/manual/Refraction-in-HDRP.html
unity的内置折射是基于HDRP管线,并且采用屏幕空间计算,需要反射探针配合。
总结
● 优先实现屏幕空间效果,等后续探针功能接入,再考虑cubemap
● 如果按照屏幕空间算法的话,直接调用opaque texture能满足最基本效果
The text was updated successfully, but these errors were encountered: