summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-11 20:44:11 +0100
committerGitHub <noreply@github.com>2018-12-11 20:44:11 +0100
commit1b038bed94519bddcc4328ca053874a754ae37fd (patch)
treea21da62094e269ee14877f8c96fe64bf15ba281e /drivers
parent5ff403b3b0a4d19122cebae1329f46444263ae17 (diff)
parent2827ee77d05bd7df3f860d52cc25b272a8cb3ae1 (diff)
Merge pull request #23932 from muiroc/es2_viewport_size_builtin
GLES2 implemented VIEWPORT_SIZE builtin for spatial shader
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp15
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h2
-rw-r--r--drivers/gles2/shaders/scene.glsl4
3 files changed, 17 insertions, 4 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 7addbaa9fe..25d7df8ebc 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -2017,6 +2017,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ Vector2 viewport_size = state.viewport_size;
+
Vector2 screen_pixel_size = state.screen_pixel_size;
bool use_radiance_map = false;
@@ -2335,6 +2337,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
state.scene_shader.set_uniform(SceneShaderGLES2::TIME, storage->frame.time[0]);
+ state.scene_shader.set_uniform(SceneShaderGLES2::VIEWPORT_SIZE, viewport_size);
+
state.scene_shader.set_uniform(SceneShaderGLES2::SCREEN_PIXEL_SIZE, screen_pixel_size);
}
@@ -2506,8 +2510,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
current_fb = probe->fbo[p_reflection_probe_pass];
- state.screen_pixel_size.x = 1.0 / probe->probe_ptr->resolution;
- state.screen_pixel_size.y = 1.0 / probe->probe_ptr->resolution;
viewport_width = probe->probe_ptr->resolution;
viewport_height = probe->probe_ptr->resolution;
@@ -2518,11 +2520,16 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
state.render_no_shadows = false;
current_fb = storage->frame.current_rt->fbo;
env = environment_owner.getornull(p_environment);
- state.screen_pixel_size.x = 1.0 / storage->frame.current_rt->width;
- state.screen_pixel_size.y = 1.0 / storage->frame.current_rt->height;
+
viewport_width = storage->frame.current_rt->width;
viewport_height = storage->frame.current_rt->height;
}
+
+ state.viewport_size.x = viewport_width;
+ state.viewport_size.y = viewport_height;
+ state.screen_pixel_size.x = 1.0 / viewport_width;
+ state.screen_pixel_size.y = 1.0 / viewport_height;
+
//push back the directional lights
if (p_light_cull_count) {
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index ba406183c7..3c7d331cb8 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -211,6 +211,8 @@ public:
bool render_no_shadows;
+ Vector2 viewport_size;
+
Vector2 screen_pixel_size;
} state;
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index 15b90a7771..d728ad5da6 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -84,6 +84,8 @@ uniform highp mat4 world_transform;
uniform highp float time;
+uniform highp vec2 viewport_size;
+
#ifdef RENDER_DEPTH
uniform float light_bias;
uniform float light_normal_bias;
@@ -677,6 +679,8 @@ uniform highp mat4 world_transform;
uniform highp float time;
+uniform highp vec2 viewport_size;
+
#if defined(SCREEN_UV_USED)
uniform vec2 screen_pixel_size;
#endif