Update more shaders for receive shadow option

This commit is contained in:
Moritz Brückner 2020-07-13 23:28:43 +02:00
parent 9a47d77594
commit 3654d34997
3 changed files with 40 additions and 36 deletions

View file

@ -346,7 +346,7 @@ void main() {
fragColor.rgb += sampleLight(
p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0
#ifdef _ShadowMap
, 0, pointBias
, 0, pointBias, true
#endif
#ifdef _Spot
, true, spotData.x, spotData.y, spotDir
@ -400,7 +400,7 @@ void main() {
occspec.y,
f0
#ifdef _ShadowMap
, li, lightsArray[li * 2].w // bias
, li, lightsArray[li * 2].w, true // bias
#endif
#ifdef _Spot
, li > numPoints - 1

View file

@ -182,7 +182,7 @@ void main() {
fragColor.rgb += sampleLight(
p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0
#ifdef _ShadowMap
, 0, pointBias
, 0, pointBias, true
#endif
#ifdef _Spot
, true, spotData.x, spotData.y, spotDir
@ -218,7 +218,7 @@ void main() {
occspec.y,
f0
#ifdef _ShadowMap
, li, lightsArray[li * 2].w // bias
, li, lightsArray[li * 2].w, true // bias
#endif
#ifdef _Spot
, li > numPoints - 1

View file

@ -33,7 +33,7 @@
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
const vec3 albedo, const float rough, const float spec, const vec3 f0
#ifdef _ShadowMap
, int index, float bias
, int index, float bias, bool receiveShadow
#endif
#ifdef _Spot
, bool isSpot, float spotA, float spotB, vec3 spotDir
@ -60,6 +60,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
direct *= smoothstep(spotB, spotA, spotEffect);
}
#ifdef _ShadowMap
if (receiveShadow) {
#ifdef _SinglePoint
vec4 lPos = LWVPSpot0 * vec4(p + n * bias * 10, 1.0);
direct *= shadowTest(shadowMapSpot[0], lPos.xyz / lPos.w, bias);
@ -82,6 +83,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
direct *= shadowTest(shadowMapSpot[3], lPos.xyz / lPos.w, bias);
}
#endif
}
#endif
return direct;
}
@ -89,6 +91,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
#ifdef _ShadowMap
#ifndef _Spot
if (receiveShadow) {
#ifdef _SinglePoint
direct *= PCFCube(shadowMapPoint[0], ld, -l, bias, lightProj, n);
#endif
@ -98,6 +101,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
else if (index == 2) direct *= PCFCube(shadowMapPoint[2], ld, -l, bias, lightProj, n);
else if (index == 3) direct *= PCFCube(shadowMapPoint[3], ld, -l, bias, lightProj, n);
#endif
}
#endif
#endif