summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/AStar.xml4
-rw-r--r--doc/classes/AStar2D.xml4
-rw-r--r--doc/classes/ColorPicker.xml2
-rw-r--r--doc/classes/Environment.xml7
-rw-r--r--doc/classes/MainLoop.xml34
-rw-r--r--doc/classes/SceneTreeTimer.xml6
-rw-r--r--doc/classes/SurfaceTool.xml1
-rw-r--r--doc/classes/TextureProgress.xml2
-rw-r--r--doc/classes/VisualShaderNode.xml7
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp514
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h65
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp147
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h35
-rw-r--r--drivers/gles2/shaders/SCsub4
-rw-r--r--drivers/gles2/shaders/canvas_shadow.glsl5
-rw-r--r--drivers/gles2/shaders/cube_to_dp.glsl5
-rw-r--r--drivers/gles2/shaders/effect_blur.glsl244
-rw-r--r--drivers/gles2/shaders/lens_distorted.glsl7
-rw-r--r--drivers/gles2/shaders/tonemap.glsl296
-rw-r--r--drivers/unix/os_unix.cpp2
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp82
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h4
-rw-r--r--misc/dist/html/fixed-size.html3
-rw-r--r--misc/dist/html/full-size.html3
-rw-r--r--modules/gdscript/gdscript_functions.cpp44
-rw-r--r--platform/javascript/engine.js13
-rw-r--r--scene/2d/node_2d.cpp2
-rw-r--r--scene/2d/polygon_2d.cpp2
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/dialogs.cpp18
-rw-r--r--scene/gui/dialogs.h1
-rw-r--r--scene/gui/grid_container.cpp2
-rw-r--r--scene/gui/tabs.cpp15
-rw-r--r--scene/gui/tabs.h1
-rw-r--r--scene/gui/texture_progress.cpp11
-rw-r--r--scene/resources/environment.cpp4
-rw-r--r--scene/resources/visual_shader.cpp17
-rw-r--r--scene/resources/visual_shader.h3
-rw-r--r--scene/resources/visual_shader_nodes.cpp81
-rw-r--r--scene/resources/visual_shader_nodes.h3
41 files changed, 1268 insertions, 438 deletions
diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml
index 9ca09371dd..e835af01e8 100644
--- a/doc/classes/AStar.xml
+++ b/doc/classes/AStar.xml
@@ -110,8 +110,10 @@
</return>
<argument index="0" name="to_position" type="Vector3">
</argument>
+ <argument index="1" name="include_disabled" type="bool" default="false">
+ </argument>
<description>
- Returns the ID of the closest point to [code]to_position[/code]. Returns -1 if there are no points in the points pool.
+ Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
</description>
</method>
<method name="get_closest_position_in_segment" qualifiers="const">
diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml
index 0eff2bd560..3002e3c351 100644
--- a/doc/classes/AStar2D.xml
+++ b/doc/classes/AStar2D.xml
@@ -87,8 +87,10 @@
</return>
<argument index="0" name="to_position" type="Vector2">
</argument>
+ <argument index="1" name="include_disabled" type="bool" default="false">
+ </argument>
<description>
- Returns the ID of the closest point to [code]to_position[/code]. Returns -1 if there are no points in the points pool.
+ Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
</description>
</method>
<method name="get_closest_position_in_segment" qualifiers="const">
diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml
index b62eb443d9..cd36f4fdf0 100644
--- a/doc/classes/ColorPicker.xml
+++ b/doc/classes/ColorPicker.xml
@@ -97,6 +97,8 @@
</theme_item>
<theme_item name="margin" type="int" default="4">
</theme_item>
+ <theme_item name="overbright_indicator" type="Texture">
+ </theme_item>
<theme_item name="preset_bg" type="Texture">
</theme_item>
<theme_item name="screen_picker" type="Texture">
diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml
index 9a943aba51..2b44eb81b1 100644
--- a/doc/classes/Environment.xml
+++ b/doc/classes/Environment.xml
@@ -177,6 +177,7 @@
Enables fog's light transmission. If enabled, lets reflections light to be transmitted by the fog.
</member>
<member name="glow_bicubic_upscale" type="bool" setter="set_glow_bicubic_upscale" getter="is_glow_bicubic_upscale_enabled" default="false">
+ Smooths out blockiness created by sampling higher levels.
</member>
<member name="glow_blend_mode" type="int" setter="set_glow_blend_mode" getter="get_glow_blend_mode" enum="Environment.GlowBlendMode" default="2">
Glow blending mode.
@@ -193,10 +194,10 @@
Bleed scale of the HDR glow.
</member>
<member name="glow_hdr_threshold" type="float" setter="set_glow_hdr_bleed_threshold" getter="get_glow_hdr_bleed_threshold" default="1.0">
- Bleed threshold of the HDR glow.
+ Bleed threshold of the HDR glow. In GLES2, this needs to be below 1.0 in order for glow to be visible, a default value of 0.9 works well.
</member>
<member name="glow_intensity" type="float" setter="set_glow_intensity" getter="get_glow_intensity" default="0.8">
- Glow intensity.
+ Glow intensity. In GLES2, this should be increased to 1.5 by default to compensate for not using HDR.
</member>
<member name="glow_levels/1" type="bool" setter="set_glow_level" getter="is_glow_level_enabled" default="false">
First level of glow (most local).
@@ -220,7 +221,7 @@
Seventh level of glow (most global).
</member>
<member name="glow_strength" type="float" setter="set_glow_strength" getter="get_glow_strength" default="1.0">
- Glow strength.
+ Glow strength. In GLES2, this should be increased to 1.3 by default to compensate for not using HDR.
</member>
<member name="ss_reflections_depth_tolerance" type="float" setter="set_ssr_depth_tolerance" getter="get_ssr_depth_tolerance" default="0.2">
</member>
diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml
index 23ce20a434..9e65da8eea 100644
--- a/doc/classes/MainLoop.xml
+++ b/doc/classes/MainLoop.xml
@@ -15,29 +15,29 @@
var quit = false
func _initialize():
- print("Initialized:")
- print(" Starting time: %s" % str(time_elapsed))
+ print("Initialized:")
+ print(" Starting time: %s" % str(time_elapsed))
func _idle(delta):
- time_elapsed += delta
- # Return true to end the main loop
- return quit
+ time_elapsed += delta
+ # Return true to end the main loop.
+ return quit
func _input_event(event):
- # Record keys
- if event is InputEventKey and event.pressed and !event.echo:
- keys_typed.append(OS.get_scancode_string(event.scancode))
- # Quit on Escape press
- if event.scancode == KEY_ESCAPE:
- quit = true
- # Quit on any mouse click
- if event is InputEventMouseButton:
- quit = true
+ # Record keys.
+ if event is InputEventKey and event.pressed and !event.echo:
+ keys_typed.append(OS.get_scancode_string(event.scancode))
+ # Quit on Escape press.
+ if event.scancode == KEY_ESCAPE:
+ quit = true
+ # Quit on any mouse click.
+ if event is InputEventMouseButton:
+ quit = true
func _finalize():
- print("Finalized:")
- print(" End time: %s" % str(time_elapsed))
- print(" Keys typed: %s" % var2str(keys_typed))
+ print("Finalized:")
+ print(" End time: %s" % str(time_elapsed))
+ print(" Keys typed: %s" % var2str(keys_typed))
[/codeblock]
</description>
<tutorials>
diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml
index a33f875be2..5678833752 100644
--- a/doc/classes/SceneTreeTimer.xml
+++ b/doc/classes/SceneTreeTimer.xml
@@ -8,9 +8,9 @@
As opposed to [Timer], it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example:
[codeblock]
func some_function():
- print("start")
- yield(get_tree().create_timer(1.0), "timeout")
- print("end")
+ print("Timer started.")
+ yield(get_tree().create_timer(1.0), "timeout")
+ print("Timer ended.")
[/codeblock]
</description>
<tutorials>
diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml
index 153d88f1af..7cfd8c6919 100644
--- a/doc/classes/SurfaceTool.xml
+++ b/doc/classes/SurfaceTool.xml
@@ -167,6 +167,7 @@
</argument>
<description>
Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh].
+ Default flag is [constant Mesh.ARRAY_COMPRESS_DEFAULT]. See [code]Mesh.ARRAY_COMPRESS_*[/code] constants for other flags.
</description>
</method>
<method name="commit_to_arrays">
diff --git a/doc/classes/TextureProgress.xml b/doc/classes/TextureProgress.xml
index 21b294cf90..479ab865ba 100644
--- a/doc/classes/TextureProgress.xml
+++ b/doc/classes/TextureProgress.xml
@@ -34,7 +34,7 @@
</member>
<member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" />
<member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" default="false">
- If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid.
+ If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid. When using a radial [member fill_mode], this setting will enable stretching.
</member>
<member name="radial_center_offset" type="Vector2" setter="set_radial_center_offset" getter="get_radial_center_offset" default="Vector2( 0, 0 )">
Offsets [member texture_progress] if [member fill_mode] is [constant FILL_CLOCKWISE] or [constant FILL_COUNTER_CLOCKWISE].
diff --git a/doc/classes/VisualShaderNode.xml b/doc/classes/VisualShaderNode.xml
index 3e80349b13..9b0c6b2604 100644
--- a/doc/classes/VisualShaderNode.xml
+++ b/doc/classes/VisualShaderNode.xml
@@ -51,8 +51,11 @@
<constant name="PORT_TYPE_TRANSFORM" value="3" enum="PortType">
Transform type. Translated to [code]mat4[/code] type in shader code.
</constant>
- <constant name="PORT_TYPE_ICON_COLOR" value="4" enum="PortType">
- Color type. Can be used for return icon type in members dialog (see [method VisualShaderNodeCustom._get_return_icon_type]) - do not use it in other cases!
+ <constant name="PORT_TYPE_SAMPLER" value="4" enum="PortType">
+ Sampler type. Translated to reference of sampler uniform in shader code. Can only be used for input ports in non-uniform nodes.
+ </constant>
+ <constant name="PORT_TYPE_MAX" value="5" enum="PortType">
+ Represents the size of the [enum PortType] enum.
</constant>
</constants>
</class>
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index a8fa30c709..9530ed08c9 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -778,18 +778,44 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer
}
void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) {
+
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
+
+ env->dof_blur_far_enabled = p_enable;
+ env->dof_blur_far_distance = p_distance;
+ env->dof_blur_far_transition = p_transition;
+ env->dof_blur_far_amount = p_amount;
+ env->dof_blur_far_quality = p_quality;
}
void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) {
+
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
+
+ env->dof_blur_near_enabled = p_enable;
+ env->dof_blur_near_distance = p_distance;
+ env->dof_blur_near_transition = p_transition;
+ env->dof_blur_near_amount = p_amount;
+ env->dof_blur_near_quality = p_quality;
}
void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
+
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
+
+ env->glow_enabled = p_enable;
+ env->glow_levels = p_level_flags;
+ env->glow_intensity = p_intensity;
+ env->glow_strength = p_strength;
+ env->glow_bloom = p_bloom_threshold;
+ env->glow_blend_mode = p_blend_mode;
+ env->glow_hdr_bleed_threshold = p_hdr_bleed_threshold;
+ env->glow_hdr_bleed_scale = p_hdr_bleed_scale;
+ env->glow_hdr_luminance_cap = p_hdr_luminance_cap;
+ env->glow_bicubic_upscale = p_bicubic_upscale;
}
void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {
@@ -813,8 +839,15 @@ void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, VS::EnvironmentTon
}
void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {
+
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
+
+ env->adjustments_enabled = p_enable;
+ env->adjustments_brightness = p_brightness;
+ env->adjustments_contrast = p_contrast;
+ env->adjustments_saturation = p_saturation;
+ env->color_correction = p_ramp;
}
void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {
@@ -1174,10 +1207,10 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
}
-void RasterizerSceneGLES2::_copy_texture_to_front_buffer(GLuint p_texture) {
+void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer) {
//copy to front buffer
- glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, p_buffer);
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
@@ -2710,6 +2743,451 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_CUBEMAP, false);
}
+void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p_cam_projection) {
+
+ //copy to front buffer
+
+ glDepthMask(GL_FALSE);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_BLEND);
+ glDepthFunc(GL_LEQUAL);
+ glColorMask(1, 1, 1, 1);
+
+ //no post process on small, transparent or render targets without an env
+ bool use_post_process = env && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
+ use_post_process = use_post_process && storage->frame.current_rt->width >= 4 && storage->frame.current_rt->height >= 4;
+ use_post_process = use_post_process && storage->frame.current_rt->mip_maps_allocated;
+
+ if (env) {
+ use_post_process = use_post_process && (env->adjustments_enabled || env->glow_enabled || env->dof_blur_far_enabled || env->dof_blur_near_enabled);
+ }
+
+ GLuint next_buffer;
+
+ if (use_post_process) {
+ next_buffer = storage->frame.current_rt->mip_maps[0].sizes[0].fbo;
+ } else {
+ // set next_buffer to front buffer so multisample blit can happen if needed
+ next_buffer = storage->frame.current_rt->fbo;
+ }
+
+ // If using multisample buffer, resolve to post_process_effect buffer or to front buffer
+ if (storage->frame.current_rt && storage->frame.current_rt->multisample_active) {
+#ifdef GLES_OVER_GL
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, next_buffer);
+ glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+#elif IPHONE_ENABLED
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, next_buffer);
+ glResolveMultisampleFramebufferAPPLE();
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+#elif ANDROID_ENABLED
+
+ // In GLES2 Android Blit is not available, so just copy color texture manually
+ _copy_texture_to_buffer(storage->frame.current_rt->multisample_color, next_buffer);
+#endif
+ } else if (use_post_process) {
+ _copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
+ }
+
+ if (!use_post_process) {
+ return;
+ }
+
+ // Order of operation
+ //1) DOF Blur (first blur, then copy to buffer applying the blur) //only on desktop
+ //2) Bloom (Glow) //only on desktop
+ //3) Adjustments
+
+ // DOF Blur
+
+ if (env->dof_blur_far_enabled) {
+
+ int vp_h = storage->frame.current_rt->height;
+ int vp_w = storage->frame.current_rt->width;
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_FAR_BLUR, true);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_LOW);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH);
+
+ state.effect_blur_shader.bind();
+ int qsteps[3] = { 4, 10, 20 };
+
+ float radius = (env->dof_blur_far_amount * env->dof_blur_far_amount) / qsteps[env->dof_blur_far_quality];
+
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_BEGIN, env->dof_blur_far_distance);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_END, env->dof_blur_far_distance + env->dof_blur_far_transition);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_DIR, Vector2(1, 0));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_RADIUS, radius);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_NEAR, p_cam_projection.get_z_near());
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_FAR, p_cam_projection.get_z_far());
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->depth);
+
+ glActiveTexture(GL_TEXTURE0);
+
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[0].color);
+ }
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
+
+ storage->_copy_screen();
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_DIR, Vector2(0, 1));
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->mip_maps[0].sizes[0].fbo); // copy to base level
+ storage->_copy_screen();
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_FAR_BLUR, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, false);
+ }
+
+ if (env->dof_blur_near_enabled) {
+
+ //convert texture to RGBA format if not already
+ if (!storage->frame.current_rt->used_dof_blur_near) {
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+
+ int vp_h = storage->frame.current_rt->height;
+ int vp_w = storage->frame.current_rt->width;
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_BLUR, true);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_FIRST_TAP, true);
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_LOW);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH);
+
+ state.effect_blur_shader.bind();
+ int qsteps[3] = { 4, 10, 20 };
+
+ float radius = (env->dof_blur_near_amount * env->dof_blur_near_amount) / qsteps[env->dof_blur_near_quality];
+
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_BEGIN, env->dof_blur_near_distance);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_END, env->dof_blur_near_distance - env->dof_blur_near_transition);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_DIR, Vector2(1, 0));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_RADIUS, radius);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_NEAR, p_cam_projection.get_z_near());
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_FAR, p_cam_projection.get_z_far());
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->depth);
+
+ glActiveTexture(GL_TEXTURE0);
+ if (!storage->frame.current_rt->used_dof_blur_near) {
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ } else {
+ for (int i = 0; i < storage->frame.current_rt->mip_maps[i].sizes.size(); i++) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[i].color);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, storage->frame.current_rt->mip_maps[0].sizes[i].width, storage->frame.current_rt->mip_maps[0].sizes[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[0].color);
+ }
+ }
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first
+
+ storage->_copy_screen();
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_FIRST_TAP, false);
+ state.effect_blur_shader.bind();
+
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_BEGIN, env->dof_blur_near_distance);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_END, env->dof_blur_near_distance - env->dof_blur_near_transition);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_DIR, Vector2(0, 1));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::DOF_RADIUS, radius);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_NEAR, p_cam_projection.get_z_near());
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::CAMERA_Z_FAR, p_cam_projection.get_z_far());
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->mip_maps[0].sizes[0].fbo); // copy to base level
+
+ glEnable(GL_BLEND);
+ glBlendEquation(GL_FUNC_ADD);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ storage->_copy_screen();
+
+ glDisable(GL_BLEND);
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_BLUR, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_FIRST_TAP, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, false);
+ storage->frame.current_rt->used_dof_blur_near = true;
+ }
+
+ if (env->dof_blur_near_enabled || env->dof_blur_far_enabled) {
+ //these needed to disable filtering, reenamble
+ glActiveTexture(GL_TEXTURE0);
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[0].color);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ }
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+
+ //glow
+
+ int max_glow_level = -1;
+ int glow_mask = 0;
+
+ if (env->glow_enabled) {
+
+ for (int i = 0; i < VS::MAX_GLOW_LEVELS; i++) {
+ if (env->glow_levels & (1 << i)) {
+
+ if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) {
+ max_glow_level = storage->frame.current_rt->mip_maps[1].sizes.size() - 1;
+ glow_mask |= 1 << max_glow_level;
+
+ } else {
+ max_glow_level = i;
+ glow_mask |= (1 << i);
+ }
+ }
+ }
+
+ for (int i = 0; i < (max_glow_level + 1); i++) {
+
+ int vp_w = storage->frame.current_rt->mip_maps[1].sizes[i].width;
+ int vp_h = storage->frame.current_rt->mip_maps[1].sizes[i].height;
+ glViewport(0, 0, vp_w, vp_h);
+ //horizontal pass
+ if (i == 0) {
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_FIRST_PASS, true);
+ }
+
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_GAUSSIAN_HORIZONTAL, true);
+ state.effect_blur_shader.bind();
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::LOD, storage->frame.current_rt->mip_maps[0].color ? float(i) : 0.0);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_STRENGTH, env->glow_strength);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::LUMINANCE_CAP, env->glow_hdr_luminance_cap);
+
+ glActiveTexture(GL_TEXTURE0);
+
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[i].color);
+ }
+
+ if (i == 0) {
+
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_BLOOM, env->glow_bloom);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale);
+ }
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->mip_maps[1].sizes[i].fbo);
+ storage->_copy_screen();
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_GAUSSIAN_HORIZONTAL, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_FIRST_PASS, false);
+
+ //vertical pass
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_GAUSSIAN_VERTICAL, true);
+ state.effect_blur_shader.bind();
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::LOD, storage->frame.current_rt->mip_maps[0].color ? float(i) : 0.0);
+ state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_STRENGTH, env->glow_strength);
+ glActiveTexture(GL_TEXTURE0);
+
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[1].color);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[1].sizes[i].color);
+ }
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger
+ storage->_copy_screen();
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::GLOW_GAUSSIAN_VERTICAL, false);
+ }
+
+ glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+ }
+
+ if (storage->frame.current_rt->external.fbo != 0) {
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->external.fbo);
+ } else {
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
+ }
+
+ glActiveTexture(GL_TEXTURE0);
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[0].color);
+ }
+
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_FILTER_BICUBIC, env->glow_bicubic_upscale);
+
+ if (max_glow_level >= 0) {
+ if (storage->frame.current_rt->mip_maps[0].color) {
+ for (int i = 0; i < (max_glow_level + 1); i++) {
+
+ if (glow_mask & (1 << i)) {
+ if (i == 0) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, true);
+ }
+ if (i == 1) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL2, true);
+ }
+ if (i == 2) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL3, true);
+ }
+ if (i == 3) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL4, true);
+ }
+ if (i == 4) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL5, true);
+ }
+ if (i == 5) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL6, true);
+ }
+ if (i == 6) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL7, true);
+ }
+ }
+ }
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
+ } else {
+
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_MULTI_TEXTURE_GLOW, true);
+ int active_glow_level = 0;
+ for (int i = 0; i < (max_glow_level + 1); i++) {
+
+ if (glow_mask & (1 << i)) {
+ active_glow_level++;
+ glActiveTexture(GL_TEXTURE0 + active_glow_level);
+ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].sizes[i + 1].color);
+ if (active_glow_level == 1) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, true);
+ }
+ if (active_glow_level == 2) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL2, true);
+ }
+ if (active_glow_level == 3) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL3, true);
+ }
+ if (active_glow_level == 4) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL4, true);
+ }
+ if (active_glow_level == 5) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL5, true);
+ }
+ if (active_glow_level == 6) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL6, true);
+ }
+ if (active_glow_level == 7) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL7, true);
+ }
+ }
+ }
+ }
+
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, env->glow_blend_mode == VS::GLOW_BLEND_MODE_SCREEN);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, env->glow_blend_mode == VS::GLOW_BLEND_MODE_SOFTLIGHT);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, env->glow_blend_mode == VS::GLOW_BLEND_MODE_REPLACE);
+ }
+
+ //Adjustments
+ if (env->adjustments_enabled) {
+
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_BCS, true);
+ RasterizerStorageGLES2::Texture *tex = storage->texture_owner.getornull(env->color_correction);
+ if (tex) {
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_COLOR_CORRECTION, true);
+ glActiveTexture(GL_TEXTURE2);
+ glBindTexture(tex->target, tex->tex_id);
+ }
+ }
+
+ state.tonemap_shader.bind();
+
+ if (max_glow_level >= 0) {
+
+ state.tonemap_shader.set_uniform(TonemapShaderGLES2::GLOW_INTENSITY, env->glow_intensity);
+ int ss[2] = {
+ storage->frame.current_rt->width,
+ storage->frame.current_rt->height,
+ };
+ glUniform2iv(state.tonemap_shader.get_uniform(TonemapShaderGLES2::GLOW_TEXTURE_SIZE), 1, ss);
+ }
+
+ if (env->adjustments_enabled) {
+
+ state.tonemap_shader.set_uniform(TonemapShaderGLES2::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation));
+ }
+
+ storage->_copy_screen();
+
+ //turn off everything used
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL2, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL3, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL4, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL5, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL6, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL7, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_FILTER_BICUBIC, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_MULTI_TEXTURE_GLOW, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_BCS, false);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_COLOR_CORRECTION, false);
+}
+
void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
Transform cam_transform = p_cam_transform;
@@ -3010,7 +3488,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
#elif ANDROID_ENABLED
// In GLES2 AndroidBlit is not available, so just copy color texture manually
- _copy_texture_to_front_buffer(storage->frame.current_rt->multisample_color);
+ _copy_texture_to_buffer(storage->frame.current_rt->multisample_color, storage->frame.current_rt->fbo);
#endif
}
@@ -3031,32 +3509,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
_render_render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, cam_transform, p_cam_projection, p_shadow_atlas, env, env_radiance_tex, 0.0, 0.0, reverse_cull, true, false);
- glDisable(GL_DEPTH_TEST);
-
- if (storage->frame.current_rt && storage->frame.current_rt->multisample_active) {
-#ifdef GLES_OVER_GL
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->fbo);
- glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-#elif IPHONE_ENABLED
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->fbo);
- glResolveMultisampleFramebufferAPPLE();
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-#elif ANDROID_ENABLED
-
- // In GLES2 Android Blit is not available, so just copy color texture manually
- _copy_texture_to_front_buffer(storage->frame.current_rt->multisample_color);
-#endif
- }
+ //post process
+ _post_process(env, p_cam_projection);
//#define GLES2_SHADOW_ATLAS_DEBUG_VIEW
@@ -3439,6 +3893,8 @@ void RasterizerSceneGLES2::initialize() {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_RGBA_SHADOWS, storage->config.use_rgba_3d_shadows);
state.cube_to_dp_shader.init();
+ state.effect_blur_shader.init();
+ state.tonemap_shader.init();
render_list.init();
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index 69a2295fc1..7babcfeed1 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -35,10 +35,12 @@
#include "rasterizer_storage_gles2.h"
#include "shaders/cube_to_dp.glsl.gen.h"
+#include "shaders/effect_blur.glsl.gen.h"
#include "shaders/scene.glsl.gen.h"
+#include "shaders/tonemap.glsl.gen.h"
/*
-#include "drivers/gles3/shaders/effect_blur.glsl.gen.h"
+
#include "drivers/gles3/shaders/exposure.glsl.gen.h"
#include "drivers/gles3/shaders/resolve.glsl.gen.h"
#include "drivers/gles3/shaders/scene.glsl.gen.h"
@@ -47,7 +49,6 @@
#include "drivers/gles3/shaders/ssao_blur.glsl.gen.h"
#include "drivers/gles3/shaders/ssao_minify.glsl.gen.h"
#include "drivers/gles3/shaders/subsurf_scattering.glsl.gen.h"
-#include "drivers/gles3/shaders/tonemap.glsl.gen.h"
*/
@@ -99,6 +100,8 @@ public:
SceneShaderGLES2 scene_shader;
CubeToDpShaderGLES2 cube_to_dp_shader;
+ TonemapShaderGLES2 tonemap_shader;
+ EffectBlurShaderGLES2 effect_blur_shader;
GLuint sky_verts;
@@ -114,7 +117,6 @@ public:
// SsaoShaderGLES3 ssao_shader;
// SsaoBlurShaderGLES3 ssao_blur_shader;
// ExposureShaderGLES3 exposure_shader;
- // TonemapShaderGLES3 tonemap_shader;
/*
struct SceneDataUBO {
@@ -362,6 +364,35 @@ public:
int canvas_max_layer;
+ bool glow_enabled;
+ int glow_levels;
+ float glow_intensity;
+ float glow_strength;
+ float glow_bloom;
+ VS::EnvironmentGlowBlendMode glow_blend_mode;
+ float glow_hdr_bleed_threshold;
+ float glow_hdr_bleed_scale;
+ float glow_hdr_luminance_cap;
+ bool glow_bicubic_upscale;
+
+ bool dof_blur_far_enabled;
+ float dof_blur_far_distance;
+ float dof_blur_far_transition;
+ float dof_blur_far_amount;
+ VS::EnvironmentDOFBlurQuality dof_blur_far_quality;
+
+ bool dof_blur_near_enabled;
+ float dof_blur_near_distance;
+ float dof_blur_near_transition;
+ float dof_blur_near_amount;
+ VS::EnvironmentDOFBlurQuality dof_blur_near_quality;
+
+ bool adjustments_enabled;
+ float adjustments_brightness;
+ float adjustments_contrast;
+ float adjustments_saturation;
+ RID color_correction;
+
bool fog_enabled;
Color fog_color;
Color fog_sun_color;
@@ -387,6 +418,30 @@ public:
ambient_energy(1.0),
ambient_sky_contribution(0.0),
canvas_max_layer(0),
+ glow_enabled(false),
+ glow_levels((1 << 2) | (1 << 4)),
+ glow_intensity(0.8),
+ glow_strength(1.0),
+ glow_bloom(0.0),
+ glow_blend_mode(VS::GLOW_BLEND_MODE_SOFTLIGHT),
+ glow_hdr_bleed_threshold(1.0),
+ glow_hdr_bleed_scale(2.0),
+ glow_hdr_luminance_cap(12.0),
+ glow_bicubic_upscale(false),
+ dof_blur_far_enabled(false),
+ dof_blur_far_distance(10),
+ dof_blur_far_transition(5),
+ dof_blur_far_amount(0.1),
+ dof_blur_far_quality(VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
+ dof_blur_near_enabled(false),
+ dof_blur_near_distance(2),
+ dof_blur_near_transition(1),
+ dof_blur_near_amount(0.1),
+ dof_blur_near_quality(VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
+ adjustments_enabled(false),
+ adjustments_brightness(1.0),
+ adjustments_contrast(1.0),
+ adjustments_saturation(1.0),
fog_enabled(false),
fog_color(Color(0.5, 0.5, 0.5)),
fog_sun_color(Color(0.8, 0.8, 0.0)),
@@ -674,7 +729,7 @@ public:
void _add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass);
void _add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass);
- void _copy_texture_to_front_buffer(GLuint texture);
+ void _copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer);
void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass);
void _render_render_list(RenderList::Element **p_elements, int p_element_count,
const Transform &p_view_transform,
@@ -698,6 +753,8 @@ public:
_FORCE_INLINE_ void _setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform, Environment *p_env);
_FORCE_INLINE_ void _render_geometry(RenderList::Element *p_element);
+ void _post_process(Environment *env, const CameraMatrix &p_cam_projection);
+
virtual void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count);
virtual bool free(RID p_rid);
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 9f511cd787..1584295b4c 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -82,6 +82,8 @@ GLuint RasterizerStorageGLES2::system_fbo = 0;
#define _DEPTH_COMPONENT24_OES 0x81A6
#ifndef GLES_OVER_GL
+#define glClearDepth glClearDepthf
+
// enable extensions manually for android and ios
#include <dlfcn.h> // needed to load extensions
@@ -4586,6 +4588,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
color_format = GL_RGB;
}
+ rt->used_dof_blur_near = false;
+ rt->mip_maps_allocated = false;
+
{
/* Front FBO */
@@ -4780,6 +4785,127 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
}
}
+ // Allocate mipmap chains for post_process effects
+ if (!rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D] && rt->width >= 2 && rt->height >= 2) {
+
+ for (int i = 0; i < 2; i++) {
+
+ ERR_FAIL_COND(rt->mip_maps[i].sizes.size());
+ int w = rt->width;
+ int h = rt->height;
+
+ if (i > 0) {
+ w >>= 1;
+ h >>= 1;
+ }
+
+ int level = 0;
+ int fb_w = w;
+ int fb_h = h;
+
+ while (true) {
+
+ RenderTarget::MipMaps::Size mm;
+ mm.width = w;
+ mm.height = h;
+ rt->mip_maps[i].sizes.push_back(mm);
+
+ w >>= 1;
+ h >>= 1;
+
+ if (w < 2 || h < 2)
+ break;
+
+ level++;
+ }
+
+ GLsizei width = fb_w;
+ GLsizei height = fb_h;
+
+ if (config.render_to_mipmap_supported) {
+
+ glGenTextures(1, &rt->mip_maps[i].color);
+ glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].color);
+
+ for (int l = 0; l < level + 1; l++) {
+ glTexImage2D(GL_TEXTURE_2D, l, color_internal_format, width, height, 0, color_format, color_type, NULL);
+ width = MAX(1, (width / 2));
+ height = MAX(1, (height / 2));
+ }
+#ifdef GLES_OVER_GL
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
+#endif
+ } else {
+
+ // Can't render to specific levels of a mipmap in ES 2.0 or Webgl so create a texture for each level
+ for (int l = 0; l < level + 1; l++) {
+ glGenTextures(1, &rt->mip_maps[i].sizes.write[l].color);
+ glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[l].color);
+ glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, width, height, 0, color_format, color_type, NULL);
+ width = MAX(1, (width / 2));
+ height = MAX(1, (height / 2));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glColorMask(1, 1, 1, 1);
+ glDepthMask(GL_TRUE);
+
+ for (int j = 0; j < rt->mip_maps[i].sizes.size(); j++) {
+
+ RenderTarget::MipMaps::Size &mm = rt->mip_maps[i].sizes.write[j];
+
+ glGenFramebuffers(1, &mm.fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo);
+
+ if (config.render_to_mipmap_supported) {
+
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].color, j);
+ } else {
+
+ glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color, 0);
+ }
+
+ bool used_depth = false;
+ if (j == 0 && i == 0) { //use always
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
+ used_depth = true;
+ }
+
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE) {
+ WARN_PRINT_ONCE("Cannot allocate mipmaps for 3D post processing effects");
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo);
+ return;
+ }
+
+ glClearColor(1.0, 0.0, 1.0, 0.0);
+ glViewport(0, 0, rt->mip_maps[i].sizes[j].width, rt->mip_maps[i].sizes[j].height);
+ glClear(GL_COLOR_BUFFER_BIT);
+ if (used_depth) {
+ glClearDepth(1.0);
+ glClear(GL_DEPTH_BUFFER_BIT);
+ }
+ }
+
+ rt->mip_maps[i].levels = level;
+
+ if (config.render_to_mipmap_supported) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+ }
+ rt->mip_maps_allocated = true;
+ }
+
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo);
}
@@ -4837,6 +4963,20 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
rt->copy_screen_effect.color = 0;
}
+ for (int i = 0; i < 2; i++) {
+ if (rt->mip_maps[i].sizes.size()) {
+ for (int j = 0; j < rt->mip_maps[i].sizes.size(); j++) {
+ glDeleteFramebuffers(1, &rt->mip_maps[i].sizes[j].fbo);
+ glDeleteTextures(1, &rt->mip_maps[i].sizes[j].color);
+ }
+
+ glDeleteTextures(1, &rt->mip_maps[i].color);
+ rt->mip_maps[i].sizes.clear();
+ rt->mip_maps[i].levels = 0;
+ rt->mip_maps[i].color = 0;
+ }
+ }
+
if (rt->multisample_active) {
glDeleteFramebuffers(1, &rt->multisample_fbo);
rt->multisample_fbo = 0;
@@ -5617,6 +5757,13 @@ void RasterizerStorageGLES2::initialize() {
config.multisample_supported = config.extensions.has("GL_EXT_framebuffer_multisample") || config.extensions.has("GL_EXT_multisampled_render_to_texture") || config.extensions.has("GL_APPLE_framebuffer_multisample");
#ifdef GLES_OVER_GL
+ config.render_to_mipmap_supported = true;
+#else
+ //check if mipmaps can be used for SCREEN_TEXTURE and Glow on Mobile and web platforms
+ config.render_to_mipmap_supported = config.extensions.has("GL_OES_fbo_render_mipmap") && config.extensions.has("GL_EXT_texture_lod");
+#endif
+
+#ifdef GLES_OVER_GL
config.use_rgba_2d_shadows = false;
config.support_depth_texture = true;
config.use_rgba_3d_shadows = false;
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index ba9274b576..2e78910614 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -95,6 +95,7 @@ public:
bool support_shadow_cubemaps;
bool multisample_supported;
+ bool render_to_mipmap_supported;
GLuint depth_internalformat;
GLuint depth_type;
@@ -1140,12 +1141,6 @@ public:
GLuint multisample_depth;
bool multisample_active;
- // TODO post processing effects?
-
- // TODO HDR?
-
- // TODO this is hardcoded for texscreen copies for now
-
struct Effect {
GLuint fbo;
int width;
@@ -1163,6 +1158,27 @@ public:
Effect copy_screen_effect;
+ struct MipMaps {
+
+ struct Size {
+ GLuint fbo;
+ GLuint color;
+ int width;
+ int height;
+ };
+
+ Vector<Size> sizes;
+ GLuint color;
+ int levels;
+
+ MipMaps() :
+ color(0),
+ levels(0) {
+ }
+ };
+
+ MipMaps mip_maps[2];
+
struct External {
GLuint fbo;
GLuint color;
@@ -1182,6 +1198,9 @@ public:
RID texture;
+ bool used_dof_blur_near;
+ bool mip_maps_allocated;
+
RenderTarget() :
fbo(0),
color(0),
@@ -1195,7 +1214,9 @@ public:
width(0),
height(0),
used_in_frame(false),
- msaa(VS::VIEWPORT_MSAA_DISABLED) {
+ msaa(VS::VIEWPORT_MSAA_DISABLED),
+ used_dof_blur_near(false),
+ mip_maps_allocated(false) {
for (int i = 0; i < RENDER_TARGET_FLAG_MAX; ++i) {
flags[i] = false;
}
diff --git a/drivers/gles2/shaders/SCsub b/drivers/gles2/shaders/SCsub
index 085c43319c..d7ae0243e6 100644
--- a/drivers/gles2/shaders/SCsub
+++ b/drivers/gles2/shaders/SCsub
@@ -12,12 +12,12 @@ if 'GLES2_GLSL' in env['BUILDERS']:
env.GLES2_GLSL('cube_to_dp.glsl');
# env.GLES2_GLSL('blend_shape.glsl');
# env.GLES2_GLSL('screen_space_reflection.glsl');
-# env.GLES2_GLSL('effect_blur.glsl');
+ env.GLES2_GLSL('effect_blur.glsl');
# env.GLES2_GLSL('subsurf_scattering.glsl');
# env.GLES2_GLSL('ssao.glsl');
# env.GLES2_GLSL('ssao_minify.glsl');
# env.GLES2_GLSL('ssao_blur.glsl');
# env.GLES2_GLSL('exposure.glsl');
-# env.GLES2_GLSL('tonemap.glsl');
+ env.GLES2_GLSL('tonemap.glsl');
# env.GLES2_GLSL('particles.glsl');
env.GLES2_GLSL('lens_distorted.glsl');
diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl
index dcb43d523f..7a5ba4f571 100644
--- a/drivers/gles2/shaders/canvas_shadow.glsl
+++ b/drivers/gles2/shaders/canvas_shadow.glsl
@@ -34,9 +34,14 @@ void main() {
#define mediump
#define highp
#else
+#if defined(USE_HIGHP_PRECISION)
+precision highp float;
+precision highp int;
+#else
precision mediump float;
precision mediump int;
#endif
+#endif
varying highp vec4 position_interp;
/* clang-format on */
diff --git a/drivers/gles2/shaders/cube_to_dp.glsl b/drivers/gles2/shaders/cube_to_dp.glsl
index cb4b3f6dec..769908c3b4 100644
--- a/drivers/gles2/shaders/cube_to_dp.glsl
+++ b/drivers/gles2/shaders/cube_to_dp.glsl
@@ -30,9 +30,14 @@ void main() {
#define mediump
#define highp
#else
+#if defined(USE_HIGHP_PRECISION)
+precision highp float;
+precision highp int;
+#else
precision mediump float;
precision mediump int;
#endif
+#endif
uniform highp samplerCube source_cube; //texunit:0
/* clang-format on */
diff --git a/drivers/gles2/shaders/effect_blur.glsl b/drivers/gles2/shaders/effect_blur.glsl
index df79e89931..b28d78a6ca 100644
--- a/drivers/gles2/shaders/effect_blur.glsl
+++ b/drivers/gles2/shaders/effect_blur.glsl
@@ -1,11 +1,20 @@
/* clang-format off */
[vertex]
-layout(location = 0) in highp vec4 vertex_attrib;
+#ifdef USE_GLES_OVER_GL
+#define lowp
+#define mediump
+#define highp
+#else
+precision highp float;
+precision highp int;
+#endif
+
+attribute vec2 vertex_attrib; // attrib:0
/* clang-format on */
-layout(location = 4) in vec2 uv_in;
+attribute vec2 uv_in; // attrib:4
-out vec2 uv_interp;
+varying vec2 uv_interp;
#ifdef USE_BLUR_SECTION
@@ -16,7 +25,7 @@ uniform vec4 blur_section;
void main() {
uv_interp = uv_in;
- gl_Position = vertex_attrib;
+ gl_Position = vec4(vertex_attrib, 0.0, 1.0);
#ifdef USE_BLUR_SECTION
uv_interp = blur_section.xy + uv_interp * blur_section.zw;
@@ -27,29 +36,46 @@ void main() {
/* clang-format off */
[fragment]
-#if !defined(GLES_OVER_GL)
+// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
+// Do not copy these defines in the vertex section.
+#ifndef USE_GLES_OVER_GL
+#ifdef GL_EXT_shader_texture_lod
+#extension GL_EXT_shader_texture_lod : enable
+#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
+#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
+#endif
+#endif // !USE_GLES_OVER_GL
+
+#ifdef GL_ARB_shader_texture_lod
+#extension GL_ARB_shader_texture_lod : enable
+#endif
+
+#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
+#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
+#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
+#endif
+
+#ifdef USE_GLES_OVER_GL
+#define lowp
+#define mediump
+#define highp
+#else
+#if defined(USE_HIGHP_PRECISION)
+precision highp float;
+precision highp int;
+#else
precision mediump float;
+precision mediump int;
+#endif
#endif
-in vec2 uv_interp;
+varying vec2 uv_interp;
/* clang-format on */
uniform sampler2D source_color; //texunit:0
-#ifdef SSAO_MERGE
-uniform sampler2D source_ssao; //texunit:1
-#endif
-
uniform float lod;
uniform vec2 pixel_size;
-layout(location = 0) out vec4 frag_color;
-
-#ifdef SSAO_MERGE
-
-uniform vec4 ssao_color;
-
-#endif
-
#if defined(GLOW_GAUSSIAN_HORIZONTAL) || defined(GLOW_GAUSSIAN_VERTICAL)
uniform float glow_strength;
@@ -58,6 +84,7 @@ uniform float glow_strength;
#if defined(DOF_FAR_BLUR) || defined(DOF_NEAR_BLUR)
+#ifdef USE_GLES_OVER_GL
#ifdef DOF_QUALITY_LOW
const int dof_kernel_size = 5;
const int dof_kernel_from = 2;
@@ -76,6 +103,7 @@ const int dof_kernel_size = 21;
const int dof_kernel_from = 10;
const float dof_kernel[21] = float[](0.028174, 0.032676, 0.037311, 0.041944, 0.046421, 0.050582, 0.054261, 0.057307, 0.059587, 0.060998, 0.061476, 0.060998, 0.059587, 0.057307, 0.054261, 0.050582, 0.046421, 0.041944, 0.037311, 0.032676, 0.028174);
#endif
+#endif
uniform sampler2D dof_source_depth; //texunit:1
uniform float dof_begin;
@@ -83,24 +111,11 @@ uniform float dof_end;
uniform vec2 dof_dir;
uniform float dof_radius;
-#ifdef DOF_NEAR_BLUR_MERGE
-
-uniform sampler2D source_dof_original; //texunit:2
-#endif
-
#endif
#ifdef GLOW_FIRST_PASS
-uniform float exposure;
-uniform float white;
-
-#ifdef GLOW_USE_AUTO_EXPOSURE
-
-uniform highp sampler2D source_auto_exposure; //texunit:1
-uniform highp float auto_exposure_grey;
-
-#endif
+uniform highp float luminance_cap;
uniform float glow_bloom;
uniform float glow_hdr_threshold;
@@ -113,60 +128,95 @@ uniform float camera_z_near;
void main() {
-#ifdef GAUSSIAN_HORIZONTAL
+#ifdef GLOW_GAUSSIAN_HORIZONTAL
vec2 pix_size = pixel_size;
pix_size *= 0.5; //reading from larger buffer, so use more samples
- // sigma 2
- vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.214607;
- color += textureLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.189879;
- color += textureLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.131514;
- color += textureLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.071303;
- color += textureLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.189879;
- color += textureLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.131514;
- color += textureLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.071303;
- frag_color = color;
+ vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938;
+ color += texture2DLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569;
+ color += texture2DLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367;
+ color += texture2DLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595;
+ color += texture2DLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569;
+ color += texture2DLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367;
+ color += texture2DLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595;
+ color *= glow_strength;
+ gl_FragColor = color;
#endif
-#ifdef GAUSSIAN_VERTICAL
- vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.38774;
- color += textureLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.24477;
- color += textureLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.06136;
- color += textureLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.24477;
- color += textureLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.06136;
- frag_color = color;
+#ifdef GLOW_GAUSSIAN_VERTICAL
+ vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713;
+ color += texture2DLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062;
+ color += texture2DLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581;
+ color += texture2DLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062;
+ color += texture2DLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581;
+ color *= glow_strength;
+ gl_FragColor = color;
#endif
- //glow uses larger sigma for a more rounded blur effect
+#ifndef USE_GLES_OVER_GL
+#if defined(DOF_FAR_BLUR) || defined(DOF_NEAR_BLUR)
-#ifdef GLOW_GAUSSIAN_HORIZONTAL
- vec2 pix_size = pixel_size;
- pix_size *= 0.5; //reading from larger buffer, so use more samples
- vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938;
- color += textureLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569;
- color += textureLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367;
- color += textureLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595;
- color += textureLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569;
- color += textureLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367;
- color += textureLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595;
- color *= glow_strength;
- frag_color = color;
+#ifdef DOF_QUALITY_LOW
+ const int dof_kernel_size = 5;
+ const int dof_kernel_from = 2;
+ float dof_kernel[5];
+ dof_kernel[0] = 0.153388;
+ dof_kernel[1] = 0.221461;
+ dof_kernel[2] = 0.250301;
+ dof_kernel[3] = 0.221461;
+ dof_kernel[4] = 0.153388;
#endif
-#ifdef GLOW_GAUSSIAN_VERTICAL
- vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713;
- color += textureLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062;
- color += textureLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581;
- color += textureLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062;
- color += textureLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581;
- color *= glow_strength;
- frag_color = color;
+#ifdef DOF_QUALITY_MEDIUM
+ const int dof_kernel_size = 11;
+ const int dof_kernel_from = 5;
+ float dof_kernel[11];
+ dof_kernel[0] = 0.055037;
+ dof_kernel[1] = 0.072806;
+ dof_kernel[2] = 0.090506;
+ dof_kernel[3] = 0.105726;
+ dof_kernel[4] = 0.116061;
+ dof_kernel[5] = 0.119726;
+ dof_kernel[6] = 0.116061;
+ dof_kernel[7] = 0.105726;
+ dof_kernel[8] = 0.090506;
+ dof_kernel[9] = 0.072806;
+ dof_kernel[10] = 0.055037;
#endif
+#ifdef DOF_QUALITY_HIGH
+ const int dof_kernel_size = 21;
+ const int dof_kernel_from = 10;
+ float dof_kernel[21];
+ dof_kernel[0] = 0.028174;
+ dof_kernel[1] = 0.032676;
+ dof_kernel[2] = 0.037311;
+ dof_kernel[3] = 0.041944;
+ dof_kernel[4] = 0.046421;
+ dof_kernel[5] = 0.050582;
+ dof_kernel[6] = 0.054261;
+ dof_kernel[7] = 0.057307;
+ dof_kernel[8] = 0.059587;
+ dof_kernel[9] = 0.060998;
+ dof_kernel[10] = 0.061476;
+ dof_kernel[11] = 0.060998;
+ dof_kernel[12] = 0.059587;
+ dof_kernel[13] = 0.057307;
+ dof_kernel[14] = 0.054261;
+ dof_kernel[15] = 0.050582;
+ dof_kernel[16] = 0.046421;
+ dof_kernel[17] = 0.041944;
+ dof_kernel[18] = 0.037311;
+ dof_kernel[19] = 0.032676;
+ dof_kernel[20] = 0.028174;
+#endif
+#endif
+#endif //!USE_GLES_OVER_GL
+
#ifdef DOF_FAR_BLUR
vec4 color_accum = vec4(0.0);
- float depth = textureLod(dof_source_depth, uv_interp, 0.0).r;
+ float depth = texture2DLod(dof_source_depth, uv_interp, 0.0).r;
depth = depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
depth = ((depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
@@ -184,17 +234,17 @@ void main() {
float tap_k = dof_kernel[i];
- float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
+ float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
#else
tap_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - tap_depth * (camera_z_far - camera_z_near));
#endif
- float tap_amount = mix(smoothstep(dof_begin, dof_end, tap_depth), 1.0, int_ofs == 0);
+ float tap_amount = int_ofs == 0 ? 1.0 : smoothstep(dof_begin, dof_end, tap_depth);
tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect
- vec4 tap_color = textureLod(source_color, tap_uv, 0.0) * tap_k;
+ vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0) * tap_k;
k_accum += tap_k * tap_amount;
color_accum += tap_color * tap_amount;
@@ -204,7 +254,7 @@ void main() {
color_accum /= k_accum;
}
- frag_color = color_accum; ///k_accum;
+ gl_FragColor = color_accum; ///k_accum;
#endif
@@ -212,19 +262,19 @@ void main() {
vec4 color_accum = vec4(0.0);
- float max_accum = 0;
+ float max_accum = 0.0;
for (int i = 0; i < dof_kernel_size; i++) {
int int_ofs = i - dof_kernel_from;
vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * dof_radius;
- float ofs_influence = max(0.0, 1.0 - float(abs(int_ofs)) / float(dof_kernel_from));
+ float ofs_influence = max(0.0, 1.0 - abs(float(int_ofs)) / float(dof_kernel_from));
float tap_k = dof_kernel[i];
- vec4 tap_color = textureLod(source_color, tap_uv, 0.0);
+ vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0);
- float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
+ float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
@@ -247,46 +297,16 @@ void main() {
color_accum.a = max(color_accum.a, sqrt(max_accum));
-#ifdef DOF_NEAR_BLUR_MERGE
-
- vec4 original = textureLod(source_dof_original, uv_interp, 0.0);
- color_accum = mix(original, color_accum, color_accum.a);
-
-#endif
-
-#ifndef DOF_NEAR_FIRST_TAP
- //color_accum=vec4(vec3(color_accum.a),1.0);
-#endif
- frag_color = color_accum;
+ gl_FragColor = color_accum;
#endif
#ifdef GLOW_FIRST_PASS
-#ifdef GLOW_USE_AUTO_EXPOSURE
-
- frag_color /= texelFetch(source_auto_exposure, ivec2(0, 0), 0).r / auto_exposure_grey;
-#endif
- frag_color *= exposure;
-
- float luminance = max(frag_color.r, max(frag_color.g, frag_color.b));
+ float luminance = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b));
float feedback = max(smoothstep(glow_hdr_threshold, glow_hdr_threshold + glow_hdr_scale, luminance), glow_bloom);
- frag_color *= feedback;
-
-#endif
-
-#ifdef SIMPLE_COPY
- vec4 color = textureLod(source_color, uv_interp, 0.0);
- frag_color = color;
-#endif
-
-#ifdef SSAO_MERGE
-
- vec4 color = textureLod(source_color, uv_interp, 0.0);
- float ssao = textureLod(source_ssao, uv_interp, 0.0).r;
-
- frag_color = vec4(mix(color.rgb, color.rgb * mix(ssao_color.rgb, vec3(1.0), ssao), color.a), 1.0);
+ gl_FragColor = min(gl_FragColor * feedback, vec4(luminance_cap));
#endif
}
diff --git a/drivers/gles2/shaders/lens_distorted.glsl b/drivers/gles2/shaders/lens_distorted.glsl
index 81898a75a5..f4ff80ba9a 100644
--- a/drivers/gles2/shaders/lens_distorted.glsl
+++ b/drivers/gles2/shaders/lens_distorted.glsl
@@ -34,8 +34,13 @@ void main() {
#define mediump
#define highp
#else
-precision mediump float;
+#if defined(USE_HIGHP_PRECISION)
+precision highp float;
precision highp int;
+#else
+precision mediump float;
+precision mediump int;
+#endif
#endif
uniform sampler2D source; //texunit:0
diff --git a/drivers/gles2/shaders/tonemap.glsl b/drivers/gles2/shaders/tonemap.glsl
index eae3b5a1ca..585d821626 100644
--- a/drivers/gles2/shaders/tonemap.glsl
+++ b/drivers/gles2/shaders/tonemap.glsl
@@ -1,66 +1,103 @@
/* clang-format off */
[vertex]
-layout(location = 0) in highp vec4 vertex_attrib;
+#ifdef USE_GLES_OVER_GL
+#define lowp
+#define mediump
+#define highp
+#else
+precision highp float;
+precision highp int;
+#endif
+
+attribute vec2 vertex_attrib; // attrib:0
/* clang-format on */
-layout(location = 4) in vec2 uv_in;
+attribute vec2 uv_in; // attrib:4
-out vec2 uv_interp;
+varying vec2 uv_interp;
void main() {
+ gl_Position = vec4(vertex_attrib, 0.0, 1.0);
- gl_Position = vertex_attrib;
uv_interp = uv_in;
-#ifdef V_FLIP
- uv_interp.y = 1.0 - uv_interp.y;
-#endif
}
/* clang-format off */
[fragment]
-#if !defined(GLES_OVER_GL)
-precision mediump float;
+
+// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
+// Do not copy these defines in the vertex section.
+#ifndef USE_GLES_OVER_GL
+#ifdef GL_EXT_shader_texture_lod
+#extension GL_EXT_shader_texture_lod : enable
+#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
+#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
+#endif // !USE_GLES_OVER_GL
-in vec2 uv_interp;
-/* clang-format on */
+#ifdef GL_ARB_shader_texture_lod
+#extension GL_ARB_shader_texture_lod : enable
+#endif
-uniform highp sampler2D source; //texunit:0
+#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
+#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
+#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
+#endif
-uniform float exposure;
-uniform float white;
+// Allows the use of bitshift operators for bicubic upscale
+#ifdef GL_EXT_gpu_shader4
+#extension GL_EXT_gpu_shader4 : enable
+#endif
-#ifdef USE_AUTO_EXPOSURE
+#ifdef USE_GLES_OVER_GL
+#define lowp
+#define mediump
+#define highp
+#else
+#if defined(USE_HIGHP_PRECISION)
+precision highp float;
+precision highp int;
+#else
+precision mediump float;
+precision mediump int;
+#endif
+#endif
-uniform highp sampler2D source_auto_exposure; //texunit:1
-uniform highp float auto_exposure_grey;
+#include "stdlib.glsl"
-#endif
+varying vec2 uv_interp;
+/* clang-format on */
-#if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7)
+uniform highp sampler2D source; //texunit:0
-uniform highp sampler2D source_glow; //texunit:2
+#if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7)
+#define USING_GLOW // only use glow when at least one glow level is selected
+
+#ifdef USE_MULTI_TEXTURE_GLOW
+uniform highp sampler2D source_glow1; //texunit:1
+uniform highp sampler2D source_glow2; //texunit:2
+uniform highp sampler2D source_glow3; //texunit:3
+uniform highp sampler2D source_glow4; //texunit:4
+uniform highp sampler2D source_glow5; //texunit:5
+uniform highp sampler2D source_glow6; //texunit:6
+uniform highp sampler2D source_glow7; //texunit:7
+#else
+uniform highp sampler2D source_glow; //texunit:1
+#endif
uniform highp float glow_intensity;
-
#endif
#ifdef USE_BCS
-
uniform vec3 bcs;
-
#endif
#ifdef USE_COLOR_CORRECTION
-
-uniform sampler2D color_correction; //texunit:3
-
+uniform sampler2D color_correction; //texunit:2
#endif
-layout(location = 0) out vec4 frag_color;
-
+#ifdef GL_EXT_gpu_shader4
#ifdef USE_GLOW_FILTER_BICUBIC
-
// w0, w1, w2, and w3 are the four cubic B-spline basis functions
float w0(float a) {
return (1.0 / 6.0) * (a * (a * (-a + 3.0) - 3.0) + 1.0);
@@ -101,8 +138,10 @@ uniform ivec2 glow_texture_size;
vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) {
float lod = float(p_lod);
vec2 tex_size = vec2(glow_texture_size >> p_lod);
- vec2 pixel_size = 1.0 / tex_size;
- uv = uv * tex_size + 0.5;
+ vec2 pixel_size = vec2(1.0) / tex_size;
+
+ uv = uv * tex_size + vec2(0.5);
+
vec2 iuv = floor(uv);
vec2 fuv = fract(uv);
@@ -113,73 +152,97 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) {
float h0y = h0(fuv.y);
float h1y = h1(fuv.y);
- vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * pixel_size;
- vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * pixel_size;
- vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * pixel_size;
- vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * pixel_size;
+ vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - vec2(0.5)) * pixel_size;
+ vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - vec2(0.5)) * pixel_size;
+ vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * pixel_size;
+ vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * pixel_size;
- return (g0(fuv.y) * (g0x * textureLod(tex, p0, lod) + g1x * textureLod(tex, p1, lod))) +
- (g1(fuv.y) * (g0x * textureLod(tex, p2, lod) + g1x * textureLod(tex, p3, lod)));
+ return (g0(fuv.y) * (g0x * texture2DLod(tex, p0, lod) + g1x * texture2DLod(tex, p1, lod))) +
+ (g1(fuv.y) * (g0x * texture2DLod(tex, p2, lod) + g1x * texture2DLod(tex, p3, lod)));
}
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2D_bicubic(m_tex, m_uv, m_lod)
+#else //!USE_GLOW_FILTER_BICUBIC
+#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod))
+#endif //USE_GLOW_FILTER_BICUBIC
-#else
+#else //!GL_EXT_gpu_shader4
+#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod))
+#endif //GL_EXT_gpu_shader4
-#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) textureLod(m_tex, m_uv, float(m_lod))
+vec3 apply_glow(vec3 color, vec3 glow) { // apply glow using the selected blending mode
+#ifdef USE_GLOW_REPLACE
+ color = glow;
+#endif
+#ifdef USE_GLOW_SCREEN
+ color = max((color + glow) - (color * glow), vec3(0.0));
#endif
-vec3 tonemap_filmic(vec3 color, float white) {
+#ifdef USE_GLOW_SOFTLIGHT
+ glow = glow * vec3(0.5) + vec3(0.5);
- float A = 0.15;
- float B = 0.50;
- float C = 0.10;
- float D = 0.20;
- float E = 0.02;
- float F = 0.30;
- float W = 11.2;
+ color.r = (glow.r <= 0.5) ? (color.r - (1.0 - 2.0 * glow.r) * color.r * (1.0 - color.r)) : (((glow.r > 0.5) && (color.r <= 0.25)) ? (color.r + (2.0 * glow.r - 1.0) * (4.0 * color.r * (4.0 * color.r + 1.0) * (color.r - 1.0) + 7.0 * color.r)) : (color.r + (2.0 * glow.r - 1.0) * (sqrt(color.r) - color.r)));
+ color.g = (glow.g <= 0.5) ? (color.g - (1.0 - 2.0 * glow.g) * color.g * (1.0 - color.g)) : (((glow.g > 0.5) && (color.g <= 0.25)) ? (color.g + (2.0 * glow.g - 1.0) * (4.0 * color.g * (4.0 * color.g + 1.0) * (color.g - 1.0) + 7.0 * color.g)) : (color.g + (2.0 * glow.g - 1.0) * (sqrt(color.g) - color.g)));
+ color.b = (glow.b <= 0.5) ? (color.b - (1.0 - 2.0 * glow.b) * color.b * (1.0 - color.b)) : (((glow.b > 0.5) && (color.b <= 0.25)) ? (color.b + (2.0 * glow.b - 1.0) * (4.0 * color.b * (4.0 * color.b + 1.0) * (color.b - 1.0) + 7.0 * color.b)) : (color.b + (2.0 * glow.b - 1.0) * (sqrt(color.b) - color.b)));
+#endif
- vec3 coltn = ((color * (A * color + C * B) + D * E) / (color * (A * color + B) + D * F)) - E / F;
- float whitetn = ((white * (A * white + C * B) + D * E) / (white * (A * white + B) + D * F)) - E / F;
+#if !defined(USE_GLOW_SCREEN) && !defined(USE_GLOW_SOFTLIGHT) && !defined(USE_GLOW_REPLACE) // no other selected -> additive
+ color += glow;
+#endif
- return coltn / whitetn;
+ return color;
}
-vec3 tonemap_aces(vec3 color) {
- float a = 2.51f;
- float b = 0.03f;
- float c = 2.43f;
- float d = 0.59f;
- float e = 0.14f;
- return color = clamp((color * (a * color + b)) / (color * (c * color + d) + e), vec3(0.0), vec3(1.0));
+vec3 apply_bcs(vec3 color, vec3 bcs) {
+ color = mix(vec3(0.0), color, bcs.x);
+ color = mix(vec3(0.5), color, bcs.y);
+ color = mix(vec3(dot(vec3(1.0), color) * 0.33333), color, bcs.z);
+
+ return color;
}
-vec3 tonemap_reindhart(vec3 color, float white) {
+vec3 apply_color_correction(vec3 color, sampler2D correction_tex) {
+ color.r = texture2D(correction_tex, vec2(color.r, 0.0)).r;
+ color.g = texture2D(correction_tex, vec2(color.g, 0.0)).g;
+ color.b = texture2D(correction_tex, vec2(color.b, 0.0)).b;
- return (color * (1.0 + (color / (white)))) / (1.0 + color);
+ return color;
}
void main() {
+ vec3 color = texture2DLod(source, uv_interp, 0.0).rgb;
- vec4 color = textureLod(source, uv_interp, 0.0);
+ // Glow
-#ifdef USE_AUTO_EXPOSURE
-
- color /= texelFetch(source_auto_exposure, ivec2(0, 0), 0).r / auto_exposure_grey;
+#ifdef USING_GLOW
+ vec3 glow = vec3(0.0);
+#ifdef USE_MULTI_TEXTURE_GLOW
+#ifdef USE_GLOW_LEVEL1
+ glow += GLOW_TEXTURE_SAMPLE(source_glow1, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL2
+ glow += GLOW_TEXTURE_SAMPLE(source_glow2, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL3
+ glow += GLOW_TEXTURE_SAMPLE(source_glow3, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL4
+ glow += GLOW_TEXTURE_SAMPLE(source_glow4, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL5
+ glow += GLOW_TEXTURE_SAMPLE(source_glow5, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL6
+ glow += GLOW_TEXTURE_SAMPLE(source_glow6, uv_interp, 0).rgb;
+#ifdef USE_GLOW_LEVEL7
+ glow += GLOW_TEXTURE_SAMPLE(source_glow7, uv_interp, 0).rgb;
+#endif
+#endif
+#endif
+#endif
+#endif
#endif
-
- color *= exposure;
-
-#if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7)
-#define USING_GLOW
#endif
-#if defined(USING_GLOW)
- vec3 glow = vec3(0.0);
+#else
#ifdef USE_GLOW_LEVEL1
-
glow += GLOW_TEXTURE_SAMPLE(source_glow, uv_interp, 1).rgb;
#endif
@@ -206,100 +269,21 @@ void main() {
#ifdef USE_GLOW_LEVEL7
glow += GLOW_TEXTURE_SAMPLE(source_glow, uv_interp, 7).rgb;
#endif
+#endif //USE_MULTI_TEXTURE_GLOW
glow *= glow_intensity;
-
-#endif
-
-#ifdef USE_REINDHART_TONEMAPPER
-
- color.rgb = tonemap_reindhart(color.rgb, white);
-
-#if defined(USING_GLOW)
- glow = tonemap_reindhart(glow, white);
-#endif
-
+ color = apply_glow(color, glow);
#endif
-#ifdef USE_FILMIC_TONEMAPPER
-
- color.rgb = tonemap_filmic(color.rgb, white);
-
-#if defined(USING_GLOW)
- glow = tonemap_filmic(glow, white);
-#endif
-
-#endif
-
-#ifdef USE_ACES_TONEMAPPER
-
- color.rgb = tonemap_aces(color.rgb);
-
-#if defined(USING_GLOW)
- glow = tonemap_aces(glow);
-#endif
-
-#endif
-
- //regular Linear -> SRGB conversion
- vec3 a = vec3(0.055);
- color.rgb = mix((vec3(1.0) + a) * pow(color.rgb, vec3(1.0 / 2.4)) - a, 12.92 * color.rgb, lessThan(color.rgb, vec3(0.0031308)));
-
-#if defined(USING_GLOW)
- glow = mix((vec3(1.0) + a) * pow(glow, vec3(1.0 / 2.4)) - a, 12.92 * glow, lessThan(glow, vec3(0.0031308)));
-#endif
-
- //glow needs to be added in SRGB space (together with image space effects)
-
- color.rgb = clamp(color.rgb, 0.0, 1.0);
-
-#if defined(USING_GLOW)
- glow = clamp(glow, 0.0, 1.0);
-#endif
-
-#ifdef USE_GLOW_REPLACE
-
- color.rgb = glow;
-
-#endif
-
-#ifdef USE_GLOW_SCREEN
-
- color.rgb = max((color.rgb + glow) - (color.rgb * glow), vec3(0.0));
-
-#endif
-
-#ifdef USE_GLOW_SOFTLIGHT
-
- {
-
- glow = (glow * 0.5) + 0.5;
- color.r = (glow.r <= 0.5) ? (color.r - (1.0 - 2.0 * glow.r) * color.r * (1.0 - color.r)) : (((glow.r > 0.5) && (color.r <= 0.25)) ? (color.r + (2.0 * glow.r - 1.0) * (4.0 * color.r * (4.0 * color.r + 1.0) * (color.r - 1.0) + 7.0 * color.r)) : (color.r + (2.0 * glow.r - 1.0) * (sqrt(color.r) - color.r)));
- color.g = (glow.g <= 0.5) ? (color.g - (1.0 - 2.0 * glow.g) * color.g * (1.0 - color.g)) : (((glow.g > 0.5) && (color.g <= 0.25)) ? (color.g + (2.0 * glow.g - 1.0) * (4.0 * color.g * (4.0 * color.g + 1.0) * (color.g - 1.0) + 7.0 * color.g)) : (color.g + (2.0 * glow.g - 1.0) * (sqrt(color.g) - color.g)));
- color.b = (glow.b <= 0.5) ? (color.b - (1.0 - 2.0 * glow.b) * color.b * (1.0 - color.b)) : (((glow.b > 0.5) && (color.b <= 0.25)) ? (color.b + (2.0 * glow.b - 1.0) * (4.0 * color.b * (4.0 * color.b + 1.0) * (color.b - 1.0) + 7.0 * color.b)) : (color.b + (2.0 * glow.b - 1.0) * (sqrt(color.b) - color.b)));
- }
-
-#endif
-
-#if defined(USING_GLOW) && !defined(USE_GLOW_SCREEN) && !defined(USE_GLOW_SOFTLIGHT) && !defined(USE_GLOW_REPLACE)
- //additive
- color.rgb += glow;
-#endif
+ // Additional effects
#ifdef USE_BCS
-
- color.rgb = mix(vec3(0.0), color.rgb, bcs.x);
- color.rgb = mix(vec3(0.5), color.rgb, bcs.y);
- color.rgb = mix(vec3(dot(vec3(1.0), color.rgb) * 0.33333), color.rgb, bcs.z);
-
+ color = apply_bcs(color, bcs);
#endif
#ifdef USE_COLOR_CORRECTION
-
- color.r = texture(color_correction, vec2(color.r, 0.0)).r;
- color.g = texture(color_correction, vec2(color.g, 0.0)).g;
- color.b = texture(color_correction, vec2(color.b, 0.0)).b;
+ color = apply_color_correction(color, color_correction);
#endif
- frag_color = vec4(color.rgb, 1.0);
+ gl_FragColor = vec4(color, 1.0);
}
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 80d7a2ccaa..b3d98a0648 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -187,7 +187,7 @@ uint64_t OS_Unix::get_system_time_secs() const {
uint64_t OS_Unix::get_system_time_msecs() const {
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
- return uint64_t(tv_now.tv_sec * 1000 + tv_now.tv_usec / 1000);
+ return uint64_t(tv_now.tv_sec) * 1000 + uint64_t(tv_now.tv_usec) / 1000;
}
OS::Date OS_Unix::get_date(bool utc) const {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index b6cd69c3cd..4c31797c50 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -456,10 +456,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
void FindReplaceBar::popup_search(bool p_show_only) {
- if (!is_visible())
- replace_text->hide();
+ replace_text->hide();
hbc_button_replace->hide();
hbc_option_replace->hide();
+
_show_search(false, p_show_only);
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 30ce2ef6e6..c5b84f0af1 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -359,8 +359,8 @@ void VisualShaderEditor::_update_options_menu() {
case VisualShaderNode::PORT_TYPE_TRANSFORM:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"));
break;
- case VisualShaderNode::PORT_TYPE_ICON_COLOR:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Color", "EditorIcons"));
+ case VisualShaderNode::PORT_TYPE_SAMPLER:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"));
break;
default:
break;
@@ -437,11 +437,12 @@ void VisualShaderEditor::_update_graph() {
}
}
- static const Color type_color[4] = {
+ static const Color type_color[5] = {
Color(0.38, 0.85, 0.96), // scalar
Color(0.84, 0.49, 0.93), // vector
Color(0.55, 0.65, 0.94), // boolean
- Color(0.96, 0.66, 0.43) // transform
+ Color(0.96, 0.66, 0.43), // transform
+ Color(1.0, 1.0, 0.0) // sampler
};
List<VisualShader::Connection> connections;
@@ -640,6 +641,7 @@ void VisualShaderEditor::_update_graph() {
type_box->add_item(TTR("Vector"));
type_box->add_item(TTR("Boolean"));
type_box->add_item(TTR("Transform"));
+ type_box->add_item(TTR("Sampler"));
type_box->select(group_node->get_input_port_type(i));
type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
type_box->connect("item_selected", this, "_change_input_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED);
@@ -704,7 +706,7 @@ void VisualShaderEditor::_update_graph() {
}
}
- if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM) {
+ if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) {
TextureButton *preview = memnew(TextureButton);
preview->set_toggle_mode(true);
preview->set_normal_texture(get_icon("GuiVisibilityHidden", "EditorIcons"));
@@ -731,15 +733,19 @@ void VisualShaderEditor::_update_graph() {
node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]);
}
- if (vsnode->get_output_port_for_preview() >= 0 && vsnode->get_output_port_type(vsnode->get_output_port_for_preview()) != VisualShaderNode::PORT_TYPE_TRANSFORM) {
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
- node->add_child(offset);
+ if (vsnode->get_output_port_for_preview() >= 0) {
+ int port_type = vsnode->get_output_port_type(vsnode->get_output_port_for_preview());
+
+ if (port_type != VisualShaderNode::PORT_TYPE_TRANSFORM && port_type != VisualShaderNode::PORT_TYPE_SAMPLER) {
+ offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
+ node->add_child(offset);
- VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
- port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview());
- port_preview->set_h_size_flags(SIZE_SHRINK_CENTER);
- node->add_child(port_preview);
+ VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
+ port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview());
+ port_preview->set_h_size_flags(SIZE_SHRINK_CENTER);
+ node->add_child(port_preview);
+ }
}
offset = memnew(Control);
@@ -1213,9 +1219,14 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node,
editing_port = p_port;
}
-void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
+void VisualShaderEditor::_add_texture_node(const String &p_path) {
+ VisualShaderNodeTexture *texture = (VisualShaderNodeTexture *)_add_node(texture_node_option_idx, -1);
+ texture->set_texture(ResourceLoader::load(p_path));
+}
+
+VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
- ERR_FAIL_INDEX(p_idx, add_options.size());
+ ERR_FAIL_INDEX_V(p_idx, add_options.size(), NULL);
Ref<VisualShaderNode> vsnode;
@@ -1223,7 +1234,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
if (!is_custom && add_options[p_idx].type != String()) {
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type));
- ERR_FAIL_COND(!vsn);
+ ERR_FAIL_COND_V(!vsn, NULL);
VisualShaderNodeScalarConstant *constant = Object::cast_to<VisualShaderNodeScalarConstant>(vsn);
@@ -1309,10 +1320,10 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
vsnode = Ref<VisualShaderNode>(vsn);
} else {
- ERR_FAIL_COND(add_options[p_idx].script.is_null());
+ ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), NULL);
String base_type = add_options[p_idx].script->get_instance_base_type();
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(base_type));
- ERR_FAIL_COND(!vsn);
+ ERR_FAIL_COND_V(!vsn, NULL);
vsnode = Ref<VisualShaderNode>(vsn);
vsnode->set_script(add_options[p_idx].script.get_ref_ptr());
}
@@ -1367,6 +1378,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
+ return vsnode.ptr();
}
void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) {
@@ -2038,6 +2050,9 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
if (d.has("id")) {
return true;
}
+ if (d.has("files")) {
+ return true;
+ }
}
return false;
@@ -2054,6 +2069,20 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
saved_node_pos = p_point;
saved_node_pos_dirty = true;
_add_node(idx, add_options[idx].sub_func);
+ } else if (d.has("files")) {
+ if (d["files"].get_type() == Variant::POOL_STRING_ARRAY) {
+
+ PoolStringArray arr = d["files"];
+ for (int i = 0; i < arr.size(); i++) {
+
+ String type = ResourceLoader::get_resource_type(arr[i]);
+ if (ClassDB::get_parent_class(type) == "Texture") {
+ saved_node_pos = p_point + Vector2(0, i * 210 * EDSCALE);
+ saved_node_pos_dirty = true;
+ _add_texture_node(arr[i]);
+ }
+ }
+ }
}
}
}
@@ -2191,6 +2220,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_TRANSFORM);
+ graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SAMPLER);
//graph->add_valid_left_disconnect_type(0);
graph->set_v_size_flags(SIZE_EXPAND_FILL);
graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED);
@@ -2214,6 +2244,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SAMPLER, VisualShaderNode::PORT_TYPE_SAMPLER);
VSeparator *vs = memnew(VSeparator);
graph->get_zoom_hbox()->add_child(vs);
@@ -2350,8 +2381,8 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Screen", "Color", "Operators", "VisualShaderNodeColorOp", TTR("Screen operator."), VisualShaderNodeColorOp::OP_SCREEN, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("SoftLight", "Color", "Operators", "VisualShaderNodeColorOp", TTR("SoftLight operator."), VisualShaderNodeColorOp::OP_SOFT_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
- add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
+ add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), -1, -1));
+ add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), -1, -1));
// CONDITIONAL
@@ -2557,12 +2588,13 @@ VisualShaderEditor::VisualShaderEditor() {
// TEXTURES
- add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
- add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
+ add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1));
+ texture_node_option_idx = add_options.size();
+ add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1));
- add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
- add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR));
- add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, -1));
+ add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1));
+ add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
// TRANSFORM
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index cd5efc366b..d56e223057 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -148,11 +148,13 @@ class VisualShaderEditor : public VBoxContainer {
};
Vector<AddOption> add_options;
+ int texture_node_option_idx;
List<String> keyword_list;
void _draw_color_over_button(Object *obj, Color p_color);
- void _add_node(int p_idx, int p_op_idx = -1);
+ void _add_texture_node(const String &p_path);
+ VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1);
void _update_custom_nodes();
void _update_options_menu();
diff --git a/misc/dist/html/fixed-size.html b/misc/dist/html/fixed-size.html
index 14766e8239..1cc6fd715e 100644
--- a/misc/dist/html/fixed-size.html
+++ b/misc/dist/html/fixed-size.html
@@ -229,6 +229,7 @@ $GODOT_HEAD_INCLUDE
(function() {
+ const EXECUTABLE_NAME = '$GODOT_BASENAME';
const MAIN_PACK = '$GODOT_BASENAME.pck';
const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
const INDETERMINATE_STATUS_STEP_MS = 100;
@@ -380,7 +381,7 @@ $GODOT_HEAD_INCLUDE
} else {
setStatusMode('indeterminate');
engine.setCanvas(canvas);
- engine.startGame(MAIN_PACK).then(() => {
+ engine.startGame(EXECUTABLE_NAME, MAIN_PACK).then(() => {
setStatusMode('hidden');
initializing = false;
}, displayFailureNotice);
diff --git a/misc/dist/html/full-size.html b/misc/dist/html/full-size.html
index 12b9af21e5..9269227d02 100644
--- a/misc/dist/html/full-size.html
+++ b/misc/dist/html/full-size.html
@@ -142,6 +142,7 @@ $GODOT_HEAD_INCLUDE
(function() {
+ const EXECUTABLE_NAME = '$GODOT_BASENAME';
const MAIN_PACK = '$GODOT_BASENAME.pck';
const INDETERMINATE_STATUS_STEP_MS = 100;
@@ -254,7 +255,7 @@ $GODOT_HEAD_INCLUDE
} else {
setStatusMode('indeterminate');
engine.setCanvas(canvas);
- engine.startGame(MAIN_PACK).then(() => {
+ engine.startGame(EXECUTABLE_NAME, MAIN_PACK).then(() => {
setStatusMode('hidden');
initializing = false;
}, displayFailureNotice);
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 97790e00bb..d9535d0f1f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -572,37 +572,31 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case OBJ_WEAKREF: {
VALIDATE_ARG_COUNT(1);
- if (p_args[0]->get_type() != Variant::OBJECT) {
-
+ if (p_args[0]->get_type() == Variant::OBJECT) {
+ if (p_args[0]->is_ref()) {
+ Ref<WeakRef> wref = memnew(WeakRef);
+ REF r = *p_args[0];
+ if (r.is_valid()) {
+ wref->set_ref(r);
+ }
+ r_ret = wref;
+ } else {
+ Ref<WeakRef> wref = memnew(WeakRef);
+ Object *obj = *p_args[0];
+ if (obj) {
+ wref->set_obj(obj);
+ }
+ r_ret = wref;
+ }
+ } else if (p_args[0]->get_type() == Variant::NIL) {
+ r_ret = memnew(WeakRef);
+ } else {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
return;
}
-
- if (p_args[0]->is_ref()) {
-
- REF r = *p_args[0];
- if (!r.is_valid()) {
- r_ret = Variant();
- return;
- }
-
- Ref<WeakRef> wref = memnew(WeakRef);
- wref->set_ref(r);
- r_ret = wref;
- } else {
- Object *obj = *p_args[0];
- if (!obj) {
- r_ret = Variant();
- return;
- }
- Ref<WeakRef> wref = memnew(WeakRef);
- wref->set_obj(obj);
- r_ret = wref;
- }
-
} break;
case FUNC_FUNCREF: {
VALIDATE_ARG_COUNT(2);
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js
index 860d6707ff..1f78aa672d 100644
--- a/platform/javascript/engine.js
+++ b/platform/javascript/engine.js
@@ -94,6 +94,7 @@
return new Promise(function(resolve, reject) {
rtenvProps.onRuntimeInitialized = resolve;
rtenvProps.onAbort = reject;
+ rtenvProps.thisProgram = executableName;
rtenvProps.engine.rtenv = Engine.RuntimeEnvironment(rtenvProps, LIBS);
});
}
@@ -130,13 +131,11 @@
);
};
- this.startGame = function(mainPack) {
+ this.startGame = function(execName, mainPack) {
+
+ executableName = execName;
+ var mainArgs = [ '--main-pack', mainPack ];
- executableName = getBaseName(mainPack);
- var mainArgs = [];
- if (!getPathLeaf(mainPack).endsWith('.pck')) {
- mainArgs = ['--main-pack', getPathLeaf(mainPack)];
- }
return Promise.all([
// Load from directory,
this.init(getBasePath(mainPack)),
@@ -187,8 +186,6 @@
this.rtenv.locale = this.rtenv.locale.split('.')[0];
this.rtenv.resizeCanvasOnStart = resizeCanvasOnStart;
- this.rtenv.thisProgram = executableName || getBaseName(basePath);
-
preloadedFiles.forEach(function(file) {
var dir = LIBS.PATH.dirname(file.path);
try {
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index f4430d93f6..336c8aa78e 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -437,7 +437,7 @@ void Node2D::_bind_methods() {
ADD_GROUP("Transform", "");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform");
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 32a0b732c0..5e14959e9d 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -842,7 +842,7 @@ void Polygon2D::_bind_methods() {
ADD_GROUP("Texture", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_NONE, "", 0), "set_texture_rotation", "get_texture_rotation");
ADD_GROUP("Skeleton", "");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton2D"), "set_skeleton", "get_skeleton");
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index f8f29632b3..fc67b28095 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2948,7 +2948,7 @@ void Control::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", 0), "_set_global_position", "get_global_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_degrees", "get_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents");
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 9ed1d2bf45..31551d6257 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -206,9 +206,9 @@ void WindowDialog::_notification(int p_what) {
Color title_color = get_color("title_color", "WindowDialog");
int title_height = get_constant("title_height", "WindowDialog");
int font_height = title_font->get_height() - title_font->get_descent() * 2;
- int x = (size.x - title_font->get_string_size(title).x) / 2;
+ int x = (size.x - title_font->get_string_size(xl_title).x) / 2;
int y = (-title_height + font_height) / 2;
- title_font->draw(canvas, Point2(x, y), title, title_color, size.x - panel->get_minimum_size().x);
+ title_font->draw(canvas, Point2(x, y), xl_title, title_color, size.x - panel->get_minimum_size().x);
} break;
case NOTIFICATION_THEME_CHANGED:
@@ -222,8 +222,9 @@ void WindowDialog::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
String new_title = tr(title);
- if (title != new_title) {
- title = new_title;
+ if (new_title != xl_title) {
+ xl_title = new_title;
+ minimum_size_changed();
update();
}
} break;
@@ -283,9 +284,10 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const {
void WindowDialog::set_title(const String &p_title) {
- String new_title = tr(p_title);
- if (title != new_title) {
- title = new_title;
+ if (title != p_title) {
+ title = p_title;
+ xl_title = tr(p_title);
+ minimum_size_changed();
update();
}
}
@@ -306,7 +308,7 @@ Size2 WindowDialog::get_minimum_size() const {
Ref<Font> font = get_font("title_font", "WindowDialog");
const int button_width = close_button->get_combined_minimum_size().x;
- const int title_width = font->get_string_size(title).x;
+ const int title_width = font->get_string_size(xl_title).x;
const int padding = button_width / 2;
const int button_area = button_width + padding;
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index 1a0350ba18..afd1173f28 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -53,6 +53,7 @@ class WindowDialog : public Popup {
TextureButton *close_button;
String title;
+ String xl_title;
int drag_type;
Point2 drag_offset;
Point2 drag_offset_far;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index a6842603fd..d304a37f82 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -210,7 +210,7 @@ Size2 GridContainer::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible())
continue;
int row = valid_controls_index / columns;
int col = valid_controls_index % columns;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 93b091e8d0..c24f15384b 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -53,7 +53,7 @@ Size2 Tabs::get_minimum_size() const {
ms.width += get_constant("hseparation");
}
- ms.width += Math::ceil(font->get_string_size(tabs[i].text).width);
+ ms.width += Math::ceil(font->get_string_size(tabs[i].xl_text).width);
if (tabs[i].disabled)
ms.width += tab_disabled->get_minimum_size().width;
@@ -223,6 +223,9 @@ void Tabs::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
+ for (int i = 0; i < tabs.size(); ++i) {
+ tabs.write[i].xl_text = tr(tabs[i].text);
+ }
minimum_size_changed();
update();
} break;
@@ -318,7 +321,7 @@ void Tabs::_notification(int p_what) {
w += icon->get_width() + get_constant("hseparation");
}
- font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), tabs[i].text, col, tabs[i].size_text);
+ font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), tabs[i].xl_text, col, tabs[i].size_text);
w += tabs[i].size_text;
@@ -435,6 +438,7 @@ void Tabs::set_tab_title(int p_tab, const String &p_title) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].text = p_title;
+ tabs.write[p_tab].xl_text = tr(p_title);
update();
minimum_size_changed();
}
@@ -543,7 +547,7 @@ void Tabs::_update_cache() {
for (int i = 0; i < tabs.size(); i++) {
tabs.write[i].ofs_cache = mw;
tabs.write[i].size_cache = get_tab_width(i);
- tabs.write[i].size_text = Math::ceil(font->get_string_size(tabs[i].text).width);
+ tabs.write[i].size_text = Math::ceil(font->get_string_size(tabs[i].xl_text).width);
mw += tabs[i].size_cache;
if (tabs[i].size_cache <= min_width || i == current) {
size_fixed += tabs[i].size_cache;
@@ -604,6 +608,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
Tab t;
t.text = p_str;
+ t.xl_text = tr(p_str);
t.icon = p_icon;
t.disabled = false;
t.ofs_cache = 0;
@@ -659,7 +664,7 @@ Variant Tabs::get_drag_data(const Point2 &p_point) {
tf->set_texture(tabs[tab_over].icon);
drag_preview->add_child(tf);
}
- Label *label = memnew(Label(tabs[tab_over].text));
+ Label *label = memnew(Label(tabs[tab_over].xl_text));
drag_preview->add_child(label);
if (!tabs[tab_over].right_button.is_null()) {
TextureRect *tf = memnew(TextureRect);
@@ -808,7 +813,7 @@ int Tabs::get_tab_width(int p_idx) const {
x += get_constant("hseparation");
}
- x += Math::ceil(font->get_string_size(tabs[p_idx].text).width);
+ x += Math::ceil(font->get_string_size(tabs[p_idx].xl_text).width);
if (tabs[p_idx].disabled)
x += tab_disabled->get_minimum_size().width;
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index a762b5b9cb..0edf2fedc1 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -58,6 +58,7 @@ private:
struct Tab {
String text;
+ String xl_text;
Ref<Texture> icon;
int ofs_cache;
bool disabled;
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index c534df5cbe..9b60a9d1c3 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -344,6 +344,9 @@ void TextureProgress::_notification(int p_what) {
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE:
case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
+ if (nine_patch_stretch)
+ s = get_size();
+
float val = get_as_ratio() * rad_max_degrees / 360;
if (val == 1) {
Rect2 region = Rect2(Point2(), s);
@@ -384,7 +387,13 @@ void TextureProgress::_notification(int p_what) {
draw_polygon(points, colors, uvs, progress);
}
if (Engine::get_singleton()->is_editor_hint()) {
- Point2 p = progress->get_size();
+ Point2 p;
+
+ if (nine_patch_stretch)
+ p = get_size();
+ else
+ p = progress->get_size();
+
p.x *= get_relative_center().x;
p.y *= get_relative_center().y;
p = p.floor();
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index afb7f1102b..bc96b5e9f3 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -354,10 +354,6 @@ void Environment::_validate_property(PropertyInfo &property) const {
"tonemap_",
"ss_reflections_",
"ssao_",
- "dof_blur_far_",
- "dof_blur_near_",
- "glow_",
- "adjustment_",
NULL
};
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 3f2261b043..6c829e6e81 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -122,7 +122,8 @@ void VisualShaderNode::_bind_methods() {
BIND_ENUM_CONSTANT(PORT_TYPE_VECTOR);
BIND_ENUM_CONSTANT(PORT_TYPE_BOOLEAN);
BIND_ENUM_CONSTANT(PORT_TYPE_TRANSFORM);
- BIND_ENUM_CONSTANT(PORT_TYPE_ICON_COLOR);
+ BIND_ENUM_CONSTANT(PORT_TYPE_SAMPLER);
+ BIND_ENUM_CONSTANT(PORT_TYPE_MAX);
}
VisualShaderNode::VisualShaderNode() {
@@ -1058,7 +1059,15 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
String src_var = "n_out" + itos(from_node) + "p" + itos(from_port);
- if (in_type == out_type) {
+ if (in_type == VisualShaderNode::PORT_TYPE_SAMPLER && out_type == VisualShaderNode::PORT_TYPE_SAMPLER) {
+
+ VisualShaderNodeUniform *uniform = (VisualShaderNodeUniform *)graph[type].nodes[from_node].node.ptr();
+ if (uniform) {
+ inputs[i] = uniform->get_uniform_name();
+ } else {
+ inputs[i] = "";
+ }
+ } else if (in_type == out_type) {
inputs[i] = src_var;
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
inputs[i] = "dot(" + src_var + ",vec3(0.333333,0.333333,0.333333))";
@@ -2207,7 +2216,7 @@ void VisualShaderNodeGroupBase::clear_output_ports() {
void VisualShaderNodeGroupBase::set_input_port_type(int p_id, int p_type) {
ERR_FAIL_COND(!has_input_port(p_id));
- ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM);
+ ERR_FAIL_COND(p_type < 0 || p_type >= PORT_TYPE_MAX);
if (input_ports[p_id].type == p_type)
return;
@@ -2273,7 +2282,7 @@ String VisualShaderNodeGroupBase::get_input_port_name(int p_id) const {
void VisualShaderNodeGroupBase::set_output_port_type(int p_id, int p_type) {
ERR_FAIL_COND(!has_output_port(p_id));
- ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM);
+ ERR_FAIL_COND(p_type < 0 || p_type >= PORT_TYPE_MAX);
if (output_ports[p_id].type == p_type)
return;
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 45beb8e6ca..d9f089586d 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -184,7 +184,8 @@ public:
PORT_TYPE_VECTOR,
PORT_TYPE_BOOLEAN,
PORT_TYPE_TRANSFORM,
- PORT_TYPE_ICON_COLOR // just a hint for node tree icons, do not use it as actual port type !
+ PORT_TYPE_SAMPLER,
+ PORT_TYPE_MAX,
};
virtual String get_caption() const = 0;
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index b7173b157e..24e436e61c 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -361,15 +361,35 @@ String VisualShaderNodeTexture::get_caption() const {
}
int VisualShaderNodeTexture::get_input_port_count() const {
- return 2;
+ return 3;
}
VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_input_port_type(int p_port) const {
- return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR;
+
+ switch (p_port) {
+ case 0:
+ return PORT_TYPE_VECTOR;
+ case 1:
+ return PORT_TYPE_SCALAR;
+ case 2:
+ return PORT_TYPE_SAMPLER;
+ default:
+ return PORT_TYPE_SCALAR;
+ }
}
String VisualShaderNodeTexture::get_input_port_name(int p_port) const {
- return p_port == 0 ? "uv" : "lod";
+
+ switch (p_port) {
+ case 0:
+ return "uv";
+ case 1:
+ return "lod";
+ case 2:
+ return "sampler";
+ default:
+ return "";
+ }
}
int VisualShaderNodeTexture::get_output_port_count() const {
@@ -440,6 +460,29 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
return code;
}
+ if (source == SOURCE_PORT) {
+ String id = p_input_vars[2];
+ String code;
+ if (id == String()) {
+ code += "\tvec4 " + id + "_tex_read = vec4(0.0);\n";
+ } else {
+ if (p_input_vars[0] == String()) { //none bound, do nothing
+
+ code += "\tvec4 " + id + "_tex_read = vec4(0.0);\n";
+
+ } else if (p_input_vars[1] == String()) {
+ //no lod
+ code += "\tvec4 " + id + "_tex_read = texture( " + id + " , " + p_input_vars[0] + ".xy );\n";
+ } else {
+ code += "\tvec4 " + id + "_tex_read = textureLod( " + id + " , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
+ }
+
+ code += "\t" + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n";
+ code += "\t" + p_output_vars[1] + " = " + id + "_tex_read.a;\n";
+ }
+ return code;
+ }
+
if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) {
String code = "\t{\n";
@@ -588,6 +631,10 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T
return String(); // all good
}
+ if (source == SOURCE_PORT) {
+ return String(); // all good
+ }
+
if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) {
return String(); // all good
@@ -625,7 +672,7 @@ void VisualShaderNodeTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeTexture::set_texture_type);
ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeTexture::get_texture_type);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth"), "set_source", "get_source");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth,SamplerPort"), "set_source", "get_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type");
@@ -3023,15 +3070,35 @@ String VisualShaderNodeTextureUniform::get_input_port_name(int p_port) const {
}
int VisualShaderNodeTextureUniform::get_output_port_count() const {
- return 2;
+ return 3;
}
VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniform::get_output_port_type(int p_port) const {
- return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR;
+
+ switch (p_port) {
+ case 0:
+ return PORT_TYPE_VECTOR;
+ case 1:
+ return PORT_TYPE_SCALAR;
+ case 2:
+ return PORT_TYPE_SAMPLER;
+ default:
+ return PORT_TYPE_SCALAR;
+ }
}
String VisualShaderNodeTextureUniform::get_output_port_name(int p_port) const {
- return p_port == 0 ? "rgb" : "alpha";
+
+ switch (p_port) {
+ case 0:
+ return "rgb";
+ case 1:
+ return "alpha";
+ case 2:
+ return "sampler";
+ default:
+ return "";
+ }
}
String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 0c6e060353..1e4608444c 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -199,7 +199,8 @@ public:
SOURCE_SCREEN,
SOURCE_2D_TEXTURE,
SOURCE_2D_NORMAL,
- SOURCE_DEPTH
+ SOURCE_DEPTH,
+ SOURCE_PORT,
};
enum TextureType {