From f26c9d650b72a8b1b30254914bc486569e611ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Louren=C3=A7o?= Date: Mon, 23 Dec 2019 00:00:18 +0000 Subject: Fix 2D lighting when using skeleton. --- drivers/gles3/rasterizer_canvas_gles3.cpp | 7 +++++-- drivers/gles3/shaders/canvas.glsl | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/gles3') diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 1803a3dbbe..642cc0f763 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1413,7 +1413,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons } 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); state.using_skeleton = true; state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform); @@ -1674,7 +1674,6 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons bool light_rebind = state.canvas_shader.bind(); if (light_rebind) { - 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::EXTRA_MATRIX, Transform2D()); @@ -1683,6 +1682,10 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons } else { 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(light->light_internal.get_data())->ubo); diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 53f84abf51..9116868f68 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -55,7 +55,7 @@ out highp vec2 pixel_size_interp; #endif #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_inverse; #endif -- cgit v1.2.3