mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Fix GLES 2 Spotlight Bug
Fixes https://github.com/godotengine/godot/issues/69759 Fixes https://github.com/godotengine/godot/issues/54343 Fixes https://github.com/godotengine/godot/issues/25526
This commit is contained in:
parent
845b70faad
commit
e1081d3d33
@ -1411,9 +1411,12 @@ LIGHT_SHADER_CODE
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture2D(p_shadow, p_pos)))
|
#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture2D(p_shadow, p_pos)))
|
||||||
#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos)))
|
|
||||||
|
|
||||||
float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
|
float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
|
||||||
|
spos.xyz /= spos.w;
|
||||||
|
vec2 pos = spos.xy;
|
||||||
|
float depth = spos.z;
|
||||||
|
|
||||||
#ifdef SHADOW_MODE_PCF_13
|
#ifdef SHADOW_MODE_PCF_13
|
||||||
|
|
||||||
// Soft PCF filter adapted from three.js:
|
// Soft PCF filter adapted from three.js:
|
||||||
@ -1421,9 +1424,6 @@ float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
|
|||||||
// This method actually uses 16 shadow samples. This soft filter isn't needed in GLES3
|
// This method actually uses 16 shadow samples. This soft filter isn't needed in GLES3
|
||||||
// as we can use hardware-based linear filtering instead of emulating it in the shader
|
// as we can use hardware-based linear filtering instead of emulating it in the shader
|
||||||
// like we're doing here.
|
// like we're doing here.
|
||||||
spos.xyz /= spos.w;
|
|
||||||
vec2 pos = spos.xy;
|
|
||||||
float depth = spos.z;
|
|
||||||
vec2 f = fract(pos * (1.0 / shadow_pixel_size) + 0.5);
|
vec2 f = fract(pos * (1.0 / shadow_pixel_size) + 0.5);
|
||||||
pos -= f * shadow_pixel_size;
|
pos -= f * shadow_pixel_size;
|
||||||
|
|
||||||
@ -1461,10 +1461,6 @@ float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
|
|||||||
|
|
||||||
#ifdef SHADOW_MODE_PCF_5
|
#ifdef SHADOW_MODE_PCF_5
|
||||||
|
|
||||||
spos.xyz /= spos.w;
|
|
||||||
vec2 pos = spos.xy;
|
|
||||||
float depth = spos.z;
|
|
||||||
|
|
||||||
float avg = SAMPLE_SHADOW_TEXEL(shadow, pos, depth);
|
float avg = SAMPLE_SHADOW_TEXEL(shadow, pos, depth);
|
||||||
avg += SAMPLE_SHADOW_TEXEL(shadow, pos + vec2(shadow_pixel_size.x, 0.0), depth);
|
avg += SAMPLE_SHADOW_TEXEL(shadow, pos + vec2(shadow_pixel_size.x, 0.0), depth);
|
||||||
avg += SAMPLE_SHADOW_TEXEL(shadow, pos + vec2(-shadow_pixel_size.x, 0.0), depth);
|
avg += SAMPLE_SHADOW_TEXEL(shadow, pos + vec2(-shadow_pixel_size.x, 0.0), depth);
|
||||||
@ -1474,9 +1470,9 @@ float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(SHADOW_MODE_PCF_5) || !defined(SHADOW_MODE_PCF_13)
|
#if !defined(SHADOW_MODE_PCF_5) && !defined(SHADOW_MODE_PCF_13)
|
||||||
|
|
||||||
return SAMPLE_SHADOW_TEXEL_PROJ(shadow, spos);
|
return SAMPLE_SHADOW_TEXEL(shadow, pos, depth);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user