Fixed bug regarding to strange black shapes appearing in ice from material tester demo

This commit is contained in:
Juan Linietsky 2017-07-05 22:36:13 -03:00
parent 12a8fedfe6
commit 1a857c5149
2 changed files with 17 additions and 3 deletions

View file

@ -3981,7 +3981,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
} else {
use_mrt = env && (state.used_screen_texture || state.used_sss || env->ssao_enabled || env->ssr_enabled); //only enable MRT rendering if any of these is enabled
use_mrt = env && (state.used_sss || env->ssao_enabled || env->ssr_enabled); //only enable MRT rendering if any of these is enabled
//effects disabled and transparency also prevent using MRTs
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS];
@ -4157,6 +4157,20 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
if (use_mrt) {
_render_mrts(env, p_cam_projection);
} else {
//FIXME: check that this is possible to use
if (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);
glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
_blur_effect_buffer();
//restored framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
}
}
if (state.used_screen_texture) {

View file

@ -968,12 +968,12 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex;
float light_length = length( light_rel_vec );
float normalized_distance = light_length*spot_lights[idx].light_pos_inv_radius.w;
vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.0), spot_lights[idx].light_direction_attenuation.w ));
vec3 light_attenuation = vec3(pow( max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w ));
vec3 spot_dir = spot_lights[idx].light_direction_attenuation.xyz;
float spot_cutoff=spot_lights[idx].light_params.y;
float scos = max(dot(-normalize(light_rel_vec), spot_dir),spot_cutoff);
float spot_rim = (1.0 - scos) / (1.0 - spot_cutoff);
light_attenuation *= 1.0 - pow( spot_rim, spot_lights[idx].light_params.x);
light_attenuation *= 1.0 - pow( max(spot_rim,0.001), spot_lights[idx].light_params.x);
if (spot_lights[idx].light_params.w>0.5) {
//there is a shadowmap