diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-07-02 00:09:36 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-07-02 00:09:36 -0300 |
commit | e9da61411a6f1c993d528b659ebb3e5147aa44cc (patch) | |
tree | 9aec099f021920e3c61835f1152616e2a8194351 /drivers | |
parent | 77a15e2a3e1231bf9ba011af9ee10afe5fae17dd (diff) |
Fixed Bugs & Joypad in Android
================================
-resolved many graphical glitches with multiple lights in GLES2 render
-fixes and WIP apk expansion
-joystick support for Android by Ariel
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 16 | ||||
-rw-r--r-- | drivers/gles2/shaders/material.glsl | 30 |
2 files changed, 36 insertions, 10 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 8081d8d995..dd690435ec 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -4239,9 +4239,10 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD LightInstance *li=light_instance_owner.get( liptr[i] ); if (!li || li->last_pass!=scene_pass) //lit by light not in visible scene continue; - uint8_t light_type=li->base->type; - if (li->base->shadow_enabled) + uint8_t light_type=li->base->type|0x40; //penalty to ensure directionals always go first + if (li->base->shadow_enabled) { light_type|=0x8; + } uint16_t sort_key =li->sort_key; RenderList::Element *ec; @@ -4598,7 +4599,7 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material material_shader.set_uniform(MaterialShaderGLES2::FOG_COLOR_END,Vector3(col_end.r,col_end.g,col_end.b)); } - material_shader.set_uniform(MaterialShaderGLES2::CONST_LIGHT_MULT,p_no_const_light?0.0:1.0); + //material_shader.set_uniform(MaterialShaderGLES2::TIME,Math::fmod(last_time,300.0)); //if uses TIME - draw_next_frame=true @@ -5668,7 +5669,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans case VS::MATERIAL_BLEND_MODE_ADD: { glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA,GL_ONE); + glBlendFunc(p_alpha_pass?GL_SRC_ALPHA:GL_ONE,GL_ONE); } break; case VS::MATERIAL_BLEND_MODE_SUB: { @@ -5833,7 +5834,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans } material_shader.set_uniform(MaterialShaderGLES2::NORMAL_MULT, e->mirror?-1.0:1.0); - + material_shader.set_uniform(MaterialShaderGLES2::CONST_LIGHT_MULT,additive?0.0:1.0); _render(e->geometry, material, skeleton,e->owner,e->instance->transform); @@ -6097,6 +6098,9 @@ void RasterizerGLES2::_draw_tex_bg() { glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); + glDisable(GL_BLEND); + glColorMask(1,1,1,1); + RID texture; @@ -6132,6 +6136,7 @@ void RasterizerGLES2::_draw_tex_bg() { copy_shader.set_conditional(CopyShaderGLES2::USE_CUSTOM_ALPHA,true); + copy_shader.bind(); if (current_env->bg_mode==VS::ENV_BG_TEXTURE || current_env->bg_mode==VS::ENV_BG_TEXTURE_RGBE) { @@ -6350,6 +6355,7 @@ void RasterizerGLES2::end_scene() { _render_list_forward(&opaque_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting); if (draw_tex_background) { + //most 3D vendors recommend drawing a texture bg or skybox here, //after opaque geometry has been drawn //so the zbuffer can get rid of most pixels diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index b667e9176c..17365ea264 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -1060,7 +1060,19 @@ LIGHT_SHADER_CODE light+=specular * light_specular * pow( eye_light, specular_exp ); } #endif - diffuse.rgb = ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation; + diffuse.rgb = const_light_mult * ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation; + +#ifdef USE_FOG + + diffuse.rgb = mix(diffuse.rgb,fog_interp.rgb,fog_interp.a); + +# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) + diffuse.rgb = mix(mix(vec3(0.0),diffuse.rgb,attenuation),diffuse.rgb,const_light_mult); +# endif + + +#endif + } @@ -1084,9 +1096,10 @@ LIGHT_SHADER_CODE #ifdef USE_VERTEX_LIGHTING - vec3 ambient = ambient_light*diffuse.rgb; + vec3 ambient = const_light_mult*ambient_light*diffuse.rgb; # if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) ambient*=diffuse_interp.a; //attenuation affects ambient too + # endif // diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient; @@ -1094,6 +1107,16 @@ LIGHT_SHADER_CODE diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient; diffuse.rgb+=emission * const_light_mult; +#ifdef USE_FOG + + diffuse.rgb = mix(diffuse.rgb,fog_interp.rgb,fog_interp.a); + +# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) + diffuse.rgb = mix(mix(vec3(0.0),diffuse.rgb,diffuse_interp.a),diffuse.rgb,const_light_mult); +# endif + +#endif + #endif @@ -1120,10 +1143,7 @@ LIGHT_SHADER_CODE #else -#ifdef USE_FOG - diffuse.rgb = mix(diffuse.rgb,fog_interp.rgb,fog_interp.a); -#endif #ifdef USE_GLOW |