summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp27
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h1
-rw-r--r--drivers/gles2/shaders/scene.glsl11
3 files changed, 30 insertions, 9 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 0567aea7a6..feefb74480 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -944,6 +944,8 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
int rpsize = e->instance->reflection_probe_instances.size();
if (rpsize > 0) {
bool first = true;
+ rpsize = MIN(rpsize, 2); //more than 2 per object are not supported, this keeps it stable
+
for (int i = 0; i < rpsize; i++) {
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(e->instance->reflection_probe_instances[i]);
if (rpi->last_pass != render_pass) {
@@ -958,11 +960,11 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
}
- if (e->refprobe_0_index > e->refprobe_1_index) { //if both are valid, swap them to keep order as best as possible
- uint16_t tmp = e->refprobe_0_index;
+ /* if (e->refprobe_0_index > e->refprobe_1_index) { //if both are valid, swap them to keep order as best as possible
+ uint64_t tmp = e->refprobe_0_index;
e->refprobe_0_index = e->refprobe_1_index;
e->refprobe_1_index = tmp;
- }
+ }*/
}
//add directional lights
@@ -1231,7 +1233,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
}
- //bool clear_skeleton_buffer = !storage->config.float_texture_supported;
+ bool clear_skeleton_buffer = !storage->config.float_texture_supported;
if (p_skeleton) {
@@ -1351,10 +1353,17 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
glVertexAttribPointer(INSTANCE_BONE_BASE + 1, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 12, (const void *)(sizeof(float) * 4 * 1));
glVertexAttribPointer(INSTANCE_BONE_BASE + 2, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 12, (const void *)(sizeof(float) * 4 * 2));
- //clear_skeleton_buffer = false;
+ clear_skeleton_buffer = false;
}
}
+ if (clear_skeleton_buffer) {
+
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 0);
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 1);
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 2);
+ }
+
} break;
case VS::INSTANCE_MULTIMESH: {
@@ -1391,6 +1400,9 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
glDisableVertexAttribArray(INSTANCE_ATTRIB_BASE + 2);
glDisableVertexAttribArray(INSTANCE_ATTRIB_BASE + 3);
glDisableVertexAttribArray(INSTANCE_ATTRIB_BASE + 4);
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 0);
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 1);
+ glDisableVertexAttribArray(INSTANCE_BONE_BASE + 2);
} break;
@@ -2110,9 +2122,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (!unshaded && !accum_pass && e->refprobe_0_index != RenderList::MAX_REFLECTION_PROBES) {
+ ERR_FAIL_INDEX(e->refprobe_0_index, reflection_probe_count);
refprobe_1 = reflection_probe_instances[e->refprobe_0_index];
}
if (!unshaded && !accum_pass && e->refprobe_1_index != RenderList::MAX_REFLECTION_PROBES) {
+ ERR_FAIL_INDEX(e->refprobe_1_index, reflection_probe_count);
refprobe_2 = reflection_probe_instances[e->refprobe_1_index];
}
@@ -2437,7 +2451,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
if (p_reflection_probe_cull_count) {
reflection_probe_instances = (ReflectionProbeInstance **)alloca(sizeof(ReflectionProbeInstance *) * p_reflection_probe_cull_count);
-
+ reflection_probe_count = p_reflection_probe_cull_count;
for (int i = 0; i < p_reflection_probe_cull_count; i++) {
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_reflection_probe_cull_result[i]);
ERR_CONTINUE(!rpi);
@@ -2448,6 +2462,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
} else {
reflection_probe_instances = NULL;
+ reflection_probe_count = 0;
}
// render list stuff
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index 64790fcd0e..14b9116952 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -325,6 +325,7 @@ public:
mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
ReflectionProbeInstance **reflection_probe_instances;
+ int reflection_probe_count;
virtual RID reflection_probe_instance_create(RID p_probe);
virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform);
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index 468804cc5a..462aff8828 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -755,12 +755,12 @@ void reflection_process(samplerCube reflection_map,
#endif
ambient_out.rgb = textureCubeLod(reflection_map, amb_normal, RADIANCE_MAX_LOD).rgb;
- ambient_out.a = blend;
ambient_out.rgb = mix(ref_ambient.rgb, ambient_out.rgb, ref_ambient.a);
if (exterior) {
ambient_out.rgb = mix(ambient, ambient_out.rgb, blend);
}
+ ambient_out.a = blend;
ambient_out.rgb *= blend;
ambient_accum += ambient_out;
@@ -1357,12 +1357,14 @@ FRAGMENT_SHADER_CODE
ambient_light *= ambient_energy;
+#if defined(USE_REFLECTION_PROBE1) || defined(USE_REFLECTION_PROBE2)
+
-#ifdef USE_REFLECTION_PROBE1
vec4 ambient_accum = vec4(0.0);
vec4 reflection_accum = vec4(0.0);
+#ifdef USE_REFLECTION_PROBE1
reflection_process(reflection_probe1,
#ifdef USE_VERTEX_LIGHTING
@@ -1379,6 +1381,9 @@ FRAGMENT_SHADER_CODE
ambient_light, specular_light, reflection_accum, ambient_accum);
+
+#endif // USE_REFLECTION_PROBE1
+
#ifdef USE_REFLECTION_PROBE2
reflection_process(reflection_probe2,
@@ -1407,7 +1412,7 @@ FRAGMENT_SHADER_CODE
}
#endif
-#endif //use reflection probe 1
+#endif // defined(USE_REFLECTION_PROBE1) || defined(USE_REFLECTION_PROBE2)
#ifdef USE_LIGHTMAP
//ambient light will come entirely from lightmap is lightmap is used