Fix volumetric light for different lamp combinations
This commit is contained in:
parent
e2ecf3fea2
commit
93f0bcba78
|
@ -86,30 +86,32 @@ const float lighting = 0.4;
|
|||
void rayStep(inout vec3 curPos, inout float curOpticalDepth, inout float scatteredLightAmount, float stepLenWorld, vec3 viewVecNorm) {
|
||||
curPos += stepLenWorld * viewVecNorm;
|
||||
const float density = 1.0;
|
||||
|
||||
|
||||
float l1 = lighting * stepLenWorld * tScat * density;
|
||||
curOpticalDepth *= exp(-tExt * stepLenWorld * density);
|
||||
|
||||
float visibility = 0.0;
|
||||
|
||||
#ifdef _Sun
|
||||
#ifdef _CSM
|
||||
mat4 LWVP = mat4(casData[4], casData[4 + 1], casData[4 + 2], casData[4 + 3]);
|
||||
#endif
|
||||
vec4 lPos = LWVP * vec4(curPos, 1.0);
|
||||
lPos.xyz /= lPos.w;
|
||||
float visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias));
|
||||
visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias));
|
||||
#endif
|
||||
|
||||
#ifdef _SinglePoint
|
||||
#ifdef _Spot
|
||||
vec4 lPos = LWVPSpot0 * vec4(curPos, 1.0);
|
||||
float visibility = shadowTest(shadowMapSpot[0], lPos.xyz / lPos.w, pointBias);
|
||||
visibility = shadowTest(shadowMapSpot[0], lPos.xyz / lPos.w, pointBias);
|
||||
float spotEffect = dot(spotDir, normalize(pointPos - curPos)); // lightDir
|
||||
if (spotEffect < spotData.x) { // x - cutoff, y - cutoff - exponent
|
||||
visibility *= smoothstep(spotData.y, spotData.x, spotEffect);
|
||||
}
|
||||
#else
|
||||
vec3 ld = pointPos - curPos;
|
||||
float visibility = PCFCube(shadowMapPoint[0], ld, -normalize(ld), pointBias, lightProj, vec3(0.0));
|
||||
visibility = PCFCube(shadowMapPoint[0], ld, -normalize(ld), pointBias, lightProj, vec3(0.0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue