Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Image Improvements #961

Merged
merged 36 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
239068d
Reference Image Updates
TheLsbt Dec 15, 2023
201c9e4
Fixed static typing
TheLsbt Dec 18, 2023
fdec874
Tried fixing the static typing again
TheLsbt Dec 18, 2023
51afd12
Tried fixing static typing again
TheLsbt Dec 18, 2023
f3a0525
Changed Spacing
TheLsbt Dec 18, 2023
cfcddf6
Fixed Trailing Whitespaces and tabs
TheLsbt Dec 18, 2023
6d2d5af
Fixed Final Trailing Whitespace
TheLsbt Dec 18, 2023
d9d7c71
Fixed styling and removed useless enum
TheLsbt Dec 18, 2023
f6cf446
Removed double tabs left over from previous commit
TheLsbt Dec 18, 2023
d010e97
Fixed remove ConfirmDialog Showing on startusp
TheLsbt Dec 19, 2023
366d506
Tried Fixing gdlint issues
TheLsbt Dec 19, 2023
76155cd
Fixed Linting
TheLsbt Dec 19, 2023
c0a25aa
Fixed Spelling issues
TheLsbt Dec 19, 2023
0ba5a8b
Drag and drop to rearrange reference images
TheLsbt Dec 21, 2023
a6c86d5
Added Icons
TheLsbt Dec 21, 2023
7b988d4
Applied the icons to the UI
TheLsbt Dec 21, 2023
c2e59a4
Fix Scripting Issues
TheLsbt Dec 21, 2023
07e90b4
Fixed Linting
TheLsbt Dec 21, 2023
bce8764
Merge branch 'master' of https://github.com/TheLsbt/Pixelorama
TheLsbt Dec 26, 2023
fae90ba
Rename Move.png to move.png
TheLsbt Dec 26, 2023
d32260f
Merge branch 'master' of https://github.com/TheLsbt/Pixelorama
TheLsbt Dec 26, 2023
0425baf
Merge branch 'Orama-Interactive:master' into master
TheLsbt Dec 26, 2023
f604da0
Update Canvas.gd
TheLsbt Dec 26, 2023
3f1469a
Updated the tooltips
TheLsbt Dec 26, 2023
a02bc8c
Rename Select.png to select.png
TheLsbt Dec 26, 2023
4b21876
Rename Select.png.import to select.png.import
TheLsbt Dec 26, 2023
0ce5481
Rename Move.png.import to move.png.import
TheLsbt Dec 26, 2023
6d36138
Rename Rotate.png to rotate.png
TheLsbt Dec 26, 2023
d1b8d65
Rename Rotate.png.import to rotate.png.import
TheLsbt Dec 26, 2023
d86bd6f
Fixed import files
TheLsbt Dec 26, 2023
2070b85
Merge branch 'master' of https://github.com/TheLsbt/Pixelorama
TheLsbt Dec 26, 2023
d516912
Rename Scale.png to scale.png
TheLsbt Dec 26, 2023
b6776e1
Rename Scale.png.import to scale.png.import
TheLsbt Dec 26, 2023
6aa274f
Added logic to update the reference panel when the project changes
TheLsbt Dec 27, 2023
4dd250f
Merge branch 'master' of https://github.com/TheLsbt/Pixelorama
TheLsbt Dec 27, 2023
ef87d10
Update Project.gd
TheLsbt Dec 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Translations/Translations.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2780,10 +2780,36 @@ msgstr ""
msgid "Spring towards the end"
msgstr ""

msgid "Silhouette"
#. Used to turn images into a singular color
msgid "Monochrome"
msgstr ""

msgid "Blacks out the image and makes all opaque pixels a dark color."
#. A tooltip to tell users to hold the Shift key while clicking the remove button
msgid "Hold Shift while pressing to instantly remove"
msgstr ""

#. Moves the reference image up in the list
msgid "Move the selected reference image to the right"
msgstr ""

#. Moves the reference image down in the list
msgid "Move the selected reference image to the left"
msgstr ""

#. Select a reference on the canvas
msgid "Selects a reference image on the canvas"
msgstr ""

#. Moves the reference on the canvas
msgid "Move the selected reference image"
msgstr ""

#. Rotates the reference on the canvas
msgid "Rotate the selected reference image"
msgstr ""

#. Rotates the reference on the canvas
msgid "Scale the selected reference image"
msgstr ""

#. Used in checkbuttons (like on/off switches) that enable/disable something.
Expand Down
Binary file added assets/graphics/reference_images/move.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/graphics/reference_images/move.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cedsyi8gf2n2i"
path="res://.godot/imported/move.png-ed702c0a346cd77f0de30a0cba128fc7.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/reference_images/move.png"
dest_files=["res://.godot/imported/move.png-ed702c0a346cd77f0de30a0cba128fc7.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added assets/graphics/reference_images/rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/graphics/reference_images/rotate.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dtd43nvphu3jj"
path="res://.godot/imported/rotate.png-456db7ada5d7cd37fa30dc5557b226be.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/reference_images/rotate.png"
dest_files=["res://.godot/imported/rotate.png-456db7ada5d7cd37fa30dc5557b226be.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added assets/graphics/reference_images/scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/graphics/reference_images/scale.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://nfabwr5mgdir"
path="res://.godot/imported/scale.png-475926e4af79bb726ef59440df6e6f71.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/reference_images/scale.png"
dest_files=["res://.godot/imported/scale.png-475926e4af79bb726ef59440df6e6f71.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added assets/graphics/reference_images/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/graphics/reference_images/select.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d2m7enib3dplc"
path="res://.godot/imported/select.png-7c7e96d5ba897a73341e1d0445a3c991.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/reference_images/select.png"
dest_files=["res://.godot/imported/select.png-7c7e96d5ba897a73341e1d0445a3c991.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
20 changes: 20 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,26 @@ onion_skinning_settings={
"deadzone": 0.5,
"events": []
}
reference_rotate={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
reference_scale={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194328,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
reference_quick_menu={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
cancel_reference_transform={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}

[internationalization]

Expand Down
9 changes: 9 additions & 0 deletions src/Autoload/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn")

## The perspective editor. It has the [param PerspectiveEditor.gd] script attached.
@onready var perspective_editor := control.find_child("Perspective Editor")

## The reference panel. It has the [param ReferencesPanel.gd] script attached.
@onready var reference_panel: ReferencesPanel = control.find_child("Reference Images")

## The top menu container. It has the [param TopMenuContainer.gd] script attached.
@onready var top_menu_container: Panel = control.find_child("TopMenuContainer")
## The label indicating cursor position.
Expand Down Expand Up @@ -657,6 +661,10 @@ func _initialize_keychain() -> void:
Keychain.InputAction.new("", "Transformation tools", false),
"transform_copy_selection_content":
Keychain.InputAction.new("", "Transformation tools", false),
"reference_rotate": Keychain.InputAction.new("", "Reference images", false),
"reference_scale": Keychain.InputAction.new("", "Reference images", false),
"reference_quick_menu": Keychain.InputAction.new("", "Reference images", false),
"cancel_reference_transform": Keychain.InputAction.new("", "Reference images", false)
}

Keychain.groups = {
Expand All @@ -679,6 +687,7 @@ func _initialize_keychain() -> void:
"Shape tools": Keychain.InputGroup.new("Tool modifiers"),
"Selection tools": Keychain.InputGroup.new("Tool modifiers"),
"Transformation tools": Keychain.InputGroup.new("Tool modifiers"),
"Reference images": Keychain.InputGroup.new("Canvas")
}
Keychain.ignore_actions = ["left_mouse", "right_mouse", "middle_mouse", "shift", "ctrl"]

Expand Down
4 changes: 2 additions & 2 deletions src/Autoload/OpenSave.gd
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ func import_reference_image_from_path(path: String) -> void:
var ri := ReferenceImage.new()
ri.project = project
ri.deserialize({"image_path": path})
Global.canvas.add_child(ri)
Global.canvas.reference_image_container.add_child(ri)
reference_image_imported.emit()


Expand All @@ -760,7 +760,7 @@ func import_reference_image_from_image(image: Image) -> void:
var ri := ReferenceImage.new()
ri.project = project
ri.create_from_image(image)
Global.canvas.add_child(ri)
Global.canvas.reference_image_container.add_child(ri)
reference_image_imported.emit()


Expand Down
41 changes: 41 additions & 0 deletions src/Classes/Project.gd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var animation_tags: Array[AnimationTag] = []:
var guides: Array[Guide] = []
var brushes: Array[Image] = []
var reference_images: Array[ReferenceImage] = []
var reference_index: int = -1 # The currently selected index ReferenceImage
var vanishing_points := [] ## Array of Vanishing Points
var fps := 6.0

Expand Down Expand Up @@ -250,6 +251,21 @@ func change_project() -> void:
var edit_menu_popup: PopupMenu = Global.top_menu_container.edit_menu
edit_menu_popup.set_item_disabled(Global.EditMenu.NEW_BRUSH, !has_selection)

# We loop through all the reference image nodes and the ones that are not apart
# of the current project we remove from the tree
# They will still be in memory though
for ri: ReferenceImage in Global.canvas.reference_image_container.get_children():
if !reference_images.has(ri):
Global.canvas.reference_image_container.remove_child(ri)
# Now we loop through this projects reference images and add them back to the tree
var canvas_references := Global.canvas.reference_image_container.get_children()
for ri: ReferenceImage in reference_images:
if !canvas_references.has(ri) and !ri.is_inside_tree():
Global.canvas.reference_image_container.add_child(ri)

# Tell the reference images that the project changed
Global.reference_panel.project_changed()

var i := 0
for camera in Global.cameras:
camera.rotation = cameras_rotation[i]
Expand Down Expand Up @@ -870,3 +886,28 @@ func _update_layer_ui() -> void:
for f in frames.size():
cel_hbox.get_child(f).layer = l
cel_hbox.get_child(f).button_setup()


## Change the current reference image
func set_reference_image_index(new_index: int) -> void:
reference_index = clamp(-1, new_index, reference_images.size() - 1)
Global.canvas.reference_image_container.update_index(reference_index)


## Returns the reference image based on reference_index
func get_current_reference_image() -> ReferenceImage:
return get_reference_image(reference_index)


## Returns the reference image based on the index or null if index < 0
func get_reference_image(index: int) -> ReferenceImage:
if index < 0 or index > reference_images.size() - 1:
return null
return reference_images[index]


## Reorders the position of the reference image in the tree / reference_images array
func reorder_reference_image(from: int, to: int) -> void:
var ri: ReferenceImage = reference_images.pop_at(from)
reference_images.insert(to, ri)
Global.canvas.reference_image_container.move_child(ri, to)
21 changes: 21 additions & 0 deletions src/Shaders/ReferenceImageShader.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
shader_type canvas_item;

// This shader gets applied to every single reference image.


uniform bool monochrome = false;
// Used because modulate does not work when monochrome is true
uniform vec4 monchrome_color : source_color;
// Clamp the color by using the greyscale of the image to identify the brightness of each pixel
uniform float clamping : hint_range(0.0, 1.0, 0.01) = 0.0;

void fragment() {
// The original color
vec4 color = texture(TEXTURE, UV);
// Get the greyscale based on the brightest channel
float greyscale = max(max(color.r, color.g), color.b);
// Dont Use Alpha Channel past this statement!
if (greyscale < clamping) COLOR.a = 0.0;
// If we want the image to be onochrome we just set that pixels rgb color.
if (monochrome) COLOR.rgb = monchrome_color.rgb;
}
14 changes: 0 additions & 14 deletions src/Shaders/SilhouetteShader.gdshader

This file was deleted.

1 change: 1 addition & 0 deletions src/UI/Canvas/Canvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var layer_metadata_texture := ImageTexture.new()
@onready var mouse_guide_container := $MouseGuideContainer as Node2D
@onready var gizmos_3d := $Gizmos3D as Node2D
@onready var measurements := $Measurements as Node2D
@onready var reference_image_container := $ReferenceImages as Node2D
TheLsbt marked this conversation as resolved.
Show resolved Hide resolved


func _ready() -> void:
Expand Down
6 changes: 5 additions & 1 deletion src/UI/Canvas/Canvas.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://ba24iuv55m4l3"]
[gd_scene load_steps=22 format=3 uid="uid://ba24iuv55m4l3"]

[ext_resource type="Script" path="res://src/UI/Canvas/Canvas.gd" id="1"]
[ext_resource type="Shader" path="res://src/Shaders/BlendLayers.gdshader" id="1_253dh"]
Expand All @@ -16,6 +16,7 @@
[ext_resource type="Script" path="res://src/UI/Canvas/CropRect.gd" id="13"]
[ext_resource type="Script" path="res://src/UI/Canvas/Gizmos3D.gd" id="14"]
[ext_resource type="Script" path="res://src/UI/Canvas/Measurements.gd" id="16_nxilb"]
[ext_resource type="Script" path="res://src/UI/Canvas/ReferenceImages.gd" id="17_qfjb4"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_6b0ox"]
shader = ExtResource("1_253dh")
Expand Down Expand Up @@ -93,3 +94,6 @@ script = ExtResource("14")

[node name="Measurements" type="Node2D" parent="."]
script = ExtResource("16_nxilb")

[node name="ReferenceImages" type="Node2D" parent="."]
script = ExtResource("17_qfjb4")
Loading