summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders/canvas.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/shaders/canvas.glsl')
-rw-r--r--drivers/gles3/shaders/canvas.glsl27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 7255b0425c..07ee9cd010 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
@@ -150,6 +150,7 @@ void main() {
#define extra_matrix extra_matrix_instance
+ float point_size = 1.0;
//for compatibility with the fragment shader we need to use uv here
vec2 uv = uv_interp;
{
@@ -160,6 +161,7 @@ VERTEX_SHADER_CODE
/* clang-format on */
}
+ gl_PointSize = point_size;
uv_interp = uv;
#ifdef USE_NINEPATCH
@@ -395,26 +397,29 @@ float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, flo
draw_center--;
}
- if (np_repeat == 0) { //stretch
- //convert to ratio
+ // np_repeat is passed as uniform using NinePatchRect::AxisStretchMode enum.
+ if (np_repeat == 0) { // Stretch.
+ // Convert to ratio.
float ratio = (pixel - screen_margin_begin) / (draw_size - screen_margin_begin - screen_margin_end);
- //scale to source texture
+ // Scale to source texture.
return (margin_begin + ratio * (tex_size - margin_begin - margin_end)) * tex_pixel_size;
- } else if (np_repeat == 1) { //tile
- //convert to ratio
+ } else if (np_repeat == 1) { // Tile.
+ // Convert to offset.
float ofs = mod((pixel - screen_margin_begin), tex_size - margin_begin - margin_end);
- //scale to source texture
+ // Scale to source texture.
return (margin_begin + ofs) * tex_pixel_size;
- } else if (np_repeat == 2) { //tile fit
- //convert to ratio
+ } else if (np_repeat == 2) { // Tile Fit.
+ // Calculate scale.
float src_area = draw_size - screen_margin_begin - screen_margin_end;
float dst_area = tex_size - margin_begin - margin_end;
float scale = max(1.0, floor(src_area / max(dst_area, 0.0000001) + 0.5));
-
- //convert to ratio
+ // Convert to ratio.
float ratio = (pixel - screen_margin_begin) / src_area;
ratio = mod(ratio * scale, 1.0);
+ // Scale to source texture.
return (margin_begin + ratio * dst_area) * tex_pixel_size;
+ } else { // Shouldn't happen, but silences compiler warning.
+ return 0.0;
}
}
}