Fresnel

Fresnel snippet
Perhaps one of the more versatile effects for spatial shaders, fresnel is used for many things. From making water look more natural to simulating rim lighting and even creating force fields.

The fresnel effect is simulating the relationship between a surface’s angle and how much light you will see coming from that surface. The more the surface is pointing away from you the more light you’ll see, creating bright edges.

Basic fresnel

float fresnel(float amount, vec3 normal, vec3 view)
{
	return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0 )), amount);
}

void fragment()
{
	vec3 base_color = vec3(0.0);
	float basic_fresnel = fresnel(3.0, NORMAL, VIEW);
	ALBEDO = base_color + basic_fresnel;
}

Colorful glow fresnel

This snippet lets you colorize the fresnel by multiplying it with an RGB-value and set the intensity to either tone down the effect or, if you crank it up, make it glow. You need to enable Glow in the Environment node. (The clamp() has been removed allowing the fresnel to go beyond 1.0). You can also make the fresnel glow by assigning it to EMISSION.

vec3 fresnel_glow(float amount, float intensity, vec3 color, vec3 normal, vec3 view)
{
	return pow((1.0 - dot(normalize(normal), normalize(view))), amount) * color * intensity;
}

void fragment()
{
	vec3 base_color = vec3(0.5, 0.2, 0.9);
	vec3 fresnel_color = vec3(0.0, 0.7, 0.9);
	vec3 fresnel = fresnel_glow(4.0, 4.5, fresnel_color, NORMAL, VIEW);
	ALBEDO = base_color + fresnel;
}