Transition between two textures

Very simple shader that is able to transition between two textures.

Looks nice if you use a tweener to move the “transform_ratio” from 0.0 to 1.0 and then back to 0.0.

Shader code
shader_type canvas_item;


uniform sampler2D texture_1 : source_color, repeat_enable, filter_nearest;
uniform sampler2D texture_2 : source_color, repeat_enable, filter_nearest;
uniform float transform_ratio : hint_range(0.0, 1.0, 0.01) = 1.0;

void fragment() {
	vec4 texture_1_color = texture(texture_1, UV );
	vec4 texture_2_color = texture(texture_2, UV );
	COLOR.rgb = (texture_1_color.rgb * transform_ratio) + (texture_2_color.rgb * abs(transform_ratio - 1.0) );
}
Live Preview
Tags
canvas_item, texture, transition
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from sanlor

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments