Skip to content

Commit

Permalink
TIME constant reverted to a single float, fixes #9123
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jun 16, 2017
1 parent 5d02b94 commit 80929d3
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 17 deletions.
4 changes: 1 addition & 3 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,7 @@ void RasterizerCanvasGLES3::reset_canvas() {
state.vp = canvas_transform;

store_transform(canvas_transform, state.canvas_item_ubo_data.projection_matrix);
for (int i = 0; i < 4; i++) {
state.canvas_item_ubo_data.time[i] = storage->frame.time[i];
}
state.canvas_item_ubo_data.time = storage->frame.time[0];

glBindBuffer(GL_UNIFORM_BUFFER, state.canvas_item_ubo);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(CanvasItemUBO), &state.canvas_item_ubo_data);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_canvas_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RasterizerCanvasGLES3 : public RasterizerCanvas {
struct CanvasItemUBO {

float projection_matrix[16];
float time[4];
float time;
};

struct Data {
Expand Down
4 changes: 1 addition & 3 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,9 +2314,7 @@ void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatr
store_transform(p_cam_transform.affine_inverse(), state.ubo_data.camera_inverse_matrix);

//time global variables
for (int i = 0; i < 4; i++) {
state.ubo_data.time[i] = storage->frame.time[i];
}
state.ubo_data.time = storage->frame.time[0];

state.ubo_data.z_far = p_cam_projection.get_z_far();
//bg and ambient
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class RasterizerSceneGLES3 : public RasterizerScene {
float projection_matrix[16];
float camera_inverse_matrix[16];
float camera_matrix[16];
float time[4];
float ambient_light_color[4];
float bg_color[4];
float fog_color_enabled[4];
Expand All @@ -127,6 +126,7 @@ class RasterizerSceneGLES3 : public RasterizerScene {
float shadow_atlas_pixel_size[2];
float shadow_directional_pixel_size[2];

float time;
float z_far;
float reflection_multiplier;
float subsurface_scatter_width;
Expand Down
4 changes: 1 addition & 3 deletions drivers/gles3/rasterizer_storage_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5381,7 +5381,7 @@ void RasterizerStorageGLES3::update_particles() {
shaders.particles.bind();

shaders.particles.set_uniform(ParticlesShaderGLES3::TOTAL_PARTICLES, particles->amount);
shaders.particles.set_uniform(ParticlesShaderGLES3::TIME, Color(frame.time[0], frame.time[1], frame.time[2], frame.time[3]));
shaders.particles.set_uniform(ParticlesShaderGLES3::TIME, frame.time[0]);
shaders.particles.set_uniform(ParticlesShaderGLES3::EXPLOSIVENESS, particles->explosiveness);
shaders.particles.set_uniform(ParticlesShaderGLES3::LIFETIME, particles->lifetime);
shaders.particles.set_uniform(ParticlesShaderGLES3::ATTRACTOR_COUNT, 0);
Expand Down Expand Up @@ -5447,8 +5447,6 @@ void RasterizerStorageGLES3::update_particles() {
}

glDisable(GL_RASTERIZER_DISCARD);


}

////////
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ layout(location=4) in highp vec2 uv_attrib;
layout(std140) uniform CanvasItemData { //ubo:0

highp mat4 projection_matrix;
highp vec4 time;
highp float time;
};

uniform highp mat4 modelview_matrix;
Expand Down Expand Up @@ -158,7 +158,7 @@ uniform sampler2D screen_texture; // texunit:-3
layout(std140) uniform CanvasItemData {

highp mat4 projection_matrix;
highp vec4 time;
highp float time;
};


Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/shaders/particles.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ uniform float prev_system_phase;
uniform int total_particles;
uniform float explosiveness;
uniform float randomness;
uniform vec4 time;
uniform float time;
uniform float delta;

uniform int attractor_count;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/shaders/scene.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ layout(std140) uniform SceneData { //ubo:0
highp mat4 projection_matrix;
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
highp vec4 time;

highp vec4 ambient_light_color;
highp vec4 bg_color;
Expand All @@ -83,6 +82,7 @@ layout(std140) uniform SceneData { //ubo:0
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;

float time;
float z_far;
float reflection_multiplier;
float subsurface_scatter_width;
Expand Down Expand Up @@ -435,7 +435,6 @@ layout(std140) uniform SceneData {
highp mat4 projection_matrix;
highp mat4 camera_inverse_matrix;
highp mat4 camera_matrix;
highp vec4 time;

highp vec4 ambient_light_color;
highp vec4 bg_color;
Expand All @@ -455,6 +454,7 @@ layout(std140) uniform SceneData {
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;

float time;
float z_far;
float reflection_multiplier;
float subsurface_scatter_width;
Expand Down
2 changes: 1 addition & 1 deletion servers/visual/shader_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["RESTART"] = ShaderLanguage::TYPE_BOOL;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["CUSTOM"] = ShaderLanguage::TYPE_VEC4;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TRANSFORM"] = ShaderLanguage::TYPE_MAT4;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_VEC4;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["LIFETIME"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["DELTA"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["NUMBER"] = ShaderLanguage::TYPE_UINT;
Expand Down

0 comments on commit 80929d3

Please sign in to comment.