26 lines
739 B
Plaintext
26 lines
739 B
Plaintext
shader_type canvas_item;
|
|
|
|
// Positive values lean right, negative lean left
|
|
uniform float skew_x : hint_range(-2.0, 2.0) = 0.0;
|
|
// Positive values lean down, negative lean up
|
|
uniform float skew_y : hint_range(-2.0, 2.0) = 0.0;
|
|
|
|
void vertex() {
|
|
// 1. Get the size of the Control node
|
|
vec2 size = 1.0 / TEXTURE_PIXEL_SIZE;
|
|
|
|
// 2. Move the pivot to the center for a natural tilt
|
|
// Without this, it skews from the top-left corner
|
|
VERTEX -= size * 0.5;
|
|
|
|
// 3. Apply the Skew math
|
|
// We use a temporary variable so the calculations don't interfere
|
|
float old_x = VERTEX.x;
|
|
float old_y = VERTEX.y;
|
|
|
|
VERTEX.x = old_x + (old_y * skew_x);
|
|
VERTEX.y = old_y + (old_x * skew_y);
|
|
|
|
// 4. Move back from the center
|
|
VERTEX += size * 0.5;
|
|
} |