diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/SCsub | 5 | ||||
-rw-r--r-- | drivers/gl_context/context_gl.cpp | 2 | ||||
-rw-r--r-- | drivers/gl_context/context_gl.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 63 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 39 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 136 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.h | 48 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 4 |
8 files changed, 133 insertions, 166 deletions
diff --git a/drivers/SCsub b/drivers/SCsub index 34d6254578..938927f3a9 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -34,7 +34,12 @@ if env['tools']: SConscript("convex_decomp/SCsub") if env['vsproj']: + import os + path = os.getcwd() + # Change directory so the path resolves correctly in the function call. + os.chdir("..") env.AddToVSProject(env.drivers_sources) + os.chdir(path) if env.split_drivers: env.split_lib("drivers") diff --git a/drivers/gl_context/context_gl.cpp b/drivers/gl_context/context_gl.cpp index a453eef227..1581512369 100644 --- a/drivers/gl_context/context_gl.cpp +++ b/drivers/gl_context/context_gl.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "context_gl.h" -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) ContextGL *ContextGL::singleton = NULL; diff --git a/drivers/gl_context/context_gl.h b/drivers/gl_context/context_gl.h index 399657eb52..3496f2948c 100644 --- a/drivers/gl_context/context_gl.h +++ b/drivers/gl_context/context_gl.h @@ -30,7 +30,7 @@ #ifndef CONTEXT_GL_H #define CONTEXT_GL_H -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) #include "typedefs.h" diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 5d62d2f5a0..308a18aa9d 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -149,13 +149,6 @@ void RasterizerCanvasGLES3::canvas_begin() { storage->frame.clear_request = false; } - /*canvas_shader.unbind(); - canvas_shader.set_custom_shader(0); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE,false); - canvas_shader.bind(); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0); - canvas_use_modulate=false;*/ - reset_canvas(); state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_TEXTURE_RECT, true); @@ -911,61 +904,6 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur } } -#if 0 -void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material,Shader* shader) { - - if (canvas_shader.bind()) - rebind_texpixel_size=true; - - if (material->shader_version!=shader->version) { - //todo optimize uniforms - material->shader_version=shader->version; - } - - if (shader->has_texscreen && framebuffer.active) { - - int x = viewport.x; - int y = window_size.height-(viewport.height+viewport.y); - - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX,max_texture_units-1); - glActiveTexture(GL_TEXTURE0+max_texture_units-1); - glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color); - if (framebuffer.scale==1 && !canvas_texscreen_used) { -#ifdef GLEW_ENABLED - if (current_rt) { - glReadBuffer(GL_COLOR_ATTACHMENT0); - } else { - glReadBuffer(GL_BACK); - } -#endif - if (current_rt) { - glCopyTexSubImage2D(GL_TEXTURE_2D,0,viewport.x,viewport.y,viewport.x,viewport.y,viewport.width,viewport.height); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(viewport.y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height)); - //window_size.height-(viewport.height+viewport.y) - } else { - glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height); - } - - canvas_texscreen_used=true; - } - - glActiveTexture(GL_TEXTURE0); - - } - - if (shader->has_screen_uv) { - canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_UV_MULT,Vector2(1.0/viewport.width,1.0/viewport.height)); - } - - - uses_texpixel_size=shader->uses_texpixel_size; - -} - -#endif - void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { glDisable(GL_BLEND); @@ -1570,6 +1508,7 @@ void RasterizerCanvasGLES3::reset_canvas() { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); + glDisable(GL_DITHER); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 220a3533b7..ee61481a86 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -141,28 +141,22 @@ void RasterizerGLES3::initialize() { print_line("Using GLES3 video driver"); } -#ifdef GLEW_ENABLED - GLuint res = glewInit(); - ERR_FAIL_COND(res != GLEW_OK); - if (OS::get_singleton()->is_stdout_verbose()) { - print_line(String("GLES2: Using GLEW ") + (const char *)glewGetString(GLEW_VERSION)); +#ifdef GLAD_ENABLED + if (!gladLoadGL()) { + ERR_PRINT("Error initializing GLAD"); } - // Check for GL 2.1 compatibility, if not bail out - if (!glewIsSupported("GL_VERSION_3_0")) { - ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n" +// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them +#ifdef OPENGL_ENABLED // OpenGL 3.3 Core Profile required + if (GLVersion.major < 3 && GLVersion.minor < 3) { +#else // OpenGL ES 3.0 + if (GLVersion.major < 3) { +#endif + ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n" "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault."); - OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n" + OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n" "Godot Engine will self-destruct as soon as you acknowledge this error message.", - "Fatal error: Insufficient OpenGL / GLES drivers"); - // TODO: If it's even possible, we should stop the execution without segfault and memory leaks :) - } -#endif - -#ifdef GLAD_ENABLED - - if (!gladLoadGL()) { - ERR_PRINT("Error initializing GLAD"); + "Fatal error: Insufficient OpenGL / GLES driver support"); } #ifdef __APPLE__ @@ -175,21 +169,20 @@ void RasterizerGLES3::initialize() { } #endif -#endif +#endif // GLAD_ENABLED - /* glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); + /* // For debugging + glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PORTABILITY_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PERFORMANCE_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_OTHER_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageInsertARB( - GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, 1, GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello"); - -*/ + */ const GLubyte *renderer = glGetString(GL_RENDERER); print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer)); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 296d945cda..004c628252 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2600,7 +2600,7 @@ RID RasterizerStorageGLES3::mesh_create() { return mesh_owner.make_rid(mesh); } -void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) { +void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { PoolVector<uint8_t> array = p_array; @@ -2866,7 +2866,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: glGenBuffers(1, &surface->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); - glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind if (p_format & VS::ARRAY_FORMAT_INDEX) { @@ -3104,6 +3104,22 @@ VS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh) return mesh->blend_shape_mode; } +void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) { + + Mesh *mesh = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!mesh); + ERR_FAIL_INDEX(p_surface, mesh->surfaces.size()); + + int total_size = p_data.size(); + ERR_FAIL_COND(p_offset + total_size > mesh->surfaces[p_surface]->array_byte_size); + + PoolVector<uint8_t>::Read r = p_data.read(); + + glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->array_id); + glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr()); + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind +} + void RasterizerStorageGLES3::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) { Mesh *mesh = mesh_owner.getornull(p_mesh); @@ -3224,11 +3240,11 @@ VS::PrimitiveType RasterizerStorageGLES3::mesh_surface_get_primitive_type(RID p_ return mesh->surfaces[p_surface]->primitive; } -Rect3 RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { +AABB RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), AABB()); return mesh->surfaces[p_surface]->aabb; } @@ -3263,11 +3279,11 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap return bsarr; } -Vector<Rect3> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { +Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Vector<Rect3>()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Rect3>()); + ERR_FAIL_COND_V(!mesh, Vector<AABB>()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<AABB>()); return mesh->surfaces[p_surface]->skeleton_bone_aabb; } @@ -3321,7 +3337,7 @@ int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const { return mesh->surfaces.size(); } -void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -3329,37 +3345,37 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aab mesh->custom_aabb = p_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { +AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); return mesh->custom_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { +AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); - if (mesh->custom_aabb != Rect3()) + if (mesh->custom_aabb != AABB()) return mesh->custom_aabb; Skeleton *sk = NULL; if (p_skeleton.is_valid()) sk = skeleton_owner.get(p_skeleton); - Rect3 aabb; + AABB aabb; if (sk && sk->size != 0) { for (int i = 0; i < mesh->surfaces.size(); i++) { - Rect3 laabb; + AABB laabb; if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); - const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); + const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr(); int sbs = sk->size; @@ -3385,7 +3401,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[1].y = texture[base_ofs + 1]; mtx.origin.y = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -3418,7 +3434,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[2].z = texture[base_ofs + 2]; mtx.origin.z = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -4012,10 +4028,10 @@ int RasterizerStorageGLES3::multimesh_get_visible_instances(RID p_multimesh) con return multimesh->visible_instances; } -Rect3 RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { +AABB RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); - ERR_FAIL_COND_V(!multimesh, Rect3()); + ERR_FAIL_COND_V(!multimesh, AABB()); const_cast<RasterizerStorageGLES3 *>(this)->update_dirty_multimeshes(); //update pending AABBs @@ -4037,7 +4053,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { if (multimesh->size && multimesh->dirty_aabb) { - Rect3 mesh_aabb; + AABB mesh_aabb; if (multimesh->mesh.is_valid()) { mesh_aabb = mesh_get_aabb(multimesh->mesh, RID()); @@ -4049,7 +4065,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { int count = multimesh->data.size(); float *data = multimesh->data.ptr(); - Rect3 aabb; + AABB aabb; if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { @@ -4064,7 +4080,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis[1][1] = dataptr[5]; xform.origin[1] = dataptr[7]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4090,7 +4106,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis.elements[2][2] = dataptr[10]; xform.origin.z = dataptr[11]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4226,10 +4242,10 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) { im->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { +AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND_V(!im, Rect3()); + ERR_FAIL_COND_V(!im, AABB()); return im->aabb; } @@ -4678,10 +4694,10 @@ uint64_t RasterizerStorageGLES3::light_get_version(RID p_light) const { return light->version; } -Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { +AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, Rect3()); + ERR_FAIL_COND_V(!light, AABB()); switch (light->type) { @@ -4689,22 +4705,22 @@ Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { float len = light->param[VS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; - return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); + return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); } break; case VS::LIGHT_OMNI: { float r = light->param[VS::LIGHT_PARAM_RANGE]; - return Rect3(-Vector3(r, r, r), Vector3(r, r, r) * 2); + return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); } break; case VS::LIGHT_DIRECTIONAL: { - return Rect3(); + return AABB(); } break; default: {} } - ERR_FAIL_V(Rect3()); - return Rect3(); + ERR_FAIL_V(AABB()); + return AABB(); } /* PROBE API */ @@ -4826,11 +4842,11 @@ void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_ reflection_probe->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { +AABB RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!reflection_probe, Rect3()); + ERR_FAIL_COND_V(!reflection_probe, AABB()); - Rect3 aabb; + AABB aabb; aabb.position = -reflection_probe->extents; aabb.size = reflection_probe->extents * 2.0; @@ -4887,7 +4903,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { GIProbe *gip = memnew(GIProbe); - gip->bounds = Rect3(Vector3(), Vector3(1, 1, 1)); + gip->bounds = AABB(Vector3(), Vector3(1, 1, 1)); gip->dynamic_range = 1.0; gip->energy = 1.0; gip->propagation = 1.0; @@ -4901,7 +4917,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { return gi_probe_owner.make_rid(gip); } -void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) { +void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) { GIProbe *gip = gi_probe_owner.getornull(p_probe); ERR_FAIL_COND(!gip); @@ -4910,10 +4926,10 @@ void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bou gip->version++; gip->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { +AABB RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip, Rect3()); + ERR_FAIL_COND_V(!gip, AABB()); return gip->bounds; } @@ -5322,7 +5338,7 @@ void RasterizerStorageGLES3::_particles_update_histories(Particles *particles) { particles->clear = true; } -void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) { Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); @@ -5413,15 +5429,15 @@ void RasterizerStorageGLES3::particles_request_process(RID p_particles) { } } -Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { +AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[0]); float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, particles->amount * 16 * 6, GL_MAP_READ_BIT); - Rect3 aabb; + AABB aabb; Transform inv = particles->emission_transform.affine_inverse(); @@ -5443,7 +5459,7 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { float longest_axis = 0; for (int i = 0; i < particles->draw_passes.size(); i++) { if (particles->draw_passes[i].is_valid()) { - Rect3 maabb = mesh_get_aabb(particles->draw_passes[i], RID()); + AABB maabb = mesh_get_aabb(particles->draw_passes[i], RID()); longest_axis = MAX(maabb.get_longest_axis_size(), longest_axis); } } @@ -5453,10 +5469,10 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { return aabb; } -Rect3 RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { +AABB RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); return particles->custom_aabb; } @@ -7011,14 +7027,22 @@ void RasterizerStorageGLES3::initialize() { glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); { const float qv[16] = { - -1, -1, - 0, 0, - -1, 1, - 0, 1, - 1, 1, - 1, 1, - 1, -1, - 1, 0, + -1, + -1, + 0, + 0, + -1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + -1, + 1, + 0, }; glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 6abc22b643..8aa8235b42 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -592,7 +592,7 @@ public: GLuint instancing_array_wireframe_id; int index_wireframe_len; - Vector<Rect3> skeleton_bone_aabb; + Vector<AABB> skeleton_bone_aabb; Vector<bool> skeleton_bone_used; //bool packed; @@ -604,7 +604,7 @@ public: Vector<BlendShape> blend_shapes; - Rect3 aabb; + AABB aabb; int array_len; int index_array_len; @@ -659,7 +659,7 @@ public: Vector<Surface *> surfaces; int blend_shape_count; VS::BlendShapeMode blend_shape_mode; - Rect3 custom_aabb; + AABB custom_aabb; mutable uint64_t last_pass; SelfList<MultiMesh>::List multimeshes; @@ -684,7 +684,7 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()); + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount); virtual int mesh_get_blend_shape_count(RID p_mesh) const; @@ -692,6 +692,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; + virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data); + virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material); virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const; @@ -704,17 +706,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_surface); virtual int mesh_get_surface_count(RID p_mesh) const; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb); - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb); + virtual AABB mesh_get_custom_aabb(RID p_mesh) const; - virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const; + virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const; virtual void mesh_clear(RID p_mesh); void mesh_render_blend_shapes(Surface *s, float *p_weights); @@ -727,7 +729,7 @@ public: VS::MultimeshTransformFormat transform_format; VS::MultimeshColorFormat color_format; Vector<float> data; - Rect3 aabb; + AABB aabb; SelfList<MultiMesh> update_list; SelfList<MultiMesh> mesh_list; GLuint buffer; @@ -778,7 +780,7 @@ public: virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible); virtual int multimesh_get_visible_instances(RID p_multimesh) const; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const; + virtual AABB multimesh_get_aabb(RID p_multimesh) const; /* IMMEDIATE API */ @@ -799,7 +801,7 @@ public: List<Chunk> chunks; bool building; int mask; - Rect3 aabb; + AABB aabb; Immediate() { type = GEOMETRY_IMMEDIATE; @@ -828,7 +830,7 @@ public: virtual void immediate_clear(RID p_immediate); virtual void immediate_set_material(RID p_immediate, RID p_material); virtual RID immediate_get_material(RID p_immediate) const; - virtual Rect3 immediate_get_aabb(RID p_immediate) const; + virtual AABB immediate_get_aabb(RID p_immediate) const; /* SKELETON API */ @@ -916,7 +918,7 @@ public: virtual float light_get_param(RID p_light, VS::LightParam p_param); virtual Color light_get_color(RID p_light); - virtual Rect3 light_get_aabb(RID p_light) const; + virtual AABB light_get_aabb(RID p_light) const; virtual uint64_t light_get_version(RID p_light) const; /* PROBE API */ @@ -954,7 +956,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable); virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers); - virtual Rect3 reflection_probe_get_aabb(RID p_probe) const; + virtual AABB reflection_probe_get_aabb(RID p_probe) const; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const; @@ -967,7 +969,7 @@ public: struct GIProbe : public Instantiable { - Rect3 bounds; + AABB bounds; Transform to_cell; float cell_size; @@ -988,8 +990,8 @@ public: virtual RID gi_probe_create(); - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds); - virtual Rect3 gi_probe_get_bounds(RID p_probe) const; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds); + virtual AABB gi_probe_get_bounds(RID p_probe) const; virtual void gi_probe_set_cell_size(RID p_probe, float p_size); virtual float gi_probe_get_cell_size(RID p_probe) const; @@ -1056,7 +1058,7 @@ public: float explosiveness; float randomness; bool restart_request; - Rect3 custom_aabb; + AABB custom_aabb; bool use_local_coords; RID process_material; @@ -1111,7 +1113,7 @@ public: restart_request = false; - custom_aabb = Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8)); + custom_aabb = AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)); draw_order = VS::PARTICLES_DRAW_ORDER_INDEX; particle_buffers[0] = 0; @@ -1153,7 +1155,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time); virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio); virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio); - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb); + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb); virtual void particles_set_speed_scale(RID p_particles, float p_scale); virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable); virtual void particles_set_process_material(RID p_particles, RID p_material); @@ -1167,8 +1169,8 @@ public: virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh); virtual void particles_request_process(RID p_particles); - virtual Rect3 particles_get_current_aabb(RID p_particles); - virtual Rect3 particles_get_aabb(RID p_particles) const; + virtual AABB particles_get_current_aabb(RID p_particles); + virtual AABB particles_get_aabb(RID p_particles) const; virtual void _particles_update_histories(Particles *particles); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index ad08c59de8..325df8e4f1 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -741,6 +741,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n"; + actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; @@ -828,6 +829,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; |