1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Pass angles in radians in SmearRotxel

Should be a slight optimization, since angles are being converted to radians only once, and that calculation is done in the CPU
This commit is contained in:
Emmanouil Papadeas 2024-05-08 23:31:03 +03:00
parent fe54f943e9
commit 25f7192573
2 changed files with 7 additions and 11 deletions

View file

@ -26,15 +26,13 @@ vec4 rotate(sampler2D tex, vec2 uv, vec2 tex_pixel_size) {
float dir;
float mag;
float init_angle = initial_angle < ending_angle ? initial_angle : ending_angle;
for (float angle = ending_angle; angle >= init_angle && color.a == 0.0; angle -= 1.0) {
float ang = angle*3.1416/180.0;
for (float angle = ending_angle; angle >= init_angle && color.a <= 0.0001; angle -= 0.0174) {
for (int k = 0; k < 9; k++) {
int i = -1 + int(k % 3);
int j = -1 + k / 3;
dir = atan(float(dy + j), float(dx + i));
mag = sqrt(pow(float(dx + i), 2.0) + pow(float(dy + j), 2.0));
dir -= ang;
dir -= angle;
ox = int(round(3.0 * center.x + 1.0 + mag * cos(dir)));
oy = int(round(3.0 * center.y + 1.0 + mag * sin(dir)));
@ -125,15 +123,13 @@ vec4 rotate_uniform(sampler2D tex, vec2 uv, vec2 tex_pixel_size) {
float dir;
float mag;
float init_angle = initial_angle < ending_angle ? initial_angle : ending_angle;
for (float angle = ending_angle; angle >= init_angle && color.a == 0.0; angle -= 1.0) {
float ang = angle*3.1416/180.0;
for (float angle = ending_angle; angle >= init_angle && color.a <= 0.0001; angle -= 0.0174) {
for (int k = 0; k < 9; k++) {
int i = -1 + int(k % 3);
int j = -1 + k / 3;
dir = atan(float(dy + j), float(dx + i));
mag = sqrt(pow(float(dx + i), 2.0) + pow(float(dy + j), 2.0));
dir -= ang;
dir -= angle;
ox = int(round(3.0 * center.x + 1.0 + mag * cos(dir)));
oy = int(round(3.0 * center.y + 1.0 + mag * sin(dir)));

View file

@ -1,7 +1,7 @@
extends ImageEffect
enum { ROTXEL_SMEAR, CLEANEDGE, OMNISCALE, NNS, NN, ROTXEL, URD }
enum Animate { ANGLE, INITIAL_ANGLE }
enum Animate { ANGLE, INIT_ANGLE }
var rotxel_shader := preload("res://src/Shaders/Effects/Rotation/SmearRotxel.gdshader")
var nn_shader := preload("res://src/Shaders/Effects/Rotation/NearestNeighbour.gdshader")
@ -79,7 +79,7 @@ func _calculate_pivot() -> void:
func commit_action(cel: Image, _project := Global.current_project) -> void:
var angle := deg_to_rad(animate_panel.get_animated_value(commit_idx, Animate.ANGLE))
var init_angle := animate_panel.get_animated_value(commit_idx, Animate.INITIAL_ANGLE)
var init_angle := deg_to_rad(animate_panel.get_animated_value(commit_idx, Animate.INIT_ANGLE))
var selection_tex: ImageTexture
var image := Image.new()
@ -105,7 +105,7 @@ func commit_action(cel: Image, _project := Global.current_project) -> void:
ROTXEL_SMEAR:
params = {
"initial_angle": init_angle,
"ending_angle": rad_to_deg(angle),
"ending_angle": angle,
"tolerance": tolerance_slider.value,
"selection_tex": selection_tex,
"origin": pivot / Vector2(cel.get_size()),