提交 da2b5e71 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #10213 from jbaicoianu/logdepthbuf-ssao

Added logarithmic depth buffer support to SSAO postprocessing shader
......@@ -44,6 +44,9 @@ THREE.SSAOShader = {
"uniform float cameraNear;",
"uniform float cameraFar;",
"#ifdef USE_LOGDEPTHBUF",
"uniform float logDepthBufFC;",
"#endif",
"uniform bool onlyAO;", // use only ambient occlusion pass?
......@@ -109,8 +112,19 @@ THREE.SSAOShader = {
"float cameraFarMinusNear = cameraFar - cameraNear;",
"float cameraCoef = 2.0 * cameraNear;",
// "return ( 2.0 * cameraNear ) / ( cameraFar + cameraNear - unpackDepth( texture2D( tDepth, coord ) ) * ( cameraFar - cameraNear ) );",
"return cameraCoef / ( cameraFarPlusNear - unpackRGBAToDepth( texture2D( tDepth, coord ) ) * cameraFarMinusNear );",
"#ifdef USE_LOGDEPTHBUF",
"float logz = unpackRGBAToDepth( texture2D( tDepth, coord ) );",
"float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;",
"float z = (logz / w) + 1.0;",
"#else",
"float z = unpackRGBAToDepth( texture2D( tDepth, coord ) );",
"#endif",
"return cameraCoef / ( cameraFarPlusNear - z * cameraFarMinusNear );",
"}",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册