diff options
Diffstat (limited to 'drivers/gles3/rasterizer_storage_gles3.cpp')
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 122 |
1 files changed, 102 insertions, 20 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 06daebbf82..cec41aa251 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1,7 +1,7 @@ #include "rasterizer_storage_gles3.h" #include "rasterizer_canvas_gles3.h" #include "rasterizer_scene_gles3.h" -#include "globals.h" +#include "global_config.h" /* TEXTURE API */ @@ -93,16 +93,26 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima switch(p_format) { case Image::FORMAT_L8: { +#ifdef GLES_OVER_GL r_gl_internal_format=GL_R8; r_gl_format=GL_RED; r_gl_type=GL_UNSIGNED_BYTE; - +#else + r_gl_internal_format=GL_LUMINANCE; + r_gl_format=GL_LUMINANCE; + r_gl_type=GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_LA8: { - +#ifdef GLES_OVER_GL r_gl_internal_format=GL_RG8; r_gl_format=GL_RG; r_gl_type=GL_UNSIGNED_BYTE; +#else + r_gl_internal_format=GL_LUMINANCE_ALPHA; + r_gl_format=GL_LUMINANCE_ALPHA; + r_gl_type=GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_R8: { @@ -734,6 +744,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image } //set swizle for older format compatibility +#ifdef GLES_OVER_GL switch(texture->format) { case Image::FORMAT_L8: { @@ -759,6 +770,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image } break; } +#endif if (config.use_anisotropic_filter) { if (texture->flags&VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) { @@ -1096,7 +1108,7 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_r ERR_FAIL_COND_V(!texture,RID()); ERR_FAIL_COND_V(!(texture->flags&VS::TEXTURE_FLAG_CUBEMAP),RID()); - bool use_float=true; + bool use_float=config.hdr_supported; if (p_resolution<0) { p_resolution=texture->width; @@ -1316,7 +1328,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in int mm_level=mipmaps; - bool use_float=true; + bool use_float=config.hdr_supported; GLenum internal_format = use_float?GL_RGBA16F:GL_RGB10_A2; GLenum format = GL_RGBA; @@ -2320,6 +2332,7 @@ void RasterizerStorageGLES3::_update_material(Material* material) { bool is_animated = false; if (material->shader && material->shader->mode==VS::SHADER_SPATIAL) { + if (!material->shader->spatial.uses_alpha && material->shader->spatial.blend_mode==Shader::Spatial::BLEND_MODE_MIX) { can_cast_shadow=true; } @@ -2332,20 +2345,19 @@ void RasterizerStorageGLES3::_update_material(Material* material) { is_animated=true; } - } + if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) { + material->can_cast_shadow_cache=can_cast_shadow; + material->is_animated_cache=is_animated; - if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) { - material->can_cast_shadow_cache=can_cast_shadow; - material->is_animated_cache=is_animated; + for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) { + E->key()->material_changed_notify(); + } - for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) { - E->key()->material_changed_notify(); - } + for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) { + E->key()->base_material_changed(); + } - for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) { - E->key()->base_material_changed(); } - } } @@ -3619,8 +3631,23 @@ void RasterizerStorageGLES3::multimesh_set_mesh(RID p_multimesh,RID p_mesh){ MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.remove(&multimesh->mesh_list); + } + } + multimesh->mesh=p_mesh; + + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.add(&multimesh->mesh_list); + } + } + multimesh->dirty_aabb=true; if (!multimesh->update_list.in_list()) { @@ -4778,6 +4805,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { gip->dynamic_range=1.0; gip->energy=1.0; gip->propagation=1.0; + gip->bias=0.4; gip->interior=false; gip->compress=false; gip->version=1; @@ -4883,6 +4911,16 @@ void RasterizerStorageGLES3::gi_probe_set_energy(RID p_probe,float p_range){ } + +void RasterizerStorageGLES3::gi_probe_set_bias(RID p_probe,float p_range){ + + GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND(!gip); + + gip->bias=p_range; + +} + void RasterizerStorageGLES3::gi_probe_set_propagation(RID p_probe,float p_range){ GIProbe *gip = gi_probe_owner.getornull(p_probe); @@ -4936,6 +4974,15 @@ float RasterizerStorageGLES3::gi_probe_get_energy(RID p_probe) const{ return gip->energy; } +float RasterizerStorageGLES3::gi_probe_get_bias(RID p_probe) const{ + + const GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND_V(!gip,0); + + return gip->bias; +} + + float RasterizerStorageGLES3::gi_probe_get_propagation(RID p_probe) const{ const GIProbe *gip = gi_probe_owner.getornull(p_probe); @@ -5535,9 +5582,10 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ GLuint color_type; Image::Format image_format; + bool hdr = rt->flags[RENDER_TARGET_HDR] && config.hdr_supported; + hdr=false; - - if (!rt->flags[RENDER_TARGET_HDR] || rt->flags[RENDER_TARGET_NO_3D]) { + if (!hdr || rt->flags[RENDER_TARGET_NO_3D]) { color_internal_format=GL_RGBA8; color_format=GL_RGBA; @@ -5562,7 +5610,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ glGenTextures(1, &rt->depth); glBindTexture(GL_TEXTURE_2D, rt->depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, rt->width, rt->height, 0, + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -5586,6 +5634,10 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); + if (status != GL_FRAMEBUFFER_COMPLETE) { + printf("framebuffer fail, status: %x\n",status); + } + ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE ); Texture *tex = texture_owner.get(rt->texture); @@ -5633,7 +5685,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ if (msaa==0) glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height); else - glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,GL_RGBA16F,rt->width,rt->height); + glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER,rt->buffers.diffuse); @@ -5641,7 +5693,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ glBindRenderbuffer(GL_RENDERBUFFER, rt->buffers.specular); if (msaa==0) - glRenderbufferStorage(GL_RENDERBUFFER,GL_RGBA16F,rt->width,rt->height); + glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height); else glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height); @@ -6265,6 +6317,18 @@ bool RasterizerStorageGLES3::free(RID p_rid){ mesh->instance_remove_deps(); mesh_clear(p_rid); + while(mesh->multimeshes.first()) { + MultiMesh *multimesh = mesh->multimeshes.first()->self(); + multimesh->mesh=RID(); + multimesh->dirty_aabb=true; + mesh->multimeshes.remove(mesh->multimeshes.first()); + + if (!multimesh->update_list.in_list()) { + multimesh_update_list.add(&multimesh->update_list); + } + + } + mesh_owner.free(p_rid); memdelete(mesh); @@ -6274,9 +6338,17 @@ bool RasterizerStorageGLES3::free(RID p_rid){ MultiMesh *multimesh = multimesh_owner.get(p_rid); multimesh->instance_remove_deps(); + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.remove(&multimesh->mesh_list); + } + } + multimesh_allocate(p_rid,0,VS::MULTIMESH_TRANSFORM_2D,VS::MULTIMESH_COLOR_NONE); //frees multimesh update_dirty_multimeshes(); + multimesh_owner.free(p_rid); memdelete(multimesh); } else if (immediate_owner.owns(p_rid)) { @@ -6405,9 +6477,11 @@ void RasterizerStorageGLES3::initialize() { config.latc_supported=config.extensions.has("GL_EXT_texture_compression_latc"); config.bptc_supported=config.extensions.has("GL_ARB_texture_compression_bptc"); #ifdef GLES_OVER_GL + config.hdr_supported=true; config.etc2_supported=false; #else config.etc2_supported=true; + config.hdr_supported=false; #endif config.pvrtc_supported=config.extensions.has("GL_IMG_texture_compression_pvrtc"); config.srgb_decode_supported=config.extensions.has("GL_EXT_texture_sRGB_decode"); @@ -6568,6 +6642,14 @@ void RasterizerStorageGLES3::finalize() { } +void RasterizerStorageGLES3::update_dirty_resources() { + + update_dirty_multimeshes(); + update_dirty_skeletons(); + update_dirty_shaders(); + update_dirty_materials(); + update_particles(); +} RasterizerStorageGLES3::RasterizerStorageGLES3() { |