Merge pull request #12288 from tagcup/expose_viewport_size

Expose VIEWPORT_SIZE in shader language.
This commit is contained in:
Juan Linietsky 2017-10-30 19:32:21 -03:00 committed by GitHub
commit 4785e66eea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View file

@ -4023,6 +4023,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_side = 0;
state.ubo_data.shadow_dual_paraboloid_render_zfar = 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) { 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[0] = 1.0 / storage->frame.current_rt->width;
state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height; state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;

View file

@ -124,6 +124,7 @@ public:
float z_slope_scale; float z_slope_scale;
float shadow_dual_paraboloid_render_zfar; float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side; float shadow_dual_paraboloid_render_side;
float viewport_size[2];
float screen_pixel_size[2]; float screen_pixel_size[2];
float shadow_atlas_pixel_size[2]; float shadow_atlas_pixel_size[2];
float shadow_directional_pixel_size[2]; float shadow_directional_pixel_size[2];
@ -143,7 +144,7 @@ public:
float fog_height_min; float fog_height_min;
float fog_height_max; float fog_height_max;
float fog_height_curve; 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; } ubo_data;

View file

@ -766,7 +766,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
//builtins //builtins
actions[VS::SHADER_SPATIAL].renames["TIME"] = "time"; 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["FRAGCOORD"] = "gl_FragCoord";
actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing"; actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";

View file

@ -80,6 +80,7 @@ layout(std140) uniform SceneData { //ubo:0
highp float shadow_dual_paraboloid_render_zfar; highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side; highp float shadow_dual_paraboloid_render_side;
highp vec2 viewport_size;
highp vec2 screen_pixel_size; highp vec2 screen_pixel_size;
highp vec2 shadow_atlas_pixel_size; highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size; highp vec2 directional_shadow_pixel_size;
@ -566,6 +567,7 @@ in vec3 normal_interp;
uniform bool no_ambient_light; uniform bool no_ambient_light;
#ifdef USE_RADIANCE_MAP #ifdef USE_RADIANCE_MAP