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.
This commit is contained in:
@ -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");
|
||||
|
||||
@ -781,9 +781,22 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
bool *additive_ptr;
|
||||
bool additive;
|
||||
bool mirror;
|
||||
uint16_t light;
|
||||
uint8_t light_type;
|
||||
uint8_t sort_flags;
|
||||
union {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
struct {
|
||||
uint8_t sort_flags;
|
||||
uint8_t light_type;
|
||||
uint16_t light;
|
||||
};
|
||||
#else
|
||||
struct {
|
||||
uint16_t light;
|
||||
uint8_t light_type;
|
||||
uint8_t sort_flags;
|
||||
};
|
||||
#endif
|
||||
uint32_t sort_key;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -896,27 +909,22 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const Element* A, const Element* B ) const {
|
||||
|
||||
if (A->sort_flags == B->sort_flags) {
|
||||
if (A->light_type == B->light_type) {
|
||||
if (A->material->shader_cache == B->material->shader_cache) {
|
||||
if (A->material == B->material) {
|
||||
if (A->sort_key == B->sort_key) {
|
||||
if (A->material->shader_cache == B->material->shader_cache) {
|
||||
if (A->material == B->material) {
|
||||
|
||||
return (A->geometry_cmp < B->geometry_cmp);
|
||||
} else {
|
||||
|
||||
return (A->material < B->material);
|
||||
}
|
||||
return (A->geometry_cmp < B->geometry_cmp);
|
||||
} else {
|
||||
|
||||
return (A->material->shader_cache < B->material->shader_cache);
|
||||
return (A->material < B->material);
|
||||
}
|
||||
} else {
|
||||
|
||||
return A->light_type < B->light_type;
|
||||
return (A->material->shader_cache < B->material->shader_cache);
|
||||
}
|
||||
} else {
|
||||
|
||||
return A->sort_flags < B->sort_flags; //one is null and one is not
|
||||
return A->sort_key < B->sort_key; //one is null and one is not
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -31,6 +31,8 @@ attribute vec4 color_attrib; // attrib:3
|
||||
attribute vec2 uv_attrib; // attrib:4
|
||||
attribute vec2 uv2_attrib; // attrib:5
|
||||
|
||||
uniform float normal_mult;
|
||||
|
||||
#ifdef USE_SKELETON
|
||||
attribute vec4 bone_indices; // attrib:6
|
||||
attribute vec4 bone_weights; // attrib:7
|
||||
@ -232,8 +234,10 @@ void main() {
|
||||
#endif
|
||||
highp vec4 vertex_in = vertex_attrib; // vec4(vertex_attrib.xyz * data_attrib.x,1.0);
|
||||
vec3 normal_in = normal_attrib;
|
||||
normal_in*=normal_mult;
|
||||
#if defined(ENABLE_TANGENT_INTERP)
|
||||
vec3 tangent_in = tangent_attrib.xyz;
|
||||
tangent_in*=normal_mult;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SKELETON
|
||||
|
||||
Reference in New Issue
Block a user