Merge pull request #34551 from MadEqua/fix-light-with-skeleton

Fix 2D lighting when using skeleton.
This commit is contained in:
Rémi Verschelde 2020-01-03 08:32:29 +01:00 committed by GitHub
commit 2d6586ec78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -1413,7 +1413,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
} }
if (skeleton) { if (skeleton) {
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 4);
glBindTexture(GL_TEXTURE_2D, skeleton->texture); glBindTexture(GL_TEXTURE_2D, skeleton->texture);
state.using_skeleton = true; state.using_skeleton = true;
} else { } else {
@ -1677,7 +1677,6 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
bool light_rebind = state.canvas_shader.bind(); bool light_rebind = state.canvas_shader.bind();
if (light_rebind) { if (light_rebind) {
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate); state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform); state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D()); state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D());
@ -1686,6 +1685,10 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
} else { } else {
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0)); state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0));
} }
if (state.using_skeleton) {
state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
}
} }
glBindBufferBase(GL_UNIFORM_BUFFER, 1, static_cast<LightInternal *>(light->light_internal.get_data())->ubo); glBindBufferBase(GL_UNIFORM_BUFFER, 1, static_cast<LightInternal *>(light->light_internal.get_data())->ubo);

View file

@ -55,7 +55,7 @@ out highp vec2 pixel_size_interp;
#endif #endif
#ifdef USE_SKELETON #ifdef USE_SKELETON
uniform mediump sampler2D skeleton_texture; // texunit:-1 uniform mediump sampler2D skeleton_texture; // texunit:-4
uniform highp mat4 skeleton_transform; uniform highp mat4 skeleton_transform;
uniform highp mat4 skeleton_transform_inverse; uniform highp mat4 skeleton_transform_inverse;
#endif #endif