Merge pull request #2128 from N8n5h/light-fix-2
Fix shadows not working when there are lights present with cast_shadow=false
This commit is contained in:
commit
7d78e01bb4
|
@ -94,7 +94,7 @@ uniform vec3 eye;
|
||||||
uniform vec3 eyeLook;
|
uniform vec3 eyeLook;
|
||||||
|
|
||||||
#ifdef _Clusters
|
#ifdef _Clusters
|
||||||
uniform vec4 lightsArray[maxLights * 2];
|
uniform vec4 lightsArray[maxLights * 3];
|
||||||
#ifdef _Spot
|
#ifdef _Spot
|
||||||
uniform vec4 lightsArraySpot[maxLights];
|
uniform vec4 lightsArraySpot[maxLights];
|
||||||
#endif
|
#endif
|
||||||
|
@ -456,18 +456,19 @@ void main() {
|
||||||
n,
|
n,
|
||||||
v,
|
v,
|
||||||
dotNV,
|
dotNV,
|
||||||
lightsArray[li * 2].xyz, // lp
|
lightsArray[li * 3].xyz, // lp
|
||||||
lightsArray[li * 2 + 1].xyz, // lightCol
|
lightsArray[li * 3 + 1].xyz, // lightCol
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
occspec.y,
|
occspec.y,
|
||||||
f0
|
f0
|
||||||
#ifdef _ShadowMap
|
#ifdef _ShadowMap
|
||||||
, li, lightsArray[li * 2].w, true // bias
|
// light index, shadow bias, cast_shadows
|
||||||
|
, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0
|
||||||
#endif
|
#endif
|
||||||
#ifdef _Spot
|
#ifdef _Spot
|
||||||
, lightsArray[li * 2 + 1].w != 0.0
|
, lightsArray[li * 3 + 2].y != 0.0
|
||||||
, lightsArray[li * 2 + 1].w // cutoff
|
, lightsArray[li * 3 + 2].y // cutoff
|
||||||
, lightsArraySpot[li].w // cutoff - exponent
|
, lightsArraySpot[li].w // cutoff - exponent
|
||||||
, lightsArraySpot[li].xyz // spotDir
|
, lightsArraySpot[li].xyz // spotDir
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,7 +37,7 @@ uniform vec3 eye;
|
||||||
uniform vec3 eyeLook;
|
uniform vec3 eyeLook;
|
||||||
|
|
||||||
#ifdef _Clusters
|
#ifdef _Clusters
|
||||||
uniform vec4 lightsArray[maxLights * 2];
|
uniform vec4 lightsArray[maxLights * 3];
|
||||||
#ifdef _Spot
|
#ifdef _Spot
|
||||||
uniform vec4 lightsArraySpot[maxLights];
|
uniform vec4 lightsArraySpot[maxLights];
|
||||||
#endif
|
#endif
|
||||||
|
@ -258,18 +258,19 @@ void main() {
|
||||||
n,
|
n,
|
||||||
v,
|
v,
|
||||||
dotNV,
|
dotNV,
|
||||||
lightsArray[li * 2].xyz, // lp
|
lightsArray[li * 3].xyz, // lp
|
||||||
lightsArray[li * 2 + 1].xyz, // lightCol
|
lightsArray[li * 3 + 1].xyz, // lightCol
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
occspec.y,
|
occspec.y,
|
||||||
f0
|
f0
|
||||||
#ifdef _ShadowMap
|
#ifdef _ShadowMap
|
||||||
, li, lightsArray[li * 2].w, true // bias
|
// light index, shadow bias, cast_shadows
|
||||||
|
, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0
|
||||||
#endif
|
#endif
|
||||||
#ifdef _Spot
|
#ifdef _Spot
|
||||||
, lightsArray[li * 2 + 1].w != 0.0
|
, lightsArray[li * 3 + 2].y != 0.0
|
||||||
, lightsArray[li * 2 + 1].w // cutoff
|
, lightsArray[li * 3 + 2].y // cutoff
|
||||||
, lightsArraySpot[li].w // cutoff - exponent
|
, lightsArraySpot[li].w // cutoff - exponent
|
||||||
, lightsArraySpot[li].xyz // spotDir
|
, lightsArraySpot[li].xyz // spotDir
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,7 @@ uniform sampler2D gbufferD;
|
||||||
uniform sampler2D snoise;
|
uniform sampler2D snoise;
|
||||||
|
|
||||||
#ifdef _Clusters
|
#ifdef _Clusters
|
||||||
uniform vec4 lightsArray[maxLights * 2];
|
uniform vec4 lightsArray[maxLights * 3];
|
||||||
#ifdef _Spot
|
#ifdef _Spot
|
||||||
uniform vec4 lightsArraySpot[maxLights];
|
uniform vec4 lightsArraySpot[maxLights];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,7 +57,11 @@ class Inc {
|
||||||
break;
|
break;
|
||||||
if (LightObject.discardLightCulled(light)) continue;
|
if (LightObject.discardLightCulled(light)) continue;
|
||||||
if (light.data.raw.type == "point") {
|
if (light.data.raw.type == "point") {
|
||||||
for(k in 0...light.tileOffsetX.length) {
|
if (!light.data.raw.cast_shadow) {
|
||||||
|
j += 4 * 6;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(k in 0...6) {
|
||||||
LightObject.pointLightsData[j ] = light.tileOffsetX[k]; // posx
|
LightObject.pointLightsData[j ] = light.tileOffsetX[k]; // posx
|
||||||
LightObject.pointLightsData[j + 1] = light.tileOffsetY[k]; // posy
|
LightObject.pointLightsData[j + 1] = light.tileOffsetY[k]; // posy
|
||||||
LightObject.pointLightsData[j + 2] = light.tileScale[k]; // tile scale factor relative to atlas
|
LightObject.pointLightsData[j + 2] = light.tileScale[k]; // tile scale factor relative to atlas
|
||||||
|
|
|
@ -9,7 +9,7 @@ def write(vert, frag):
|
||||||
frag.add_include_front('std/clusters.glsl')
|
frag.add_include_front('std/clusters.glsl')
|
||||||
frag.add_uniform('vec2 cameraProj', link='_cameraPlaneProj')
|
frag.add_uniform('vec2 cameraProj', link='_cameraPlaneProj')
|
||||||
frag.add_uniform('vec2 cameraPlane', link='_cameraPlane')
|
frag.add_uniform('vec2 cameraPlane', link='_cameraPlane')
|
||||||
frag.add_uniform('vec4 lightsArray[maxLights * 2]', link='_lightsArray')
|
frag.add_uniform('vec4 lightsArray[maxLights * 3]', link='_lightsArray')
|
||||||
frag.add_uniform('sampler2D clustersData', link='_clustersData')
|
frag.add_uniform('sampler2D clustersData', link='_clustersData')
|
||||||
if is_shadows:
|
if is_shadows:
|
||||||
frag.add_uniform('bool receiveShadow')
|
frag.add_uniform('bool receiveShadow')
|
||||||
|
@ -56,19 +56,19 @@ def write(vert, frag):
|
||||||
frag.write(' n,')
|
frag.write(' n,')
|
||||||
frag.write(' vVec,')
|
frag.write(' vVec,')
|
||||||
frag.write(' dotNV,')
|
frag.write(' dotNV,')
|
||||||
frag.write(' lightsArray[li * 2].xyz,') # lp
|
frag.write(' lightsArray[li * 3].xyz,') # lp
|
||||||
frag.write(' lightsArray[li * 2 + 1].xyz,') # lightCol
|
frag.write(' lightsArray[li * 3 + 1].xyz,') # lightCol
|
||||||
frag.write(' albedo,')
|
frag.write(' albedo,')
|
||||||
frag.write(' roughness,')
|
frag.write(' roughness,')
|
||||||
frag.write(' specular,')
|
frag.write(' specular,')
|
||||||
frag.write(' f0')
|
frag.write(' f0')
|
||||||
if is_shadows:
|
if is_shadows:
|
||||||
frag.write(' , li, lightsArray[li * 2].w, receiveShadow') # bias
|
frag.write('\t, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0') # bias
|
||||||
if '_Spot' in wrd.world_defs:
|
if '_Spot' in wrd.world_defs:
|
||||||
frag.write(' , lightsArray[li * 2 + 1].w != 0.0')
|
frag.write('\t, lightsArray[li * 3 + 2].y != 0.0')
|
||||||
frag.write(' , lightsArray[li * 2 + 1].w') # cutoff
|
frag.write('\t, lightsArray[li * 3 + 2].y') # cutoff
|
||||||
frag.write(' , lightsArraySpot[li].w') # cutoff - exponent
|
frag.write('\t, lightsArraySpot[li].w') # cutoff - exponent
|
||||||
frag.write(' , lightsArraySpot[li].xyz') # spotDir
|
frag.write('\t, lightsArraySpot[li].xyz') # spotDir
|
||||||
if '_VoxelShadow' in wrd.world_defs and '_VoxelAOvar' in wrd.world_defs:
|
if '_VoxelShadow' in wrd.world_defs and '_VoxelAOvar' in wrd.world_defs:
|
||||||
frag.write(' , voxels, voxpos')
|
frag.write(' , voxels, voxpos')
|
||||||
frag.write(');')
|
frag.write(');')
|
||||||
|
|
Loading…
Reference in a new issue