Baker fixes

This commit is contained in:
Juan Linietsky 2018-10-07 11:18:27 -03:00
parent 5676632a3b
commit e0871b0f52
6 changed files with 29 additions and 21 deletions

View file

@ -2519,7 +2519,7 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, false);
}
void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform) {
void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog) {
//store camera into ubo
store_camera(p_cam_projection, state.ubo_data.projection_matrix);
@ -2570,7 +2570,7 @@ void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatr
state.ubo_data.fog_color_enabled[0] = linear_fog.r;
state.ubo_data.fog_color_enabled[1] = linear_fog.g;
state.ubo_data.fog_color_enabled[2] = linear_fog.b;
state.ubo_data.fog_color_enabled[3] = env->fog_enabled ? 1.0 : 0.0;
state.ubo_data.fog_color_enabled[3] = (!p_no_fog && env->fog_enabled) ? 1.0 : 0.0;
Color linear_sun = env->fog_sun_color.to_linear();
state.ubo_data.fog_sun_color_amount[0] = linear_sun.r;
@ -4083,7 +4083,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;
}
_setup_environment(env, p_cam_projection, p_cam_transform);
_setup_environment(env, p_cam_projection, p_cam_transform, p_reflection_probe.is_valid());
bool fb_cleared = false;

View file

@ -831,7 +831,7 @@ public:
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy);
void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog = false);
void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transform, bool p_use_shadows);
void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_shadow_atlas);
void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env);

View file

@ -1340,7 +1340,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal, vec3 binormal, vec3 t
reflection_accum += reflection;
}
#ifndef USE_LIGHTMAP
#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
if (reflections[idx].ambient.a > 0.0) { //compute ambient using skybox
vec3 local_amb_vec = (reflections[idx].local_matrix * vec4(normal, 0.0)).xyz;
@ -1957,7 +1957,7 @@ FRAGMENT_SHADER_CODE
} else {
specular_light += env_reflection_light;
}
#ifndef USE_LIGHTMAP
#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
if (ambient_accum.a > 0.0) {
ambient_light = ambient_accum.rgb / ambient_accum.a;
}

View file

@ -321,7 +321,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else {
//mesh since nothing else
node = memnew(MeshInstance);
Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
//Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
}
} break;
case Collada::Node::TYPE_SKELETON: {

View file

@ -365,29 +365,37 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
if (mi) {
Node *col;
Node *col = NULL;
if (_teststr(name, "colonly")) {
col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col, NULL);
if (col == NULL) {
ERR_PRINTS("Error generating collision for mesh: " + name);
} else {
col->set_name(_fixstr(name, "colonly"));
col->set_name(_fixstr(name, "colonly"));
}
} else {
col = mi->create_convex_collision_node();
ERR_FAIL_COND_V(!col, NULL);
if (col == NULL) {
ERR_PRINTS("Error generating collision for mesh: " + name);
} else {
col->set_name(_fixstr(name, "convcolonly"));
col->set_name(_fixstr(name, "convcolonly"));
}
}
Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
p_node->replace_by(col);
memdelete(p_node);
p_node = col;
if (col) {
Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
p_node->replace_by(col);
memdelete(p_node);
p_node = col;
StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape");
colshape->set_owner(p_node->get_owner());
StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape");
colshape->set_owner(p_node->get_owner());
}
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
StaticBody *sb = memnew(StaticBody);

View file

@ -116,7 +116,7 @@ class ResourceImporterScene : public ResourceImporter {
enum LightBakeMode {
LIGHT_BAKE_DISABLED,
LIGHT_BAKE_ENABLE,
//LIGHT_BAKE_LIGHTMAPS
LIGHT_BAKE_LIGHTMAPS
};
void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);