{
  "name": "Spiral Galaxy Globe",
  "dimension": "3d",
  "slot": "action_bar",
  "width": 256,
  "height": 128,
  "textBaseline": 128,
  "placement": {
    "x": 0,
    "y": 0
  },
  "shapes": [],
  "texts": [],
  "heads": [],
  "images": [],
  "bars": [],
  "triggers": [],
  "world": {
    "glsl": "const vec3 SG_C = vec3(0.0, 0.10, 0.0);\nconst float SG_R = 0.73;\nvec2 sgSphere(vec3 ro, vec3 rd, vec3 c, float r) {\n    vec3 p=ro-c;\n    float b=dot(p,rd);\n    float h=b*b-dot(p,p)+r*r;\n    if(h<0.0) return vec2(1e4,-1e4);\n    h=sqrt(h);\n    return vec2(-b-h,-b+h);\n}\nvec4 sgCylinderHit(vec3 ro, vec3 rd, float y, float r, float hh, float t0) {\n    vec3 p=ro-vec3(0.0,y,0.0);\n    float a=dot(rd.xz,rd.xz);\n    float b=dot(p.xz,rd.xz);\n    float c=dot(p.xz,p.xz)-r*r;\n    float h=b*b-a*c;\n    vec4 hit=vec4(0.0,1.0,0.0,1e4);\n    if(h>0.0 && a>0.00001) {\n        float t=(-b-sqrt(h))/a;\n        float py=p.y+t*rd.y;\n        if(t>=t0 && abs(py)<=hh) hit=vec4(normalize(vec3(p.x+t*rd.x,0.0,p.z+t*rd.z)),t);\n    }\n    if(abs(rd.y)>0.00001) {\n        float sy=rd.y>0.0 ? -1.0 : 1.0;\n        float t=(sy*hh-p.y)/rd.y;\n        if(t>=t0 && t<hit.w && length(p.xz+t*rd.xz)<r) hit=vec4(0.0,sy,0.0,t);\n    }\n    return hit;\n}\nvec3 sgGalaxyFrame(vec3 p, float time) {\n    p-=SG_C;\n    p.yz=rpw_rot(0.48)*p.yz;\n    p.xy=rpw_rot(-0.12)*p.xy;\n    p.xz=rpw_rot(time*0.16)*p.xz;\n    return p;\n}\nvec4 sgGlass(vec3 ro, vec3 rd, float t, float back, vec3 light) {\n    vec3 n=normalize(ro+rd*t-SG_C);\n    float fres=pow(1.0-abs(dot(n,rd)),3.0);\n    vec3 refl=reflect(rd,n);\n    float sun=pow(max(dot(refl,normalize(vec3(-0.45,0.78,0.48))),0.0),110.0);\n    float streak=pow(max(dot(n,normalize(vec3(-0.52,0.38,0.77))),0.0),85.0);\n    float streak2=pow(max(dot(n,normalize(vec3(0.63,0.14,0.76))),0.0),155.0);\n    float a=(0.02+0.67*fres+0.42*streak+0.3*streak2+0.6*sun)*back;\n    vec3 col=rpw_sky(refl)*mix(vec3(0.60,0.78,0.90),vec3(0.9,0.98,1.0),fres)*max(light,vec3(0.3));\n    col+=vec3(1.0,0.97,0.89)*(sun*1.8+streak*0.6+streak2*0.45);\n    return vec4(col,clamp(a,0.0,0.94));\n}\nvec4 object(vec3 ro, vec3 rd, float t0, float t1, float time, vec3 light, inout float depth) {\n    vec4 bh=sgCylinderHit(ro,rd,-0.732,0.475,0.064,t0);\n    vec4 h=sgCylinderHit(ro,rd,-0.638,0.421,0.030,t0);\n    if(h.w<bh.w) bh=h;\n    h=sgCylinderHit(ro,rd,-0.807,0.488,0.013,t0);\n    if(h.w<bh.w) bh=h;\n    float baseT=bh.w;\n    vec3 baseCol=vec3(0.0);\n    if(baseT<=t1) {\n        vec3 p=ro+rd*baseT;\n        vec3 n=bh.xyz;\n        float gold=max(1.0-smoothstep(0.005,0.009,abs(p.y+0.784)),1.0-smoothstep(0.004,0.009,abs(p.y+0.677)));\n        gold=max(gold,1.0-smoothstep(0.005,0.009,abs(p.y+0.812)));\n        gold=max(gold,step(-0.615,p.y)*smoothstep(0.33,0.40,length(p.xz)));\n        float grooves=0.5+0.5*cos(atan(p.z,p.x)*72.0);\n        vec3 material=mix(vec3(0.036,0.050,0.070)*(0.65+0.35*grooves),vec3(0.68,0.42,0.16),gold);\n        vec3 ld=normalize(vec3(-0.4,0.8,0.5));\n        float diff=max(dot(n,ld),0.0);\n        float spec=pow(max(dot(reflect(rd,n),ld),0.0),52.0);\n        baseCol=material*(0.3+0.8*diff)*light+rpw_sky(reflect(rd,n))*material*0.5*light+spec*mix(vec3(0.3),vec3(1.0,0.77,0.38),gold)*light;\n        float trim=exp(-pow((length(p.xz)-0.36)/0.006,2.0))*step(0.5,n.y);\n        baseCol+=vec3(0.28,0.44,0.70)*trim*0.45;\n    }\n    vec2 shell=sgSphere(ro,rd,SG_C,SG_R);\n    vec3 col=vec3(0.0);\n    float alpha=0.0;\n    float visibleDepth=baseT;\n    if(shell.x>=t0 && shell.x<min(t1,baseT)) {\n        vec4 g=sgGlass(ro,rd,shell.x,1.0,light);\n        col=g.rgb*g.a;\n        alpha=g.a;\n        visibleDepth=shell.x;\n    }\n    vec2 vol=sgSphere(ro,rd,SG_C,0.64);\n    float va=max(t0,vol.x);\n    float vb=min(min(t1,vol.y),baseT);\n    if(vb>va) {\n        vec3 qr=sgGalaxyFrame(ro,time);\n        vec3 qd=sgGalaxyFrame(ro+rd,time)-qr;\n        float ga=va;\n        float gb=vb;\n        if(abs(qd.y)>0.0001) {\n            float u=(-0.16-qr.y)/qd.y;\n            float v=(0.16-qr.y)/qd.y;\n            ga=max(ga,min(u,v));\n            gb=min(gb,max(u,v));\n        }\n        float dt=max(gb-ga,0.0)/28.0;\n        for(int i=0;i<28;i++) {\n            if(dt<=0.0) break;\n            float st=ga+(float(i)+0.5)*dt;\n            vec3 q=qr+qd*st;\n            float r=length(q.xz);\n            float ang=atan(q.z,q.x);\n            float winding=ang*2.0+7.0*log(r+0.16);\n            float wave=0.5+0.5*cos(winding);\n            float arm=wave*wave*wave*wave*wave*wave;\n            vec3 np=q*32.0;\n            vec3 cell=floor(np);\n            vec3 f=fract(np);\n            f=f*f*(3.0-2.0*f);\n            float nh=dot(cell,vec3(127.1,74.7,311.7));\n            vec4 hc=nh+vec4(0.0,127.1,311.7,438.8);\n            vec4 hv=fract(sin(hc)*43758.5453);\n            vec4 hw=fract(sin(hc+74.7)*43758.5453);\n            float nv=mix(mix(hv.x,hv.y,f.x),mix(hv.z,hv.w,f.x),f.z);\n            float nw=mix(mix(hw.x,hw.y,f.x),mix(hw.z,hw.w,f.x),f.z);\n            float no=mix(nv,nw,f.y);\n            float radial=(1.0-smoothstep(0.43,0.615,r))*smoothstep(0.035,0.13,r);\n            float thick=exp(-abs(q.y)/(0.022+0.014*(1.0-r/0.64)));\n            float arms=radial*thick*(0.065+arm*2.2)*(0.4+no*1.15);\n            float core=exp(-r*r/0.0050-q.y*q.y/0.0018);\n            float haze=exp(-r*r/0.13-q.y*q.y/0.011)*0.25;\n            float density=arms*10.0+core*35.0+haze;\n            float a=1.0-exp(-density*dt);\n            vec3 outer=mix(vec3(0.46,0.12,1.0),vec3(0.25,0.80,1.45),arm*(0.35+no*0.65));\n            vec3 color=mix(outer,vec3(1.8,1.20,0.58),exp(-r*r/0.015));\n            float knots=max((no-0.5)*2.0,0.0);\n            knots=knots*knots*knots*arm;\n            color+=vec3(0.7,1.2,1.6)*knots*1.7;\n            color+=vec3(0.6,0.45,0.3)*core;\n            col+=(1.0-alpha)*color*a;\n            alpha+=(1.0-alpha)*a;\n            if(visibleDepth>t1 && alpha>0.12) visibleDepth=st;\n            if(alpha>0.985) break;\n        }\n        vec3 stars=vec3(0.0);\n        for(int i=0;i<24;i++) {\n            float fi=float(i);\n            float h1=fract(sin(fi*127.1+2.0)*43758.54);\n            float h2=fract(sin(fi*311.7+5.0)*22578.14);\n            float rr=0.19+0.38*sqrt(h1);\n            float angle=fi*2.39996-time*0.08;\n            vec3 s=vec3(rr*cos(angle),(h2-0.5)*0.57,rr*sin(angle));\n            float ts=dot(s-qr,qd);\n            if(ts<va || ts>vb) continue;\n            vec3 offset=qr+qd*ts-s;\n            float d2=dot(offset,offset);\n            float tw=0.75+0.25*sin(time*(0.65+h1)+fi*2.1);\n            float star=exp(-d2/0.000028)*2.0+exp(-d2/0.0003)*0.12;\n            stars+=mix(vec3(0.48,0.72,1.0),vec3(1.0,0.8,0.5),h2)*star*tw;\n        }\n        float sa=clamp(max(stars.r,max(stars.g,stars.b)),0.0,0.9);\n        col+=stars*(1.0-alpha*0.65);\n        alpha+=(1.0-alpha)*sa;\n    }\n    if(shell.y>=t0 && shell.y<min(t1,baseT)) {\n        vec4 g=sgGlass(ro,rd,shell.y,0.48,light);\n        col+=(1.0-alpha)*g.rgb*g.a;\n        alpha+=(1.0-alpha)*g.a;\n        if(visibleDepth>t1) visibleDepth=shell.y;\n    }\n    if(baseT<=t1) {\n        col+=(1.0-alpha)*baseCol;\n        alpha=1.0;\n        if(visibleDepth>t1) visibleDepth=baseT;\n    }\n    if(alpha<0.001) return vec4(0.0);\n    depth=clamp(visibleDepth,t0,t1);\n    return vec4(col/max(alpha,0.0001),alpha);\n}",
    "prompt": "a glass snow globe with a tiny spiral galaxy swirling inside it",
    "size": 4,
    "summary": "A reflective glass snow globe on a brass-trimmed pedestal holds a slowly swirling blue-violet spiral galaxy with a warm luminous core and softly twinkling, orbiting stars."
  }
}