diff options
-rw-r--r-- | drivers/gles2/rasterizer_scene_gles2.cpp | 15 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_scene_gles2.h | 2 | ||||
-rw-r--r-- | drivers/gles2/shaders/scene.glsl | 4 |
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 |