Does CESM use a logarithmic function?

logarithmic ：

exponential:

I think this should have the same effect.

Hello! You can see the functions used to compute ESM and CESM in `shadowsFragmentFunctions.fx`

:

- ESM :
`float esm = 1.0 - clamp(exp(min(87., depthScale * shadowPixelDepth)) * shadowMapSample, 0., 1. - darkness);`

- CESM:
`float esm = clamp(exp(min(87., -depthScale * (shadowPixelDepth - shadowMapSample))), darkness, 1.);`

They look pretty similar to one another at a glance, but once you plot the values according to the `shadowMapSample`

value, they look pretty different (for simplicity, I substituted `depthScale`

and `shadowPixelDepth`

for 1.0, and `darkness`

for 0.0):

ESM is f1, CESM is f2. The link to the plots is here: Graphtoy

@sebavan can complement with anything I missed

I’m a little confused.

ESM core formula：

But we use this formula:

ESM : `float esm = 1.0 - clamp(exp(min(87., depthScale * shadowPixelDepth)) * shadowMapSample, 0., 1. - darkness);`

It make the shadowMapSample without exp.Why can we omit the exponent calculation?

Seb will be the best person to answer but he’s out of office for a few days so he may take a bit to respond

Okay~Thanks!

No, the `shadowMapSample`

is generated with the `exp`

, see:

As explained in this thread, we are doing `e^(-c*(z-d))`

and not `e^(-c*(d-z))`

, that’s why we need to do `visibility=1-e^(-c*(z-d))`

in the end.

If you want to use the formula from the original paper (which are the ones you quote), you should use CESM and not ESM in Babylon.js.