Cube shadow fixes
This commit is contained in:
parent
e6e4206991
commit
24b2cc23cd
|
@ -33,8 +33,11 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
|
|||
|
||||
float PCFCube(samplerCubeShadow shadowMapCube, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n) {
|
||||
const float s = shadowmapCubePcfSize; // TODO: incorrect...
|
||||
float compare = lpToDepth(lp - n * bias * 80, lightProj);
|
||||
ml = ml + n * bias * 80;
|
||||
float compare = lpToDepth(lp, lightProj) - bias * 1.5;
|
||||
ml = ml + n * bias * 20;
|
||||
#ifdef HLSL
|
||||
ml.y = -ml.y;
|
||||
#endif
|
||||
float result = texture(shadowMapCube, vec4(ml, compare));
|
||||
result += texture(shadowMapCube, vec4(ml + vec3(s, s, s), compare));
|
||||
result += texture(shadowMapCube, vec4(ml + vec3(-s, s, s), compare));
|
||||
|
|
|
@ -43,6 +43,9 @@ void main() {
|
|||
else { // Cube
|
||||
vec3 lp = lightPos - p;
|
||||
vec3 l = normalize(lp);
|
||||
#ifdef HLSL
|
||||
l.y = -l.y;
|
||||
#endif
|
||||
fragColor[0] = float(texture(shadowMapCube, -l).r + shadowsBias > lpToDepth(lp, lightProj));
|
||||
fragColor[1] = 0.0;
|
||||
}
|
||||
|
|
|
@ -1499,7 +1499,6 @@ class ArmoryExporter:
|
|||
o['strength'] *= 2.6
|
||||
o['fov'] = 1.5708 # pi/2
|
||||
o['shadowmap_cube'] = True
|
||||
o['shadows_bias'] *= 2.0
|
||||
if objref.shadow_soft_size > 0.1:
|
||||
o['light_size'] = objref.shadow_soft_size * 10
|
||||
elif objtype == 'SPOT':
|
||||
|
|
|
@ -403,11 +403,14 @@ def make_forward_mobile(con_mesh):
|
|||
frag.add_uniform('vec2 lightProj', link='_lightPlaneProj')
|
||||
frag.add_uniform('samplerCubeShadow shadowMapPoint[1]')
|
||||
frag.write('const float s = shadowmapCubePcfSize;') # TODO: incorrect...
|
||||
frag.write('float compare = lpToDepth(ld - n * pointBias * 80, lightProj);')
|
||||
frag.write('float compare = lpToDepth(ld, lightProj) - pointBias;')
|
||||
frag.write('#ifdef HLSL')
|
||||
frag.write('l.y = -l.y;')
|
||||
frag.write('#endif')
|
||||
if '_Legacy' in wrd.world_defs:
|
||||
frag.write('visibility = float(texture(shadowMapPoint[0], vec3(-l + n * pointBias * 80)).r > compare);')
|
||||
frag.write('visibility = float(texture(shadowMapPoint[0], vec3(-l + n * pointBias * 20)).r > compare);')
|
||||
else:
|
||||
frag.write('visibility = texture(shadowMapPoint[0], vec4(-l + n * pointBias * 80, compare)).r;')
|
||||
frag.write('visibility = texture(shadowMapPoint[0], vec4(-l + n * pointBias * 20, compare)).r;')
|
||||
|
||||
frag.write('direct += basecol * dotNL * pointCol * attenuate(distance(wposition, pointPos)) * visibility;')
|
||||
|
||||
|
|
Loading…
Reference in a new issue