summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp6
-rw-r--r--drivers/gles2/shaders/canvas.glsl27
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp7
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h1
-rw-r--r--drivers/gles3/shaders/canvas.glsl1
-rw-r--r--drivers/unix/os_unix.cpp5
-rw-r--r--drivers/unix/os_unix.h1
7 files changed, 44 insertions, 4 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 2c52895bda..cc9084dceb 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -1564,6 +1564,8 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
} else {
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 3, buffer + color_ofs);
}
+ } else {
+ glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, 1.0, 1.0, 1.0, 1.0);
}
if (multi_mesh->custom_data_floats) {
@@ -3041,7 +3043,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
}
}
- glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+ if (storage->frame.current_rt) {
+ glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+ }
glColorMask(1, 1, 1, 1);
}
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index c4a8c8b990..643b6a5cc9 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -316,9 +316,35 @@ FRAGMENT_SHADER_GLOBALS
/* clang-format on */
+void light_compute(
+ inout vec4 light,
+ inout vec2 light_vec,
+ inout float light_height,
+ inout vec4 light_color,
+ vec2 light_uv,
+ inout vec4 shadow_color,
+ vec3 normal,
+ vec2 uv,
+#if defined(SCREEN_UV_USED)
+ vec2 screen_uv,
+#endif
+ vec4 color) {
+
+#if defined(USE_LIGHT_SHADER_CODE)
+
+ /* clang-format off */
+
+LIGHT_SHADER_CODE
+
+ /* clang-format on */
+
+#endif
+}
+
void main() {
vec4 color = color_interp;
+ vec2 uv = uv_interp;
#if !defined(COLOR_USED)
//default behavior, texture by color
@@ -414,7 +440,6 @@ FRAGMENT_SHADER_CODE
color *= light;
#ifdef USE_SHADOWS
- light_vec = light_uv_interp.zw; //for shadows
float angle_to_light = -atan(light_vec.x, light_vec.y);
float PI = 3.14159265358979323846264;
/*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 966466d9bc..31f42493a3 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2343,6 +2343,10 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
state.used_screen_texture = true;
}
+ if (p_material->shader->spatial.uses_depth_texture) {
+ state.used_depth_texture = true;
+ }
+
if (p_depth_pass) {
if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
@@ -3159,6 +3163,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
current_material_index = 0;
state.used_sss = false;
state.used_screen_texture = false;
+ state.used_depth_texture = false;
//fill list
for (int i = 0; i < p_cull_count; i++) {
@@ -4169,7 +4174,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glColorMask(1, 1, 1, 1);
- if (state.used_contact_shadows) {
+ if (state.used_contact_shadows || state.used_depth_texture) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0);
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 325617745a..fbafc59b48 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -204,6 +204,7 @@ public:
bool cull_disabled;
bool used_sss;
bool used_screen_texture;
+ bool used_depth_texture;
bool using_contact_shadows;
VS::ViewportDebugDraw debug_draw;
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 974eff86f3..90775c841f 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -549,7 +549,6 @@ FRAGMENT_SHADER_CODE
color *= light;
#ifdef USE_SHADOWS
- light_vec = light_uv_interp.zw; //for shadows
float angle_to_light = -atan(light_vec.x, light_vec.y);
float PI = 3.14159265358979323846264;
/*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index ce1c183242..e3e2e10e82 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -469,6 +469,11 @@ String OS_Unix::get_environment(const String &p_var) const {
return "";
}
+bool OS_Unix::set_environment(const String &p_var, const String &p_value) const {
+
+ return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0;
+}
+
int OS_Unix::get_processor_count() const {
return sysconf(_SC_NPROCESSORS_CONF);
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 2a23da6f28..09ab4aa1d8 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -95,6 +95,7 @@ public:
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
+ virtual bool set_environment(const String &p_var, const String &p_value) const;
virtual String get_locale() const;
virtual int get_processor_count() const;