-Fix for multiple reflection probes causing issues.
-Fix for positional sound corruption to avoid making people deaf.
This commit is contained in:
parent
6422b9d150
commit
741145febd
8 changed files with 74 additions and 32 deletions
|
|
@ -761,7 +761,7 @@ bool RasterizerSceneGLES3::reflection_probe_instance_postprocess_step(RID p_inst
|
|||
storage->shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, rpi->probe_ptr->update_mode == VS::REFLECTION_PROBE_UPDATE_ALWAYS);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0);
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i == 0);
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, rpi->render_step / 5.0);
|
||||
|
||||
uint32_t local_width = width, local_height = height;
|
||||
|
|
@ -2889,7 +2889,7 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
|
|||
reflection_ubo.atlas_clamp[0] = float(x) / reflection_atlas->size;
|
||||
reflection_ubo.atlas_clamp[1] = float(y) / reflection_atlas->size;
|
||||
reflection_ubo.atlas_clamp[2] = float(width) / reflection_atlas->size;
|
||||
reflection_ubo.atlas_clamp[3] = float(height / 2) / reflection_atlas->size;
|
||||
reflection_ubo.atlas_clamp[3] = float(height) / reflection_atlas->size;
|
||||
|
||||
Transform proj = (p_camera_inverse_transform * rpi->transform).inverse();
|
||||
store_transform(proj, reflection_ubo.local_matrix);
|
||||
|
|
@ -4156,7 +4156,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||
glDrawBuffers(1, &gldb);
|
||||
}
|
||||
|
||||
if (env && env->bg_mode == VS::ENV_BG_SKY && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
|
||||
if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || (!storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW))) {
|
||||
|
||||
/*
|
||||
if (use_mrt) {
|
||||
|
|
@ -4175,7 +4175,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||
_render_mrts(env, p_cam_projection);
|
||||
} else {
|
||||
//FIXME: check that this is possible to use
|
||||
if (state.used_screen_texture) {
|
||||
if (storage->frame.current_rt && state.used_screen_texture) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
|
||||
|
|
@ -4189,7 +4189,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||
}
|
||||
}
|
||||
|
||||
if (state.used_screen_texture) {
|
||||
if (storage->frame.current_rt && state.used_screen_texture) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 7);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ void main() {
|
|||
|
||||
#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA)
|
||||
|
||||
N.y=-N.y;
|
||||
frag_color=vec4(texture(N,source_cube).rgb,1.0);
|
||||
#endif
|
||||
|
||||
|
|
@ -277,6 +278,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA)
|
||||
H.y=-H.y;
|
||||
sum.rgb += textureLod(source_cube, H, 0.0).rgb *ndotl;
|
||||
#endif
|
||||
sum.a += ndotl;
|
||||
|
|
|
|||
|
|
@ -1093,27 +1093,19 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta
|
|||
}
|
||||
|
||||
|
||||
|
||||
vec3 splane=normalize(local_ref_vec);
|
||||
vec4 clamp_rect=reflections[idx].atlas_clamp;
|
||||
|
||||
splane.z*=-1.0;
|
||||
if (splane.z>=0.0) {
|
||||
splane.z+=1.0;
|
||||
clamp_rect.y+=clamp_rect.w;
|
||||
} else {
|
||||
splane.z=1.0 - splane.z;
|
||||
splane.y=-splane.y;
|
||||
vec3 norm = normalize(local_ref_vec);
|
||||
norm.xy/=1.0+abs(norm.z);
|
||||
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
|
||||
if (norm.z>0) {
|
||||
norm.y=0.5-norm.y+0.5;
|
||||
}
|
||||
|
||||
splane.xy/=splane.z;
|
||||
splane.xy=splane.xy * 0.5 + 0.5;
|
||||
|
||||
splane.xy = splane.xy * clamp_rect.zw + clamp_rect.xy;
|
||||
splane.xy = clamp(splane.xy,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw);
|
||||
vec2 atlas_uv = norm.xy * clamp_rect.zw + clamp_rect.xy;
|
||||
atlas_uv = clamp(atlas_uv,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw);
|
||||
|
||||
highp vec4 reflection;
|
||||
reflection.rgb = textureLod(reflection_atlas,splane.xy,roughness*5.0).rgb;
|
||||
reflection.rgb = textureLod(reflection_atlas,atlas_uv,roughness*5.0).rgb;
|
||||
|
||||
if (reflections[idx].params.z < 0.5) {
|
||||
reflection.rgb = mix(skybox,reflection.rgb,blend);
|
||||
|
|
@ -1466,6 +1458,7 @@ FRAGMENT_SHADER_CODE
|
|||
vec3 specular_light = vec3(0.0,0.0,0.0);
|
||||
vec3 ambient_light;
|
||||
vec3 diffuse_light = vec3(0.0,0.0,0.0);
|
||||
vec3 env_reflection_light = vec3(0.0,0.0,0.0);
|
||||
|
||||
vec3 eye_vec = -normalize( vertex_interp );
|
||||
|
||||
|
|
@ -1483,7 +1476,7 @@ FRAGMENT_SHADER_CODE
|
|||
vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n);
|
||||
ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz);
|
||||
vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy;
|
||||
specular_light = radiance;
|
||||
env_reflection_light = radiance;
|
||||
|
||||
}
|
||||
//no longer a cubemap
|
||||
|
|
@ -1673,12 +1666,15 @@ FRAGMENT_SHADER_CODE
|
|||
highp vec4 ambient_accum = vec4(0.0,0.0,0.0,0.0);
|
||||
|
||||
for(int i=0;i<reflection_count;i++) {
|
||||
reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,specular_light,reflection_accum,ambient_accum);
|
||||
reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,env_reflection_light,reflection_accum,ambient_accum);
|
||||
}
|
||||
|
||||
if (reflection_accum.a>0.0) {
|
||||
specular_light+=reflection_accum.rgb/reflection_accum.a;
|
||||
} else {
|
||||
specular_light+=env_reflection_light;
|
||||
}
|
||||
|
||||
if (ambient_accum.a>0.0) {
|
||||
ambient_light+=ambient_accum.rgb/ambient_accum.a;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue