summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/image_loader.cpp3
-rw-r--r--doc/classes/AudioStreamSample.xml5
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp53
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h12
-rw-r--r--editor/import/resource_importer_scene.cpp6
5 files changed, 52 insertions, 27 deletions
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index a5a0738140..a759e615c7 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -65,6 +65,9 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
if (!loader[i]->recognize(extension))
continue;
Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale);
+ if (err != OK) {
+ ERR_PRINTS("Error loading image: " + p_file);
+ }
if (err != ERR_FILE_UNRECOGNIZED) {
diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml
index e23080c9d3..4bcf8ea791 100644
--- a/doc/classes/AudioStreamSample.xml
+++ b/doc/classes/AudioStreamSample.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamSample" inherits="AudioStream" category="Core" version="3.2">
<brief_description>
- Plays audio.
+ Stores audio data loaded from [code].wav[/code] files.
</brief_description>
<description>
- Plays audio, can loop.
+ AudioStreamSample stores sound samples loaded from [code].wav[/code] files. To play the stored sound use an [AudioStreamPlayer] (for background music) or [AudioStreamPlayer2D]/[AudioStreamPlayer3D] (for positional audio). The sound can be looped.
+ This class can also be used to store dynamically generated PCM audio data.
</description>
<tutorials>
</tutorials>
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 83e1196979..50cb39b13f 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -1027,6 +1027,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->light_index = RenderList::MAX_LIGHTS;
e->use_accum_ptr = &e->use_accum;
e->instancing = (e->instance->base_type == VS::INSTANCE_MULTIMESH) ? 1 : 0;
+ e->front_facing = false;
if (e->geometry->last_pass != render_pass) {
e->geometry->last_pass = render_pass;
@@ -1046,6 +1047,10 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->material_index = e->material->index;
+ if (mirror) {
+ e->front_facing = true;
+ }
+
e->refprobe_0_index = RenderList::MAX_REFLECTION_PROBES; //refprobe disabled by default
e->refprobe_1_index = RenderList::MAX_REFLECTION_PROBES; //refprobe disabled by default
@@ -1257,7 +1262,29 @@ static const GLenum gl_primitive[] = {
GL_TRIANGLE_FAN
};
-bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_material, bool p_reverse_cull, bool p_alpha_pass, Size2i p_skeleton_tex_size) {
+void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_reverse_cull) {
+
+ bool front = p_front;
+ if (p_reverse_cull)
+ front = !front;
+
+ if (p_disabled != state.cull_disabled) {
+ if (p_disabled)
+ glDisable(GL_CULL_FACE);
+ else
+ glEnable(GL_CULL_FACE);
+
+ state.cull_disabled = p_disabled;
+ }
+
+ if (front != state.cull_front) {
+
+ glCullFace(front ? GL_FRONT : GL_BACK);
+ state.cull_front = front;
+ }
+}
+
+bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size) {
// material parameters
@@ -1295,21 +1322,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
} break;
}
- switch (p_material->shader->spatial.cull_mode) {
- case RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_DISABLED: {
- glDisable(GL_CULL_FACE);
- } break;
-
- case RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_BACK: {
- glEnable(GL_CULL_FACE);
- glCullFace(p_reverse_cull ? GL_FRONT : GL_BACK);
- } break;
- case RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_FRONT: {
- glEnable(GL_CULL_FACE);
- glCullFace(p_reverse_cull ? GL_BACK : GL_FRONT);
- } break;
- }
-
int tc = p_material->textures.size();
const Pair<StringName, RID> *textures = p_material->textures.ptr();
@@ -2202,6 +2214,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
int prev_blend_mode = -2; //will always catch the first go
+ state.cull_front = false;
+ state.cull_disabled = false;
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
+
if (p_alpha_pass) {
glEnable(GL_BLEND);
} else {
@@ -2441,12 +2458,14 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
if (rebind || material != prev_material) {
storage->info.render.material_switch_count++;
- shader_rebind = _setup_material(material, p_reverse_cull, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0));
+ shader_rebind = _setup_material(material, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0));
if (shader_rebind) {
storage->info.render.shader_rebind_count++;
}
}
+ _set_cull(e->front_facing, material->shader->spatial.cull_mode == RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_DISABLED, p_reverse_cull);
+
if (i == 0 || shader_rebind) { //first time must rebind
if (p_shadow) {
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index bd1a61688c..d5a691d0b9 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -198,14 +198,15 @@ public:
int directional_light_count;
int reflection_probe_count;
- bool cull_front;
- bool cull_disabled;
bool used_sss;
bool using_contact_shadows;
VS::ViewportDebugDraw debug_draw;
*/
+ bool cull_front;
+ bool cull_disabled;
+
bool used_screen_texture;
bool shadow_is_dual_parabolloid;
float dual_parbolloid_direction;
@@ -503,8 +504,7 @@ public:
enum {
MAX_LIGHTS = 255,
MAX_REFLECTION_PROBES = 255,
- DEFAULT_MAX_ELEMENTS = 65536,
- SORT_KEY_PRIORITY_SHIFT = 56
+ DEFAULT_MAX_ELEMENTS = 65536
};
int max_elements;
@@ -518,6 +518,7 @@ public:
bool use_accum; //is this an add pass for multipass
bool *use_accum_ptr;
+ bool front_facing;
union {
//TODO: should be endian swapped on big endian
@@ -685,7 +686,8 @@ public:
void _draw_sky(RasterizerStorageGLES2::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy, const Basis &p_sky_orientation);
- _FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES2::Material *p_material, bool p_reverse_cull, bool p_alpha_pass, Size2i p_skeleton_tex_size = Size2i(0, 0));
+ _FORCE_INLINE_ void _set_cull(bool p_front, bool p_disabled, bool p_reverse_cull);
+ _FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size = Size2i(0, 0));
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *p_element, RasterizerStorageGLES2::Skeleton *p_skeleton);
_FORCE_INLINE_ void _setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas);
_FORCE_INLINE_ void _setup_light(LightInstance *p_light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5da731b0a0..0989a43705 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1024,7 +1024,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
} else {
ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
- p_materials[mat] = ResourceLoader::load(ext_name);
+ p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache.
}
}
@@ -1070,13 +1070,13 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material");
;
- if (FileAccess::exists(ext_name)) {
+ if (p_keep_materials && FileAccess::exists(ext_name)) {
//if exists, use it
p_materials[mat] = ResourceLoader::load(ext_name);
} else {
ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
- p_materials[mat] = ResourceLoader::load(ext_name);
+ p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache.
}
}