Merge pull request #30870 from raphael10241024/fix_shadow
update algorithm about paking float to vec4 to fix shadow slipping
This commit is contained in:
commit
47df673d73
6 changed files with 10 additions and 11 deletions
|
@ -489,8 +489,7 @@ FRAGMENT_SHADER_CODE
|
||||||
highp float shadow_attenuation = 0.0;
|
highp float shadow_attenuation = 0.0;
|
||||||
|
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture2D((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0))
|
||||||
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture2D((m_tex), (m_uv)), vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0))
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ void main() {
|
||||||
|
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
|
||||||
highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
|
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
|
||||||
comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
|
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
|
||||||
gl_FragColor = comp;
|
gl_FragColor = comp;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ LIGHT_SHADER_CODE
|
||||||
|
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
|
||||||
#define SHADOW_DEPTH(m_val) dot(m_val, vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0))
|
#define SHADOW_DEPTH(m_val) dot(m_val, vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -2207,8 +2207,8 @@ FRAGMENT_SHADER_CODE
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
|
||||||
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
|
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
|
||||||
highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
|
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
|
||||||
comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
|
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
|
||||||
gl_FragColor = comp;
|
gl_FragColor = comp;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8093,7 +8093,7 @@ void RasterizerStorageGLES3::initialize() {
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units);
|
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size);
|
||||||
|
|
||||||
config.use_rgba_2d_shadows = config.framebuffer_float_supported;
|
config.use_rgba_2d_shadows = !config.framebuffer_float_supported;
|
||||||
|
|
||||||
//generic quadie for copying
|
//generic quadie for copying
|
||||||
|
|
||||||
|
|
|
@ -597,7 +597,7 @@ FRAGMENT_SHADER_CODE
|
||||||
|
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
|
||||||
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture((m_tex), (m_uv)), vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0))
|
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ void main() {
|
||||||
|
|
||||||
#ifdef USE_RGBA_SHADOWS
|
#ifdef USE_RGBA_SHADOWS
|
||||||
|
|
||||||
highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
|
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
|
||||||
comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
|
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
|
||||||
distance_buf = comp;
|
distance_buf = comp;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue