mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
small fix so shadows dont need to use a separate material for world vertex coords (more perf)
This commit is contained in:
parent
0243803117
commit
d8953fe737
@ -2164,7 +2164,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
|||||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_OPAQUE_PREPASS, false);
|
state.scene_shader.set_conditional(SceneShaderGLES3::USE_OPAQUE_PREPASS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass) {
|
void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass,bool p_shadow_pass) {
|
||||||
|
|
||||||
RasterizerStorageGLES3::Material *m = NULL;
|
RasterizerStorageGLES3::Material *m = NULL;
|
||||||
RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : (p_material >= 0 ? p_instance->materials[p_material] : p_geometry->material);
|
RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : (p_material >= 0 ? p_instance->materials[p_material] : p_geometry->material);
|
||||||
@ -2196,17 +2196,17 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
|
|||||||
|
|
||||||
ERR_FAIL_COND(!m);
|
ERR_FAIL_COND(!m);
|
||||||
|
|
||||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass);
|
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass, p_shadow_pass);
|
||||||
|
|
||||||
while (m->next_pass.is_valid()) {
|
while (m->next_pass.is_valid()) {
|
||||||
m = storage->material_owner.getornull(m->next_pass);
|
m = storage->material_owner.getornull(m->next_pass);
|
||||||
if (!m || !m->shader || !m->shader->valid)
|
if (!m || !m->shader || !m->shader->valid)
|
||||||
break;
|
break;
|
||||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass);
|
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass, p_shadow_pass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass) {
|
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
|
||||||
|
|
||||||
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture;
|
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture;
|
||||||
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX;
|
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX;
|
||||||
@ -2238,11 +2238,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
|
|||||||
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
|
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
|
||||||
//shader does not use discard and does not write a vertex position, use generic material
|
//shader does not use discard and does not write a vertex position, use generic material
|
||||||
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
|
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
|
||||||
p_material = storage->material_owner.getptr( p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
|
p_material = storage->material_owner.getptr( !p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
|
||||||
no_cull = true;
|
no_cull = true;
|
||||||
mirror = false;
|
mirror = false;
|
||||||
} else {
|
} else {
|
||||||
p_material = storage->material_owner.getptr( p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
|
p_material = storage->material_owner.getptr( !p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3064,7 +3064,7 @@ void RasterizerSceneGLES3::_copy_texture_to_front_buffer(GLuint p_texture) {
|
|||||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false);
|
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass) {
|
void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass) {
|
||||||
|
|
||||||
current_geometry_index = 0;
|
current_geometry_index = 0;
|
||||||
current_material_index = 0;
|
current_material_index = 0;
|
||||||
@ -3089,7 +3089,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
|
|||||||
|
|
||||||
int mat_idx = inst->materials[i].is_valid() ? i : -1;
|
int mat_idx = inst->materials[i].is_valid() ? i : -1;
|
||||||
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
|
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
|
||||||
_add_geometry(s, inst, NULL, mat_idx, p_depth_pass);
|
_add_geometry(s, inst, NULL, mat_idx, p_depth_pass, p_shadow_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mesh->last_pass=frame;
|
//mesh->last_pass=frame;
|
||||||
@ -3112,7 +3112,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
|
|||||||
for (int i = 0; i < ssize; i++) {
|
for (int i = 0; i < ssize; i++) {
|
||||||
|
|
||||||
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
|
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
|
||||||
_add_geometry(s, inst, multi_mesh, -1, p_depth_pass);
|
_add_geometry(s, inst, multi_mesh, -1, p_depth_pass, p_shadow_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@ -3121,7 +3121,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
|
|||||||
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
|
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
|
||||||
ERR_CONTINUE(!immediate);
|
ERR_CONTINUE(!immediate);
|
||||||
|
|
||||||
_add_geometry(immediate, inst, NULL, -1, p_depth_pass);
|
_add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VS::INSTANCE_PARTICLES: {
|
case VS::INSTANCE_PARTICLES: {
|
||||||
@ -3143,7 +3143,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
|
|||||||
for (int j = 0; j < ssize; j++) {
|
for (int j = 0; j < ssize; j++) {
|
||||||
|
|
||||||
RasterizerStorageGLES3::Surface *s = mesh->surfaces[j];
|
RasterizerStorageGLES3::Surface *s = mesh->surfaces[j];
|
||||||
_add_geometry(s, inst, particles, -1, p_depth_pass);
|
_add_geometry(s, inst, particles, -1, p_depth_pass, p_shadow_pass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4059,7 +4059,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
render_list.clear();
|
render_list.clear();
|
||||||
_fill_render_list(p_cull_result, p_cull_count, true);
|
_fill_render_list(p_cull_result, p_cull_count, true, false);
|
||||||
render_list.sort_by_key(false);
|
render_list.sort_by_key(false);
|
||||||
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, true);
|
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, true);
|
||||||
_render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, 0, false, false, true, false, false);
|
_render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, 0, false, false, true, false, false);
|
||||||
@ -4094,7 +4094,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||||||
bool use_mrt = false;
|
bool use_mrt = false;
|
||||||
|
|
||||||
render_list.clear();
|
render_list.clear();
|
||||||
_fill_render_list(p_cull_result, p_cull_count, false);
|
_fill_render_list(p_cull_result, p_cull_count, false, false);
|
||||||
//
|
//
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@ -4597,10 +4597,8 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo hacer que se redibuje cuando corresponde
|
|
||||||
|
|
||||||
render_list.clear();
|
render_list.clear();
|
||||||
_fill_render_list(p_cull_result, p_cull_count, true);
|
_fill_render_list(p_cull_result, p_cull_count, true, true);
|
||||||
|
|
||||||
render_list.sort_by_depth(false); //shadow is front to back for performance
|
render_list.sort_by_depth(false); //shadow is front to back for performance
|
||||||
|
|
||||||
|
@ -817,9 +817,9 @@ public:
|
|||||||
|
|
||||||
void _render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, GLuint p_base_env, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow, bool p_directional_add, bool p_directional_shadows);
|
void _render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, GLuint p_base_env, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow, bool p_directional_add, bool p_directional_shadows);
|
||||||
|
|
||||||
_FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass);
|
_FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass,bool p_shadow_pass);
|
||||||
|
|
||||||
_FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass);
|
_FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass, bool p_shadow_pass);
|
||||||
|
|
||||||
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 _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy);
|
||||||
|
|
||||||
@ -832,7 +832,7 @@ public:
|
|||||||
void _copy_to_front_buffer(Environment *env);
|
void _copy_to_front_buffer(Environment *env);
|
||||||
void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug
|
void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug
|
||||||
|
|
||||||
void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass);
|
void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass);
|
||||||
|
|
||||||
void _blur_effect_buffer();
|
void _blur_effect_buffer();
|
||||||
void _render_mrts(Environment *env, const CameraMatrix &p_cam_projection);
|
void _render_mrts(Environment *env, const CameraMatrix &p_cam_projection);
|
||||||
|
Loading…
Reference in New Issue
Block a user