Medium 3DAnimated

Gas giant

A banded, swirling planet with a blue atmosphere glow around it.

The target picture for the shader challenge "Gas giant"
Recreate this picture. You pass at a 99% match, then try to write it in fewer characters than the par.

How this challenge works

You write a fragment shader that draws the picture above, live in your browser. A match bar shows how close you are, and the score combines accuracy, code size (the par is 764 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.

The numbers you need

Sphere
same setup as the globe: R = 0.8, n = normalized (p, z)
Swirl
u = atan2(n.x, n.z) + time * 0.3
Bands
sin(n.y * 14.0 + 1.5 * sin(u * 2.0 + n.y * 3.0))
Base
lerp(float3(0.85,0.6,0.35), float3(0.95,0.85,0.65), 0.5 + 0.5 * bands)
Light
normalize(float3(0.5, 0.7, 0.6)), planet = base * (0.12 + 0.88 * diffuse)
Rim
pow(1.0 - n.z, 3.0), float3(0.4, 0.6, 1.0) * rim * 0.5, added to the planet
Glow outside
exp(-max(length(p) - R, 0.0) * 10.0) * (1.0 - mask) * 0.4 * float3(0.4,0.6,1.0)
Space
float3(0.02, 0.03, 0.06)

Solve it in your language

Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.

Start coding