1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-22 13:33:13 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
Variable
b2fe358950
Merge branch 'Orama-Interactive:master' into resource 2024-09-02 13:18:37 +05:00
Variable
f75939f8c6 moved a function to the shaderloader 2024-09-02 13:17:46 +05:00
Emmanouil Papadeas
9cac98c941 Add an alpha uniform to the IndexMap shader
In case users don't want the effect to affect the alpha channel
2024-09-02 02:21:48 +03:00
Variable
167b0d863c
fix wrong stretch mode in cel preview (#1097) 2024-09-02 02:03:39 +03:00
4 changed files with 18 additions and 14 deletions

View file

@ -704,17 +704,6 @@ func _init() -> void:
) )
func modify_texture_resource(image: Image, resource_name: StringName, update_callable: Callable):
var resource_proj = ResourceProject.new([], resource_name, image.get_size())
resource_proj.layers.append(PixelLayer.new(resource_proj))
resource_proj.frames.append(resource_proj.new_empty_frame())
resource_proj.frames[0].cels[0].set_content(image)
resource_proj.resource_updated.connect(update_callable)
Global.projects.append(resource_proj)
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
Global.canvas.camera_zoom()
func _ready() -> void: func _ready() -> void:
_initialize_keychain() _initialize_keychain()
default_width = config_cache.get_value("preferences", "default_width", default_width) default_width = config_cache.get_value("preferences", "default_width", default_width)

View file

@ -227,7 +227,7 @@ static func create_ui_for_shader_uniforms(
var mod_button := Button.new() var mod_button := Button.new()
mod_button.text = "Modify" mod_button.text = "Modify"
mod_button.pressed.connect( mod_button.pressed.connect(
func(): Global.modify_texture_resource( func(): _modify_texture_resource(
_get_loaded_texture(params, u_name), _get_loaded_texture(params, u_name),
u_name, u_name,
_shader_update_texture.bind(value_changed, u_name) _shader_update_texture.bind(value_changed, u_name)
@ -373,3 +373,14 @@ static func _shader_update_texture(
value_changed.call(ImageTexture.create_from_image(updated_image), parameter_name) value_changed.call(ImageTexture.create_from_image(updated_image), parameter_name)
if not warnings.is_empty(): if not warnings.is_empty():
Global.popup_error(warnings) Global.popup_error(warnings)
static func _modify_texture_resource(image: Image, resource_name: StringName, update_callable: Callable):
var resource_proj = ResourceProject.new([], resource_name, image.get_size())
resource_proj.layers.append(PixelLayer.new(resource_proj))
resource_proj.frames.append(resource_proj.new_empty_frame())
resource_proj.frames[0].cels[0].set_content(image)
resource_proj.resource_updated.connect(update_callable)
Global.projects.append(resource_proj)
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
Global.canvas.camera_zoom()

View file

@ -3,6 +3,7 @@ shader_type canvas_item;
render_mode unshaded; render_mode unshaded;
uniform sampler2D map_texture : filter_nearest; // The map texture uniform sampler2D map_texture : filter_nearest; // The map texture
uniform bool alpha = false;
// (begin DESCRIPTION) // (begin DESCRIPTION)
// The Red and Green values (0-255) of tool color will be treated as an x and y position // The Red and Green values (0-255) of tool color will be treated as an x and y position
@ -14,5 +15,8 @@ void fragment(){
vec2 map_size = vec2(textureSize(map_texture, 0)); vec2 map_size = vec2(textureSize(map_texture, 0));
vec2 lookup_uv = vec2(round(col.x * 255.0)/(map_size.x), round(col.y * 255.0)/(map_size.y)); vec2 lookup_uv = vec2(round(col.x * 255.0)/(map_size.x), round(col.y * 255.0)/(map_size.y));
vec4 index_color = texture(map_texture, lookup_uv); vec4 index_color = texture(map_texture, lookup_uv);
COLOR = index_color; COLOR.rgb = index_color.rgb;
if (alpha) {
COLOR.a = index_color.a;
}
} }

View file

@ -59,7 +59,7 @@ grow_vertical = 2
size_flags_horizontal = 0 size_flags_horizontal = 0
size_flags_vertical = 0 size_flags_vertical = 0
expand_mode = 1 expand_mode = 1
stretch_mode = 6 stretch_mode = 5
[node name="TransparentChecker" parent="CelTexture" instance=ExtResource("2_mi8wp")] [node name="TransparentChecker" parent="CelTexture" instance=ExtResource("2_mi8wp")]
show_behind_parent = true show_behind_parent = true