// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's CanvasItemMaterial.

shader_type canvas_item;
render_mode blend_mix;

#include "res://addons/rokojori_action_library/Runtime/Shading/Library/NinePatch.gdshaderinc"

uniform vec2 size = vec2( 128, 128 );
uniform vec4 borders = vec4( 40, 40, 40, 40 );

varying vec4 scaledBorders;
varying vec4 uvBorders;

void vertex()
{
  vec4 outUVBorders     = vec4( 0, 0, 0, 0 );
  vec4 outScaledBorders = vec4( 0, 0, 0, 0 );

  computeNinePatchBorders( TEXTURE_PIXEL_SIZE, size, borders, outUVBorders, outScaledBorders );

  uvBorders = outUVBorders;
  scaledBorders = outScaledBorders;
}

void fragment()
{
  vec2 nUV = computeNinePatchUV( UV, size, uvBorders, scaledBorders );

  COLOR = texture( TEXTURE, nUV ) ;
}