summaryrefslogtreecommitdiff
path: root/drivers/gles2/rasterizer_gles2.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-06-29 22:41:02 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-06-29 22:41:02 -0300
commit01632a824ee7e2326aa90b32d75c2fe09f61a37e (patch)
tree86d97af34596130fb69bf444781b7ca8fdc8c20d /drivers/gles2/rasterizer_gles2.cpp
parent97731696c9e45a351d64660b46c6d027f3b0a25e (diff)
Bug Fixes
-=-=-=-=- -Documentation now shows overridable theme values (though this needs to be documented). -Detect when object transform is flipped and flip normals too. -TileMap can specify bounce and friction for collision. -Removed limit of 4 lights per object -Added is_hovered() to buttons.
Diffstat (limited to 'drivers/gles2/rasterizer_gles2.cpp')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp67
1 files changed, 39 insertions, 28 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 681a0e7265..8081d8d995 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -4083,7 +4083,6 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
}
- LightInstance *lights[RenderList::MAX_LIGHTS];
RenderList *render_list=NULL;
@@ -4197,26 +4196,36 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
e->light_type=0x7F; //unshaded is zero
} else {
- //setup lights
- uint16_t light_count=0;
- uint16_t sort_key[4];
- uint8_t light_types[4];
+ bool duplicate=false;
- int dlc = MIN(directional_light_count,RenderList::MAX_LIGHTS);;
- light_count=dlc;
- for(int i=0;i<dlc;i++) {
- sort_key[i]=directional_lights[i]->sort_key;
- light_types[i]=VS::LIGHT_DIRECTIONAL;
+ for(int i=0;i<directional_light_count;i++) {
+ uint16_t sort_key = directional_lights[i]->sort_key;
+ uint8_t light_type = VS::LIGHT_DIRECTIONAL;
if (directional_lights[i]->base->shadow_enabled) {
- light_types[i]|=0x8;
+ light_type|=0x8;
if (directional_lights[i]->base->directional_shadow_mode==VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS)
- light_types[i]|=0x10;
+ light_type|=0x10;
else if (directional_lights[i]->base->directional_shadow_mode==VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS)
- light_types[i]|=0x30;
+ light_type|=0x30;
}
+ RenderList::Element *ec;
+ if (duplicate) {
+
+ ec = render_list->add_element();
+ memcpy(ec,e,sizeof(RenderList::Element));
+ } else {
+
+ ec=e;
+ duplicate=true;
+ }
+
+ ec->light_type=light_type;
+ ec->light=sort_key;
+ ec->additive_ptr=&e->additive;
+
}
@@ -4227,37 +4236,33 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
for(int i=0;i<ilc;i++) {
- if (light_count>=RenderList::MAX_LIGHTS)
- break;
-
LightInstance *li=light_instance_owner.get( liptr[i] );
if (!li || li->last_pass!=scene_pass) //lit by light not in visible scene
continue;
- light_types[light_count]=li->base->type;
+ uint8_t light_type=li->base->type;
if (li->base->shadow_enabled)
- light_types[light_count]|=0x8;
- sort_key[light_count++]=li->sort_key;
-
-
- }
-
- for(int i=0;i<light_count;i++) {
+ light_type|=0x8;
+ uint16_t sort_key =li->sort_key;
RenderList::Element *ec;
- if (i>0) {
+ if (duplicate) {
ec = render_list->add_element();
memcpy(ec,e,sizeof(RenderList::Element));
} else {
+ duplicate=true;
ec=e;
}
- ec->light_type=light_types[i];
- ec->light=sort_key[i];
+ ec->light_type=light_type;
+ ec->light=sort_key;
ec->additive_ptr=&e->additive;
+
}
+
+
}
DEBUG_TEST_ERROR("Add Geometry");
@@ -5548,6 +5553,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
bool stores_glow = !shadow && (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) && !p_alpha_pass;
+
bool prev_blend=false;
glDisable(GL_BLEND);
for (int i=0;i<p_render_list->element_count;i++) {
@@ -5620,6 +5626,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
additive=true;
}
+
if (stores_glow)
material_shader.set_conditional(MaterialShaderGLES2::USE_GLOW,!additive);
@@ -5752,7 +5759,8 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
if (i==0 || light!=prev_light || rebind) {
if (e->light!=0xFFFF) {
- _setup_light(e->light&0x3);
+ _setup_light(e->light);
+
}
}
@@ -5824,6 +5832,9 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_uniform(MaterialShaderGLES2::WORLD_TRANSFORM, e->instance->transform);
}
+ material_shader.set_uniform(MaterialShaderGLES2::NORMAL_MULT, e->mirror?-1.0:1.0);
+
+
_render(e->geometry, material, skeleton,e->owner,e->instance->transform);
DEBUG_TEST_ERROR("Rendering");