diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/etc1/rg_etc1.cpp | 2 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 243 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 5 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 8 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.h | 3 | ||||
-rw-r--r-- | drivers/gles2/shaders/canvas.glsl | 88 | ||||
-rw-r--r-- | drivers/trex/trex.c | 2 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.h | 2 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 2 | ||||
-rw-r--r-- | drivers/vorbis/codebook.c | 2 | ||||
-rw-r--r-- | drivers/vorbis/floor1.c | 2 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 11 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.h | 2 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 8 |
15 files changed, 303 insertions, 83 deletions
diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index cad9af8830..63877e6d12 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -2367,7 +2367,7 @@ found_perfect_match: int dr = best_results[1].m_block_color_unscaled.r - best_results[0].m_block_color_unscaled.r;
int dg = best_results[1].m_block_color_unscaled.g - best_results[0].m_block_color_unscaled.g;
int db = best_results[1].m_block_color_unscaled.b - best_results[0].m_block_color_unscaled.b;
- RG_ETC1_ASSERT(best_use_color4 || (rg_etc1::minimum(dr, dg, db) >= cETC1ColorDeltaMin) && (rg_etc1::maximum(dr, dg, db) <= cETC1ColorDeltaMax));
+ RG_ETC1_ASSERT(best_use_color4 || ((rg_etc1::minimum(dr, dg, db) >= cETC1ColorDeltaMin) && (rg_etc1::maximum(dr, dg, db) <= cETC1ColorDeltaMax)));
if (best_use_color4)
{
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index b6444b2978..3660be20db 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -989,8 +989,14 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + else { + if (texture->flags&VS::TEXTURE_FLAG_FILTER) { + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + } else { + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + + } + } if (texture->flags&VS::TEXTURE_FLAG_FILTER) { @@ -1283,8 +1289,14 @@ void RasterizerGLES2::texture_set_flags(RID p_texture,uint32_t p_flags) { if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + else{ + if (texture->flags&VS::TEXTURE_FLAG_FILTER) { + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + } else { + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + + } + } if (texture->flags&VS::TEXTURE_FLAG_FILTER) { @@ -4276,7 +4288,7 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) { void RasterizerGLES2::clear_viewport(const Color& p_color) { - if (current_rt) { + if (current_rt || using_canvas_bg) { glScissor( 0, 0, viewport.width, viewport.height ); } else { @@ -4599,6 +4611,9 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const { if (fragment_flags.uses_texpixel_size) { enablers.push_back("#define USE_TEXPIXEL_SIZE\n"); } + if (light_flags.uses_shadow_color) { + enablers.push_back("#define USE_LIGHT_SHADOW_COLOR\n"); + } if (vertex_flags.uses_worldvec) { enablers.push_back("#define USE_WORLD_VEC\n"); @@ -6932,7 +6947,7 @@ void RasterizerGLES2::_draw_tex_bg() { RID texture; - if (current_env->bg_mode==VS::ENV_BG_TEXTURE || current_env->bg_mode==VS::ENV_BG_TEXTURE_RGBE) { + if (current_env->bg_mode==VS::ENV_BG_TEXTURE) { texture=current_env->bg_param[VS::ENV_BG_PARAM_TEXTURE]; } else { texture=current_env->bg_param[VS::ENV_BG_PARAM_CUBEMAP]; @@ -6949,25 +6964,20 @@ void RasterizerGLES2::_draw_tex_bg() { copy_shader.set_conditional(CopyShaderGLES2::USE_ENERGY,true); - if (current_env->bg_mode==VS::ENV_BG_TEXTURE || current_env->bg_mode==VS::ENV_BG_TEXTURE_RGBE) { + if (current_env->bg_mode==VS::ENV_BG_TEXTURE) { copy_shader.set_conditional(CopyShaderGLES2::USE_CUBEMAP,false); } else { copy_shader.set_conditional(CopyShaderGLES2::USE_CUBEMAP,true); } - if (current_env->bg_mode==VS::ENV_BG_CUBEMAP_RGBE || current_env->bg_mode==VS::ENV_BG_TEXTURE_RGBE) { - copy_shader.set_conditional(CopyShaderGLES2::USE_RGBE,true); - } else { - copy_shader.set_conditional(CopyShaderGLES2::USE_RGBE,false); - } 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) { + if (current_env->bg_mode==VS::ENV_BG_TEXTURE) { glUniform1i( copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE),0); } else { glUniform1i( copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE_CUBE),0); @@ -6994,7 +7004,7 @@ void RasterizerGLES2::_draw_tex_bg() { Vector3( 0, 0, 0) }; - if (current_env->bg_mode==VS::ENV_BG_TEXTURE || current_env->bg_mode==VS::ENV_BG_TEXTURE_RGBE) { + if (current_env->bg_mode==VS::ENV_BG_TEXTURE) { //regular texture //adjust aspect @@ -7064,7 +7074,7 @@ void RasterizerGLES2::end_scene() { if (framebuffer.active) { //detect when to use the framebuffer object - if (texscreen_used || framebuffer.scale!=1) { + if (using_canvas_bg || texscreen_used || framebuffer.scale!=1) { use_fb=true; } else if (current_env) { use_fb=false; @@ -7116,6 +7126,7 @@ void RasterizerGLES2::end_scene() { switch(current_env->bg_mode) { + case VS::ENV_BG_CANVAS: case VS::ENV_BG_KEEP: { //copy from framebuffer if framebuffer glClear(GL_DEPTH_BUFFER_BIT); @@ -7128,7 +7139,7 @@ void RasterizerGLES2::end_scene() { bgcolor = current_env->bg_param[VS::ENV_BG_PARAM_COLOR]; else bgcolor = Globals::get_singleton()->get("render/default_clear_color"); - bgcolor = _convert_color(bgcolor); + bgcolor = _convert_color(bgcolor); float a = use_fb ? float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW]) : 1.0; glClearColor(bgcolor.r,bgcolor.g,bgcolor.b,a); _glClearDepth(1.0); @@ -7136,9 +7147,7 @@ void RasterizerGLES2::end_scene() { } break; case VS::ENV_BG_TEXTURE: - case VS::ENV_BG_CUBEMAP: - case VS::ENV_BG_TEXTURE_RGBE: - case VS::ENV_BG_CUBEMAP_RGBE: { + case VS::ENV_BG_CUBEMAP: { glClear(GL_DEPTH_BUFFER_BIT); @@ -7357,8 +7366,12 @@ void RasterizerGLES2::end_scene() { _debug_shadows(); } // _debug_luminances(); - _debug_samplers(); +// _debug_samplers(); + if (using_canvas_bg) { + using_canvas_bg=false; + glColorMask(1,1,1,1); //don't touch alpha + } } void RasterizerGLES2::end_shadow_map() { @@ -7827,8 +7840,26 @@ void RasterizerGLES2::flush_frame() { /* CANVAS API */ +void RasterizerGLES2::begin_canvas_bg() { + + if (framebuffer.active) { + using_canvas_bg=true; + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); + glViewport( 0,0,viewport.width , viewport.height ); + } else { + using_canvas_bg=false; + } + +} + void RasterizerGLES2::canvas_begin() { + + if (using_canvas_bg) { + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); + glColorMask(1,1,1,0); //don't touch alpha + } + glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -8531,6 +8562,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) { #ifdef GLEW_ENABLED glDrawBuffer(GL_NONE); #endif + } else { // We'll use a RGBA texture into which we pack the depth info glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cls->size, cls->height, 0, @@ -8539,6 +8571,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) { // Attach the RGBA texture to FBO color attachment point glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, cls->depth, 0); + cls->rgba=cls->depth; // Allocate 16-bit depth buffer glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, cls->size, cls->height); @@ -8554,7 +8587,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) { //printf("errnum: %x\n",status); #ifdef GLEW_ENABLED if (read_depth_supported) { - glDrawBuffer(GL_BACK); + //glDrawBuffer(GL_BACK); } #endif glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); @@ -8563,7 +8596,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) { #ifdef GLEW_ENABLED if (read_depth_supported) { - glDrawBuffer(GL_BACK); + //glDrawBuffer(GL_BACK); } #endif @@ -8817,10 +8850,14 @@ void RasterizerGLES2::canvas_debug_viewport_shadows(CanvasLight* p_lights_with_s int h = 10; int w = viewport.width; int ofs = h; + + //print_line(" debug lights "); while(light) { + // print_line("debug light"); if (light->shadow_buffer.is_valid()) { + // print_line("sb is valid"); CanvasLightShadow * sb = canvas_light_shadow_owner.get(light->shadow_buffer); if (sb) { glActiveTexture(GL_TEXTURE0); @@ -9099,8 +9136,11 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_use_modulate=p_modulate!=Color(1,1,1,1); canvas_modulate=p_modulate; canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE,canvas_use_modulate); + canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD,false); + bool reset_modulate=false; + bool prev_distance_field=false; while(p_item_list) { @@ -9116,12 +9156,22 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_use_modulate=p_modulate!=Color(1,1,1,1); canvas_modulate=p_modulate; canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE,canvas_use_modulate); + canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD,false); + prev_distance_field=false; rebind_shader=true; reset_modulate=true; } + if (prev_distance_field!=ci->distance_field) { + + canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD,ci->distance_field); + prev_distance_field=ci->distance_field; + rebind_shader=true; + } + + if (current_clip!=ci->final_clip_owner) { current_clip=ci->final_clip_owner; @@ -9138,6 +9188,40 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const } } + if (ci->copy_back_buffer && framebuffer.active && framebuffer.scale==1) { + + Rect2 rect; + int x,y,w,h; + + if (ci->copy_back_buffer->full) { + + x = viewport.x; + y = window_size.height-(viewport.height+viewport.y); + w = viewport.width; + h = viewport.height; + } else { + x = viewport.x+ci->copy_back_buffer->screen_rect.pos.x; + y = window_size.height-(viewport.y+ci->copy_back_buffer->screen_rect.pos.y+ci->copy_back_buffer->screen_rect.size.y); + w = ci->copy_back_buffer->screen_rect.size.x; + h = ci->copy_back_buffer->screen_rect.size.y; + } + glActiveTexture(GL_TEXTURE0+max_texture_units-1); + glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color); + +#ifdef GLEW_ENABLED + glReadBuffer(GL_COLOR_ATTACHMENT0); +#endif + glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,w,h); +// if (current_clip) { +// // print_line(" a clip "); +// } + + canvas_texscreen_used=true; + glActiveTexture(GL_TEXTURE0); + } + + + //begin rect CanvasItem *material_owner = ci->material_owner?ci->material_owner:ci; @@ -9179,7 +9263,9 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const _canvas_item_setup_shader_uniforms(material,shader_cache); } - if (material && material->unshaded) { + bool unshaded = material && material->shading_mode==VS::CANVAS_ITEM_SHADING_UNSHADED; + + if (unshaded) { canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE,Color(1,1,1,1)); reset_modulate=true; } else if (reset_modulate) { @@ -9236,13 +9322,15 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_opacity = ci->final_opacity; - _canvas_item_render_commands<false>(ci,current_clip,reclip); - if (canvas_blend_mode==VS::MATERIAL_BLEND_MODE_MIX && p_light && (!material || !material->unshaded)) { + if (unshaded || (p_modulate.a>0.001 && (!material || material->shading_mode!=VS::CANVAS_ITEM_SHADING_ONLY_LIGHT))) + _canvas_item_render_commands<false>(ci,current_clip,reclip); + + if (canvas_blend_mode==VS::MATERIAL_BLEND_MODE_MIX && p_light && !unshaded) { CanvasLight *light = p_light; bool light_used=false; - bool subtract=false; + VS::CanvasLightMode mode=VS::CANVAS_LIGHT_MODE_ADD; while(light) { @@ -9251,21 +9339,28 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const //intersects this light - if (!light_used || subtract!=light->subtract) { + if (!light_used || mode!=light->mode) { - subtract=light->subtract; + mode=light->mode; - if (subtract) { + switch(mode) { - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc(GL_SRC_ALPHA,GL_ONE); + case VS::CANVAS_LIGHT_MODE_ADD: { + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA,GL_ONE); - } else { - - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA,GL_ONE); + } break; + case VS::CANVAS_LIGHT_MODE_SUB: { + glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + } break; + case VS::CANVAS_LIGHT_MODE_MIX: { + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } break; } + } if (!light_used) { @@ -9303,7 +9398,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX,light->light_shader_xform); canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS,light->light_shader_pos); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR,light->color); + canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR,Color(light->color.r*light->energy,light->color.g*light->energy,light->color.b*light->energy,light->color.a)); canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT,light->height); canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_LOCAL_MATRIX,light->xform_cache.affine_inverse()); @@ -9783,9 +9878,9 @@ void RasterizerGLES2::free(const RID& p_rid) { glDeleteFramebuffers(1,&cls->fbo); glDeleteRenderbuffers(1,&cls->rbo); glDeleteTextures(1,&cls->depth); - if (!read_depth_supported) { - glDeleteTextures(1,&cls->rgba); - } + //if (!read_depth_supported) { + // glDeleteTextures(1,&cls->rgba); + //} canvas_light_shadow_owner.free(p_rid); memdelete(cls); @@ -9904,7 +9999,7 @@ bool RasterizerGLES2::ShadowBuffer::init(int p_size,bool p_use_depth) { //printf("errnum: %x\n",status); #ifdef GLEW_ENABLED if (p_use_depth) { - glDrawBuffer(GL_BACK); + //glDrawBuffer(GL_BACK); } #endif glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -9913,7 +10008,7 @@ bool RasterizerGLES2::ShadowBuffer::init(int p_size,bool p_use_depth) { #ifdef GLEW_ENABLED if (p_use_depth) { - glDrawBuffer(GL_BACK); + //glDrawBuffer(GL_BACK); } #endif @@ -10291,6 +10386,62 @@ void RasterizerGLES2::_update_blur_buffer() { } #endif + + +bool RasterizerGLES2::_test_depth_shadow_buffer() { + + + int size=16; + + GLuint fbo; + GLuint rbo; + GLuint depth; + + glActiveTexture(GL_TEXTURE0); + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + // Create a render buffer + glGenRenderbuffers(1, &rbo); + glBindRenderbuffer(GL_RENDERBUFFER, rbo); + + // Create a texture for storing the depth + glGenTextures(1, &depth); + glBindTexture(GL_TEXTURE_2D, depth); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // Remove artifact on the edges of the shadowmap + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + + + // We'll use a depth texture to store the depths in the shadow map + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + +#ifdef GLEW_ENABLED + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +#endif + + // Attach the depth texture to FBO depth attachment point + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_TEXTURE_2D, depth, 0); + + + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + glDeleteFramebuffers(1,&fbo); + glDeleteRenderbuffers(1,&rbo); + glDeleteTextures(1,&depth); + + return status == GL_FRAMEBUFFER_COMPLETE; + +} + void RasterizerGLES2::init() { #ifdef GLEW_ENABLED @@ -10363,7 +10514,7 @@ void RasterizerGLES2::init() { #ifdef GLEW_ENABLED - read_depth_supported=true; + pvr_supported=false; etc_supported=false; use_depth24 =true; @@ -10381,7 +10532,10 @@ void RasterizerGLES2::init() { use_anisotropic_filter=true; float_linear_supported=true; float_supported=true; - use_rgba_shadowmaps=false; + + read_depth_supported=_test_depth_shadow_buffer(); + use_rgba_shadowmaps=!read_depth_supported; + //print_line("read depth support? "+itos(read_depth_supported)); glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&anisotropic_level); anisotropic_level=MIN(anisotropic_level,float(GLOBAL_DEF("rasterizer/anisotropic_filter_level",4.0))); @@ -10504,6 +10658,7 @@ void RasterizerGLES2::init() { shadow_mat_ptr = material_owner.get(shadow_material); 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); canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP,GLOBAL_DEF("rasterizer/use_pixel_snap",false)); @@ -10521,7 +10676,7 @@ void RasterizerGLES2::init() { glBindBuffer(GL_ARRAY_BUFFER,0); //unbind - + using_canvas_bg=false; _update_framebuffer(); DEBUG_TEST_ERROR("Initializing"); } diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index f09714f50c..ad18c8e7a1 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -677,6 +677,7 @@ class RasterizerGLES2 : public Rasterizer { bg_param[VS::ENV_BG_PARAM_ENERGY]=1.0; bg_param[VS::ENV_BG_PARAM_SCALE]=1.0; bg_param[VS::ENV_BG_PARAM_GLOW]=0.0; + bg_param[VS::ENV_BG_PARAM_CANVAS_MAX_LAYER]=0; for(int i=0;i<VS::ENV_FX_MAX;i++) fx_enabled[i]=false; @@ -1258,6 +1259,7 @@ class RasterizerGLES2 : public Rasterizer { void _process_hdr(); void _draw_tex_bg(); + bool using_canvas_bg; Size2 window_size; VS::ViewportRect viewport; double last_time; @@ -1286,6 +1288,7 @@ class RasterizerGLES2 : public Rasterizer { void _copy_screen_quad(); void _copy_to_texscreen(); + bool _test_depth_shadow_buffer(); Vector3 chunk_vertex; Vector3 chunk_normal; @@ -1600,6 +1603,8 @@ public: /* CANVAS API */ + virtual void begin_canvas_bg(); + virtual void canvas_begin(); virtual void canvas_disable_blending(); diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 8d378ceec1..69bd269948 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -266,6 +266,9 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a uses_normal=true; } + if (vnode->name==vname_shadow) { + uses_shadow_color=true; + } } @@ -616,6 +619,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT uses_texpixel_size=false; uses_worldvec=false; vertex_code_writes_vertex=false; + uses_shadow_color=false; uniforms=r_uniforms; flags=&r_flags; r_flags.use_color_interp=false; @@ -651,6 +655,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT r_flags.uses_normal=uses_normal; r_flags.uses_texpixel_size=uses_texpixel_size; r_flags.uses_worldvec=uses_worldvec; + r_flags.uses_shadow_color=uses_shadow_color; r_code_line=code; r_globals_line=global_code; @@ -827,7 +832,9 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { mode_replace_table[5]["LIGHT_VEC"]="light_vec"; mode_replace_table[5]["LIGHT_HEIGHT"]="light_height"; mode_replace_table[5]["LIGHT_COLOR"]="light"; + mode_replace_table[5]["LIGHT_UV"]="light_uv"; mode_replace_table[5]["LIGHT"]="light_out"; + mode_replace_table[5]["SHADOW"]="shadow_color"; mode_replace_table[5]["SCREEN_UV"]="screen_uv"; mode_replace_table[5]["POINT_COORD"]="gl_PointCoord"; mode_replace_table[5]["TIME"]="time"; @@ -857,5 +864,6 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { vname_normal="NORMAL"; vname_texpixel_size="TEXTURE_PIXEL_SIZE"; vname_world_vec="WORLD_VERTEX"; + vname_shadow="SHADOW"; } diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h index 87722602fd..87016fd968 100644 --- a/drivers/gles2/shader_compiler_gles2.h +++ b/drivers/gles2/shader_compiler_gles2.h @@ -55,6 +55,7 @@ private: bool uses_texpixel_size; bool uses_worldvec; bool vertex_code_writes_vertex; + bool uses_shadow_color; Flags *flags; StringName vname_discard; @@ -74,6 +75,7 @@ private: StringName vname_normal; StringName vname_texpixel_size; StringName vname_world_vec; + StringName vname_shadow; Map<StringName,ShaderLanguage::Uniform> *uniforms; @@ -110,6 +112,7 @@ public: bool uses_normal; bool uses_texpixel_size; bool uses_worldvec; + bool uses_shadow_color; }; Error compile(const String& p_code, ShaderLanguage::ShaderType p_type, String& r_code_line, String& r_globals_line, Flags& r_flags, Map<StringName,ShaderLanguage::Uniform> *r_uniforms=NULL); diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 0e19736fd5..c4f0847870 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -36,7 +36,7 @@ uniform vec2 normal_flip; #endif #ifdef USE_SHADOWS -highp varying vec2 pos; +varying highp vec2 pos; #endif #endif @@ -161,11 +161,11 @@ varying vec4 local_rot; #ifdef USE_SHADOWS -uniform sampler2D shadow_texture; +uniform highp sampler2D shadow_texture; uniform float shadow_attenuation; uniform highp mat4 shadow_matrix; -highp varying vec2 pos; +varying highp vec2 pos; uniform float shadowpixel_size; #ifdef SHADOW_ESM @@ -191,8 +191,16 @@ void main() { vec3 normal = vec3(0.0,0.0,1.0); #endif - +#ifdef USE_DISTANCE_FIELD + const float smoothing = 1.0/32.0; + float distance = texture2D(texture, uv_interp).a; + color.a = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance); +#else color *= texture2D( texture, uv_interp ); + +#endif + + #if defined(ENABLE_SCREEN_UV) vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult; #endif @@ -222,12 +230,16 @@ FRAGMENT_SHADER_CODE float att=1.0; - vec4 light = texture2D(light_texture,light_uv_interp.xy) * light_color; + vec2 light_uv = light_uv_interp.xy; + vec4 light = texture2D(light_texture,light_uv) * light_color; +#if defined(USE_LIGHT_SHADOW_COLOR) + vec4 shadow_color=vec4(0.0,0.0,0.0,0.0); +#endif #if defined(USE_LIGHT_SHADER_CODE) //light is written by the light shader { - vec4 light_out=vec4(0.0,0.0,0.0,0.0); + vec4 light_out=light*color; LIGHT_SHADER_CODE color=light_out; } @@ -284,39 +296,51 @@ LIGHT_SHADER_CODE } - vec4 s = shadow_matrix * vec4(point,0.0,1.0); + highp vec4 s = shadow_matrix * highp vec4(point,0.0,1.0); s.xyz/=s.w; su=s.x*0.5+0.5; sz=s.z*0.5+0.5; - float shadow_attenuation; + highp float shadow_attenuation=0.0; + +#ifdef USE_DEPTH_SHADOWS + +#define SHADOW_DEPTH(m_tex,m_uv) (texture2D((m_tex),(m_uv)).z) + +#else + +//#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),highp vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) +#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) + +#endif + + #ifdef SHADOW_PCF5 - shadow_attenuation=0.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*2.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*2.0,sh))<sz?0.0:1.0; shadow_attenuation/=5.0; #endif #ifdef SHADOW_PCF13 - shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*2.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*3.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*4.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*5.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*6.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*2.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*3.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*4.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*5.0,sh))<sz?0.0:1.0; + shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*6.0,sh))<sz?0.0:1.0; shadow_attenuation/=13.0; #endif @@ -328,8 +352,8 @@ LIGHT_SHADER_CODE float unnormalized = su/shadowpixel_size; float fractional = fract(unnormalized); unnormalized = floor(unnormalized); - float zc = texture2D(shadow_texture,vec2((unnormalized-0.5)*shadowpixel_size,sh)).z; - float zn = texture2D(shadow_texture,vec2((unnormalized+0.5)*shadowpixel_size,sh)).z; + float zc = SHADOW_DEPTH(shadow_texture,vec2((unnormalized-0.5)*shadowpixel_size,sh)); + float zn = SHADOW_DEPTH(shadow_texture,vec2((unnormalized+0.5)*shadowpixel_size,sh)); float z = mix(zc,zn,fractional); shadow_attenuation=clamp(exp(shadow_esm_multiplier* ( z - sz )),0.0,1.0); } @@ -338,11 +362,15 @@ LIGHT_SHADER_CODE #if !defined(SHADOW_PCF5) && !defined(SHADOW_PCF13) && !defined(SHADOW_ESM) - shadow_attenuation = texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; + shadow_attenuation = SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; #endif - color.rgb*=shadow_attenuation; +#if defined(USE_LIGHT_SHADOW_COLOR) + color=mix(shadow_color,color,shadow_attenuation); +#else + color*=shadow_attenuation; +#endif //use shadows #endif } diff --git a/drivers/trex/trex.c b/drivers/trex/trex.c index e63a248e9e..b3668c3a11 100644 --- a/drivers/trex/trex.c +++ b/drivers/trex/trex.c @@ -489,7 +489,7 @@ static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *s return cur;
}
case OP_WB:
- if(str == exp->_bol && !isspace(*str)
+ if((str == exp->_bol && !isspace(*str))
|| (str == exp->_eol && !isspace(*(str-1)))
|| (!isspace(*str) && isspace(*(str+1)))
|| (isspace(*str) && !isspace(*(str+1))) ) {
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 452d791d96..5f51865432 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -161,6 +161,7 @@ String DirAccessUnix::get_next() { } + _cishidden=(fname!="." && fname!=".." && fname.begins_with(".")); @@ -173,6 +174,11 @@ bool DirAccessUnix::current_is_dir() const { return _cisdir; } +bool DirAccessUnix::current_is_hidden() const { + + return _cishidden; +} + void DirAccessUnix::list_dir_end() { diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 119cb5c3f4..f6089ccfe1 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -50,12 +50,14 @@ class DirAccessUnix : public DirAccess { String current_dir; bool _cisdir; + bool _cishidden; public: virtual bool list_dir_begin(); ///< This starts dir listing virtual String get_next(); virtual bool current_is_dir() const; + virtual bool current_is_hidden() const; virtual void list_dir_end(); ///< diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 7f85526852..2f91eee90e 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -74,7 +74,7 @@ Error FileAccessUnix::_open(const String& p_path, int p_mode_flags) { else if (p_mode_flags==WRITE) mode_string="wb"; else if (p_mode_flags==READ_WRITE) - mode_string="wb+"; + mode_string="rb+"; else return ERR_INVALID_PARAMETER; diff --git a/drivers/vorbis/codebook.c b/drivers/vorbis/codebook.c index 759d7b4254..8a928cebb9 100644 --- a/drivers/vorbis/codebook.c +++ b/drivers/vorbis/codebook.c @@ -248,7 +248,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ } /* quantized values */ - if((quantvals*s->q_quant+7>>3)>opb->storage-oggpack_bytes(opb)) + if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb)) goto _eofout; s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals); for(i=0;i<quantvals;i++) diff --git a/drivers/vorbis/floor1.c b/drivers/vorbis/floor1.c index 9f3154a6a3..ae3dcedb1f 100644 --- a/drivers/vorbis/floor1.c +++ b/drivers/vorbis/floor1.c @@ -1035,7 +1035,7 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){ } } - fit_value[i]=val+predicted&0x7fff; + fit_value[i]=(val+predicted)&0x7fff; fit_value[look->loneighbor[i-2]]&=0x7fff; fit_value[look->hineighbor[i-2]]&=0x7fff; diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index d1e9766105..4c265a1ab2 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -68,6 +68,7 @@ struct DirAccessWindowsPrivate { bool DirAccessWindows::list_dir_begin() { _cisdir=false; + _cishidden=false; if (unicode) { list_dir_end(); @@ -95,6 +96,8 @@ String DirAccessWindows::get_next() { if (unicode) { _cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); + _cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); + String name=p->fu.cFileName; if (FindNextFileW(p->h, &p->fu) == 0) { @@ -108,6 +111,7 @@ String DirAccessWindows::get_next() { #ifndef WINRT_ENABLED _cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); + _cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); String name=p->f.cFileName; @@ -128,6 +132,11 @@ bool DirAccessWindows::current_is_dir() const { return _cisdir; } +bool DirAccessWindows::current_is_hidden() const { + + return _cishidden; +} + void DirAccessWindows::list_dir_end() { if (p->h!=INVALID_HANDLE_VALUE) { @@ -270,7 +279,7 @@ Error DirAccessWindows::make_dir(String p_dir) { return OK; }; - if (err == ERROR_ALREADY_EXISTS) { + if (err == ERROR_ALREADY_EXISTS || err == ERROR_ACCESS_DENIED) { return ERR_ALREADY_EXISTS; }; diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index 36530ba9b3..4a668a7364 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -58,12 +58,14 @@ class DirAccessWindows : public DirAccess { bool unicode; bool _cisdir; + bool _cishidden; public: virtual bool list_dir_begin(); ///< This starts dir listing virtual String get_next(); virtual bool current_is_dir() const; + virtual bool current_is_hidden() const; virtual void list_dir_end(); ///< virtual int get_drive_count(); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index e24685432c..19a62967ea 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -28,8 +28,10 @@ /*************************************************************************/ #ifdef WINDOWS_ENABLED -#include <Windows.h> -#include "Shlwapi.h" +#define WINVER 0x0500 + +#include <windows.h> +#include "shlwapi.h" #include "file_access_windows.h" @@ -69,7 +71,7 @@ Error FileAccessWindows::_open(const String& p_filename, int p_mode_flags) { else if (p_mode_flags==WRITE) mode_string=L"wb"; else if (p_mode_flags==READ_WRITE) - mode_string=L"wb+"; + mode_string=L"rb+"; else return ERR_INVALID_PARAMETER; |