summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2017-10-21 14:05:57 -0400
committerFerenc Arn <tagcup@yahoo.com>2017-10-26 15:00:28 -0400
commita0fc641f2516015f1be863d9f9632654bb25a684 (patch)
tree92f7d5240c1c34965c591b1a9a9962810261d810 /drivers
parent393daf05025bd8076ec01eb754d1145dbb12edc5 (diff)
Expose VIEWPORT_SIZE in shader language.
Fixes #11710.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp6
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h3
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/scene.glsl2
4 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 39f027a5aa..0460434dd9 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1132,9 +1132,9 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
state.current_depth_draw = p_material->shader->spatial.depth_draw_mode;
}
-//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
+ //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-/*
+ /*
if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME])
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
else
@@ -4011,6 +4011,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.ubo_data.shadow_dual_paraboloid_render_side = 0;
state.ubo_data.shadow_dual_paraboloid_render_zfar = 0;
+ p_cam_projection.get_viewport_size(state.ubo_data.viewport_size[0], state.ubo_data.viewport_size[1]);
+
if (storage->frame.current_rt) {
state.ubo_data.screen_pixel_size[0] = 1.0 / storage->frame.current_rt->width;
state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 28a5cef0ee..0ff7008666 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -124,6 +124,7 @@ public:
float z_slope_scale;
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
+ float viewport_size[2];
float screen_pixel_size[2];
float shadow_atlas_pixel_size[2];
float shadow_directional_pixel_size[2];
@@ -143,7 +144,7 @@ public:
float fog_height_min;
float fog_height_max;
float fog_height_curve;
- uint8_t padding[8];
+ // make sure this struct is padded to be a multiple of 16 bytes for webgl
} ubo_data;
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 5fe7b53a7d..476132bc9f 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -766,7 +766,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
//builtins
actions[VS::SHADER_SPATIAL].renames["TIME"] = "time";
- //actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"]=ShaderLanguage::TYPE_VEC2;
+ actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrotFacing";
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 0b5b9d1d24..f91d9f24a5 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -80,6 +80,7 @@ layout(std140) uniform SceneData { //ubo:0
highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side;
+ highp vec2 viewport_size;
highp vec2 screen_pixel_size;
highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size;
@@ -566,6 +567,7 @@ in vec3 normal_interp;
uniform bool no_ambient_light;
+
#ifdef USE_RADIANCE_MAP