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

Fix gradient map layer effect being purple when it's first created

This commit is contained in:
Emmanouil Papadeas 2024-07-12 14:45:24 +03:00
parent fae89ed2a1
commit f4f0e4047e
3 changed files with 14 additions and 15 deletions

View file

@ -1222,7 +1222,9 @@ func create_ui_for_shader_uniforms(
gradient_edit.set_gradient_texture(params[u_name]) gradient_edit.set_gradient_texture(params[u_name])
else: else:
params[u_name] = gradient_edit.texture params[u_name] = gradient_edit.texture
value_changed.call(gradient_edit.get_node("TextureRect").texture, u_name) # This needs to be call_deferred because GradientTexture2D gets updated next frame.
# Without this, the texture is purple.
value_changed.call_deferred(gradient_edit.texture, u_name)
gradient_edit.updated.connect( gradient_edit.updated.connect(
func(_gradient, _cc): value_changed.call(gradient_edit.texture, u_name) func(_gradient, _cc): value_changed.call(gradient_edit.texture, u_name)
) )

View file

@ -8,11 +8,11 @@ signal updated(gradient: Gradient, cc: bool)
var continuous_change := true var continuous_change := true
var active_cursor: GradientCursor ## Showing a color picker popup to change a cursor's color var active_cursor: GradientCursor ## Showing a color picker popup to change a cursor's color
var texture := GradientTexture2D.new()
var gradient := Gradient.new()
@onready var x_offset: float = size.x - GradientCursor.WIDTH @onready var x_offset: float = size.x - GradientCursor.WIDTH
@onready var texture_rect: TextureRect = $TextureRect as TextureRect @onready var texture_rect := $TextureRect as TextureRect
@onready var texture := texture_rect.texture as GradientTexture2D
@onready var gradient := texture.gradient
@onready var color_picker := $Popup.get_node("ColorPicker") as ColorPicker @onready var color_picker := $Popup.get_node("ColorPicker") as ColorPicker
@onready var divide_dialog := $DivideConfirmationDialog as ConfirmationDialog @onready var divide_dialog := $DivideConfirmationDialog as ConfirmationDialog
@onready var number_of_parts_spin_box := $"%NumberOfPartsSpinBox" as SpinBox @onready var number_of_parts_spin_box := $"%NumberOfPartsSpinBox" as SpinBox
@ -98,7 +98,12 @@ class GradientCursor:
set_color(data) set_color(data)
func _init() -> void:
texture.gradient = gradient
func _ready() -> void: func _ready() -> void:
texture_rect.texture = texture
_create_cursors() _create_cursors()
%InterpolationOptionButton.select(gradient.interpolation_mode) %InterpolationOptionButton.select(gradient.interpolation_mode)
%ColorSpaceOptionButton.select(gradient.interpolation_color_space) %ColorSpaceOptionButton.select(gradient.interpolation_color_space)

View file

@ -1,14 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://bn4aw27dj7pwi"] [gd_scene load_steps=2 format=3 uid="uid://bn4aw27dj7pwi"]
[ext_resource type="Script" path="res://src/UI/Nodes/GradientEdit.gd" id="1"] [ext_resource type="Script" path="res://src/UI/Nodes/GradientEdit.gd" id="1"]
[sub_resource type="Gradient" id="Gradient_1k8kj"]
resource_local_to_scene = true
[sub_resource type="GradientTexture2D" id="GradientTexture2D_fau1l"]
resource_local_to_scene = true
gradient = SubResource("Gradient_1k8kj")
[node name="GradientEdit" type="VBoxContainer"] [node name="GradientEdit" type="VBoxContainer"]
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -19,7 +12,6 @@ script = ExtResource("1")
custom_minimum_size = Vector2(0, 30) custom_minimum_size = Vector2(0, 30)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
texture = SubResource("GradientTexture2D_fau1l")
expand_mode = 1 expand_mode = 1
[node name="Value" type="Label" parent="TextureRect"] [node name="Value" type="Label" parent="TextureRect"]
@ -38,8 +30,8 @@ offset_bottom = 7.0
[node name="ColorPicker" type="ColorPicker" parent="Popup"] [node name="ColorPicker" type="ColorPicker" parent="Popup"]
offset_left = 4.0 offset_left = 4.0
offset_top = 4.0 offset_top = 4.0
offset_right = 294.0 offset_right = 302.0
offset_bottom = 572.0 offset_bottom = 580.0
[node name="InterpolationContainer" type="HBoxContainer" parent="."] [node name="InterpolationContainer" type="HBoxContainer" parent="."]
layout_mode = 2 layout_mode = 2