How to save a sprite in png with a shader applied?

Hi everyone, I’m new to Godot. I’m trying to create a character maker. At the moment, there is a shader that changes the color of the animated sprite.


Now I’m trying to write a script that saves the result in png by button pressed, but so far I’ve only managed to save the frame from the animation without the shader applied.

extends Button

func _on_pressed():
	var sprite = get_node("../CharacterSprite")
	var animation = sprite.get_animation()
	var frames = sprite.get_sprite_frames()
	for i in frames.get_frame_count(animation):
		print(i)
	
	var texture = frames.get_frame_texture(animation, 0)
	var image = Image.new()
	
	image = texture.get_image()
	image.save_png("file.png")

How do I save a frame with a changed color?

You can’t get the data from the shader directly like that, it’s only available on the graphics card, you can try using a viewport texture to extract it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.