Mesh Blend – Alpha Blend – Soft Particles – Blend between water and ground

Blend 2 Meshes

 

Proximity Fade in OpenGL is fixed in Godot 4.6, simply enable it in the material properties of your mesh.

In Godot 4.5 changing Scaling 3D will spam errors and make your mesh invisible.

To use this code in earlier versions you would need to recompile your engine with the fix.

https://github.com/godotengine/godot/pull/111234/files

 

Add the shader to your shader code.

Remove the “if” statement if you only use one renderer. If you are gonna support both Vulkan and OpenGL keep it.

Combination of

https://github.com/godotengine/godot/blob/master/scene/resources/material.cpp (Proximity Fade)

https://docs.godotengine.org/en/stable/tutorials/shaders/advanced_postprocessing.html (Depth Buffer)

 

Tags for people to find (My search history)

Godot smooth alpha

Godot blend water and ground

Godot make vfx smooth

Blur the intersection between 2 meshes Godot

Smooth alpha card Godot

Smooth water Shader

Alpha Material Smoothing

Godot soft particles

Linear Depth

Shader code
shader_type spatial;
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;
uniform float fade_distance : hint_range(0.0, 4096.0, 0.01);

void fragment() {
	float depth = textureLod(depth_texture, SCREEN_UV, 0.0).r;
	#if CURRENT_RENDERER == RENDERER_COMPATIBILITY
	vec3 ndc = vec3(SCREEN_UV, depth) * 2.0 - 1.0;
	#else
	vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
	#endif
	vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
	view.xyz /= view.w;
	ALPHA *= clamp(1.0 - smoothstep(view.z + fade_distance, view.z, VERTEX.z), 0.0, 1.0);
}
Live Preview
Tags
alpha, blend, depth, Smoot, Soft, Soft Particle, vfx, water
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.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments