Hi,
I'm trying to understand the concept of Beer Shadow Map introduced by Seb Hillaire in this presentation :
1:Right now I'm using a secondary ray march to evaluate the transmittance, but it's quite slow. As I understand it, the BSM could replace it with little quality loss but better performance, am I right ?
2: On this slide, he gives a few details on how to compute the transmittance from the BSM, but little is told about the BSM rendering part itself.
I suppose the BSM is rendered from an orthographic viewport, rendering a large portion of the world around the main view, just like a standard directional light shadow map. Maybe some kind of cascaded BSM could be used used too ?
I'm guessing the code to render it may look like this (dirty quick draft), but I'm not sure at all
vec3 renderBSM(vec3 rayOrigin, vec3 rayDir, float rayLength)
{
float frontDepth = -1;
float maxOpticalDepth = -1;
float meanExtinction = 0;
float densitySum = 0;
int numSamples=0;
for(int i=0;i<max_samples;++i)
{
vec3 p = rayOrigin + i * rayDir * rayLength;
float s = sampleCloudDensity(p);
if(s>0)
{
densitySum+=s;
//increase optical depth
maxOpticalDepth+=rayLength;
//init front depth
if(frontDepth < 0)
{
frontDepth = maxOpticalDepth;
}
numSamples++;
//early break
if(densitySum>=1.0f)
{
break;
}
}
}
//how to compute meanExtinction ?? Like this ?
if(numSamples>0)
{
meanExtinction=densitySum / numSamples;
}
return vec3(frontDepth, meanExtinction,maxOpticalDepth);
}
3: When rendering clouds in the main viewport, use this to evaluate the transmittance, but I'm not sure what the variable “d” means.
vec3 bsm = getBSM(p); //p is the current's sample position
//what is the d variable ?
//The distance to the BSM camera ?
float OpticalDepth = min(bsm.b, bsm.g * max(0,d - bsm.r);
float Transmittance = exp(-OpticalDepth);
What do you think, does it looks like correct to you ?
Thanks !