Spinning Fog Circle

Just playing around with fog shaders. Put this on a fog volume with a decently large size (mine is 26x10x26). Make sure to create the noise texture and its noise property in the shader parameters. I just made this to play around with fog shaders, I haven’t seen many people use them.

Shader code
shader_type fog;

uniform float radius1 = 7.0;
uniform float radius2 = 0.5;
uniform float noise_intensity = 3.0;
uniform float density = 0.1;
uniform float spin_speed = 0.5;
uniform vec3 color:source_color = vec3(2.0);
uniform sampler3D noise;

// from inigo's website
float sdTorus( vec3 p, vec2 t )
  vec2 q = vec2(length(p.xz)-t.x,p.y);
  return length(q)-t.y;

void fog() {
	// Rotating coordinates for spinning noise
	vec3 coord = pos;
	float rot = radians(0.0);
	rot = TIME * spin_speed;
	mat2 m = mat2( vec2( cos(rot), -sin(rot) ), vec2( sin(rot), cos(rot) ) );
	vec2 coord_rot_xz = coord.xz * m;
	coord = vec3(coord_rot_xz.x, coord.y, coord_rot_xz.y);
	// SDF for torus drives density offset by noise (if less than 0, output 1 for density)
	DENSITY = float(sdTorus(pos, vec2(radius1,radius2)) - (texture(noise, coord).b * noise_intensity) < 0.0) * density;
	ALBEDO = color;
atmosphere, Fog, spin, volumetric
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

PSX Style Camera Shader – Distance Fog, Dithering, Color Limiter, Noise

2D fog overlay

Customizable Perlin Fog

Notify of

Inline Feedbacks
View all comments