diff options
author | Saracen <SaracenOne@gmail.com> | 2016-03-07 23:00:55 +0000 |
---|---|---|
committer | Saracen <SaracenOne@gmail.com> | 2016-03-07 23:14:14 +0000 |
commit | 7fecebd8a8dc12e59c8fd430b9e3dc0069fd48d1 (patch) | |
tree | 668b6cc2cc7787711d3384f2308684bf5fc68e44 /drivers/gles2 | |
parent | 20308c0475acb4678c9b86c7a4f210c1ec7548dc (diff) |
Added extra controls to GeometryInstances to control how they should cast shadows: double-sided and shadows only.
Conflicts:
servers/visual/visual_server_raster.h
Diffstat (limited to 'drivers/gles2')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 13 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 7714a5d17a..7740c9054b 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -4781,9 +4781,12 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD if (has_blend_alpha || (has_base_alpha && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA)) return; //bye - if (m->shader_cache && !m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) { + if (!m->shader_cache || (!m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA)) { //shader does not use discard and does not write a vertex position, use generic material - m = shadow_mat_ptr; + if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) + m = shadow_mat_double_sided_ptr; + else + m = shadow_mat_ptr; if (m->last_pass!=frame) { if (m->shader.is_valid()) { @@ -10961,6 +10964,12 @@ void RasterizerGLES2::init() { shadow_material = material_create(); //empty with nothing shadow_mat_ptr = material_owner.get(shadow_material); + + // Now create a second shadow material for double-sided shadow instances + shadow_material_double_sided = material_create(); + shadow_mat_double_sided_ptr = material_owner.get(shadow_material_double_sided); + shadow_mat_double_sided_ptr->flags[VS::MATERIAL_FLAG_DOUBLE_SIDED] = true; + overdraw_material = create_overdraw_debug_material(); copy_shader.set_conditional(CopyShaderGLES2::USE_8BIT_HDR,!use_fp16_fb); canvas_shader.set_conditional(CanvasShaderGLES2::USE_DEPTH_SHADOWS,read_depth_supported); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 0f70ceaa97..2a2f587f11 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -829,7 +829,9 @@ class RasterizerGLES2 : public Rasterizer { bool fragment_lighting; RID shadow_material; + RID shadow_material_double_sided; Material *shadow_mat_ptr; + Material *shadow_mat_double_sided_ptr; int max_texture_units; GLuint base_framebuffer; |