How to smoothly transition between two different materials

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nateteeples

I have a project where I want to have two separate materials fade into each other smoothly so it looks natural. What would be the best way to go about doing this? Is there a way to do it automatically with shaders or would I have to implement a solution from scratch? The terrain is procedurally generated so I can’t make a new material for each transition, I want to be able to have biomes fade between each other but I want to keep my current chunk system in place.

I want the green and white materials to smoothly fade together

:bust_in_silhouette: Reply From: DaddyMonster

I suspect you’ll just have to bite the bullet and code yourself a shader.

Really though, it shouldn’t be took difficult. You’ll need a uniform with a value from 0-1 to control the transition. You’ll then need to similarly import the two textures that you want to transition between and then just write yourself a linear interpolation function. Then output the result to your ALBEDO and you’re done.

Honestly, it sounds daunting but it’s really not that huge a task. Obviously, if you have normals, roughness and so forth then you’ll need to repeat the process with that.

Oh, a nice shortcut for you: take your starting texture and convert it to a shader so most of the code will be there for you.

EDIT: silly me, I forgot godot has mix() built in so you don’t even have to code the interpolation. And if you want to get fancy with the transition you can use a Tween cpu side.