mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Fix wrong preview in the gradient dialog when editing the gradient and dithering is enabled
This commit is contained in:
parent
501a7d3c02
commit
1e2e5dc431
|
@ -63,17 +63,20 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
|
|
||||||
var dither_texture := selected_dither_matrix.texture
|
var dither_texture := selected_dither_matrix.texture
|
||||||
var gradient := gradient_edit.gradient
|
var gradient := gradient_edit.gradient
|
||||||
var n_of_colors := gradient.offsets.size()
|
var offsets := gradient.offsets
|
||||||
|
offsets.sort()
|
||||||
|
var n_of_colors := offsets.size()
|
||||||
# Pass the gradient offsets as an array to the shader
|
# Pass the gradient offsets as an array to the shader
|
||||||
# ...but since Godot 3.x doesn't support uniform arrays, instead we construct
|
# ...but we can't provide arrays with variable sizes as uniforms, instead we construct
|
||||||
# a nx1 grayscale texture with each offset stored in each pixel, and pass it to the shader
|
# a nx1 grayscale texture with each offset stored in each pixel, and pass it to the shader
|
||||||
var offsets_image := Image.create(n_of_colors, 1, false, Image.FORMAT_L8)
|
var offsets_image := Image.create(n_of_colors, 1, false, Image.FORMAT_L8)
|
||||||
# Construct an image that contains the selected colors of the gradient without interpolation
|
# Construct an image that contains the selected colors of the gradient without interpolation
|
||||||
var gradient_image := Image.create(n_of_colors, 1, false, Image.FORMAT_RGBA8)
|
var gradient_image := Image.create(n_of_colors, 1, false, Image.FORMAT_RGBA8)
|
||||||
for i in n_of_colors:
|
for i in n_of_colors:
|
||||||
var c := gradient.offsets[i]
|
var c := offsets[i]
|
||||||
offsets_image.set_pixel(i, 0, Color(c, c, c, c))
|
offsets_image.set_pixel(i, 0, Color(c, c, c, c))
|
||||||
gradient_image.set_pixel(i, 0, gradient.colors[i])
|
var actual_index := gradient.offsets.find(offsets[i])
|
||||||
|
gradient_image.set_pixel(i, 0, gradient.colors[actual_index])
|
||||||
var offsets_tex := ImageTexture.create_from_image(offsets_image)
|
var offsets_tex := ImageTexture.create_from_image(offsets_image)
|
||||||
var gradient_tex: Texture2D
|
var gradient_tex: Texture2D
|
||||||
if shader == shader_linear:
|
if shader == shader_linear:
|
||||||
|
|
|
@ -32,10 +32,9 @@ unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
item_count = 2
|
|
||||||
selected = 0
|
selected = 0
|
||||||
|
item_count = 2
|
||||||
popup/item_0/text = "Linear"
|
popup/item_0/text = "Linear"
|
||||||
popup/item_0/id = 0
|
|
||||||
popup/item_1/text = "Radial"
|
popup/item_1/text = "Radial"
|
||||||
popup/item_1/id = 1
|
popup/item_1/id = 1
|
||||||
|
|
||||||
|
@ -47,10 +46,9 @@ text = "Dithering pattern:"
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
item_count = 1
|
|
||||||
selected = 0
|
selected = 0
|
||||||
|
item_count = 1
|
||||||
popup/item_0/text = "None"
|
popup/item_0/text = "None"
|
||||||
popup/item_0/id = 0
|
|
||||||
|
|
||||||
[node name="RepeatLabel" type="Label" parent="VBoxContainer/GradientOptions" index="4" groups=["gradient_common"]]
|
[node name="RepeatLabel" type="Label" parent="VBoxContainer/GradientOptions" index="4" groups=["gradient_common"]]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -60,10 +58,9 @@ text = "Repeat:"
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
item_count = 4
|
|
||||||
selected = 0
|
selected = 0
|
||||||
|
item_count = 4
|
||||||
popup/item_0/text = "None"
|
popup/item_0/text = "None"
|
||||||
popup/item_0/id = 0
|
|
||||||
popup/item_1/text = "Repeat"
|
popup/item_1/text = "Repeat"
|
||||||
popup/item_1/id = 1
|
popup/item_1/id = 1
|
||||||
popup/item_2/text = "Mirror"
|
popup/item_2/text = "Mirror"
|
||||||
|
|
Loading…
Reference in a new issue