POV-Ray : Newsgroups : povray.animations : Disintegration Macro Server Time
4 Nov 2026 11:20:07 EST (-0500)
  Disintegration Macro (Message 1 to 12 of 12)  
From: VAXHeadroom
Subject: Disintegration Macro
Date: 26 Oct 2026 23:30:00
Message: <web.6ae01a4334646e36c6d4b12d7c04d41a@news.povray.org>
I used claude.ai to create the following disintegration macro.  I really was
just curious if it even knew POVRay, and it turns out it knows it REALLY WELL!
This was the last piece I needed for a very large animation I'm working on for a
music video.  Whatever your opinion on AI coding, I gotta say this is damn good
code (I've been a professional programmer for >40 years).  Only thing I added
was the optional debug outputs.

Wanted to give it back to the community.

-- Emory

-----

// disintegrate.inc  --  tear a solid object apart and blow it along a vector
// POV-Ray 3.7+. Stateless: everything is computed from T, so it animates with
clock.
//
// Disintegrate(Obj, Dir, Step, T, Start, Sweep, Jitter, Life, Min_Scale, Speed,
Spread, Spin, Accel, Seed, Cut_Tex, Shards)
//
//   Obj      a declared, finite, SOLID object (#declare Obj = ...). Its texture
is kept on the pieces.
//   Dir      direction the pieces travel; the tear starts at the downstream end
and sweeps back
//   Step     size of the cubic cells the object is cut into (smaller = more,
finer pieces) -- but also the slice thickness along Dir
//   T        current time in seconds (e.g. clock * 4)
//   Start    time the tearing begins
//   Sweep    seconds for the tear front to cross the whole object
//   Jitter   random extra delay per piece in seconds (ragged, uneven tearing)
//   Life     seconds over which a piece shrinks from full size to nothing after
release
//   Min_Scale  a piece is not drawn once its scale (1 at release, 0 at Life) is
<= this value
//              (e.g. 0.05); use 0 to draw until the piece reaches zero size
//   Speed    average launch speed along Dir (units/sec)
//   Spread   sideways scatter, as a fraction of Speed (0 = straight, 0.5 = very
chaotic)
//   Spin     tumble rate in degrees/sec
//   Accel    constant acceleration vector, e.g. <0,-3,0> for gravity or Dir*2
for wind
//   Seed     integer random seed
//   Cut_Tex  texture for the faces created by cutting (and for plain cubes when
Shards = 0)
//   Shards   1 = pieces are the real object cut into cubes (keeps its shape and
texture)
//            0 = plain cubes using Cut_Tex (much faster to render)
//
// This code was written by claude.ai, prompted by Emory Stagmer (aka
VAXHeadroom)
// October 2026
//

#ifndef (DISINTEGRATE_DEBUG)
#declare DISINTEGRATE_DEBUG=false;
#end
#declare DISINTEGRATE_DEBUG_2=false;

#include "math.inc"   // for clamp()

#macro Disintegrate(Obj, Dir, Step, T, Start, Sweep, Jitter, Life, Min_Scale,
Speed, Spread, Spin, Accel, Seed, Cut_Tex, Cut_Int, Shards)
  #local Dn   = vnormalize(Dir);
  #local Pmin = min_extent(Obj);
  #local Pmax = max_extent(Obj);
  #local H    = Step / 2;

  // Extent of the object measured along Dir
  #local Smin = 1e9;
  #local Smax = -1e9;
  #for (C, 0, 7)
    #local Q = <(mod(C,2) = 0 ? Pmin.x : Pmax.x),
                (mod(floor(C/2),2) = 0 ? Pmin.y : Pmax.y),
                (C < 4 ? Pmin.z : Pmax.z)>;
    #local Smin = min(Smin, vdot(Q, Dn));
    #local Smax = max(Smax, vdot(Q, Dn));
  #end
  #local Range = max(Smax - Smin, 0.0001);

  // 1) The part of the object the tear front hasn't reached yet
  #local Front = Smax + 0.001 - clamp((T - Start) / Sweep, 0, 1) * Range;
  #if ((T - Start) < Sweep)    // once the front has crossed the object, nothing
intact remains
    intersection {
      object { Obj }
      plane { Dn, Front }
      texture { Cut_Tex }          // only used on the cut face
    }
  #end

#if( DISINTEGRATE_DEBUG )
#debug concat("DI: Pmin:<",str(Pmin.x,4,4),  ",", str(Pmin.y,4,4), ",",
str(Pmin.z,4,4),">\n")
#debug concat("DI: Pmax:<",str(Pmax.x,4,4),  ",", str(Pmax.y,4,4), ",",
str(Pmax.z,4,4),">\n")
#debug concat("DI: Front: ",str(Front,4,4),"\n")
#debug concat("DI: Smin:  ",str(Smin,4,4),"\n")
#debug concat("DI: Smax:  ",str(Smax,4,4),"\n")
#debug concat("DI: Range: ",str(Range,4,4),"\n")
#debug concat("DI: T   :  ",str(T,4,0),"\n")
#debug concat("DI: Start:  ",str(Start,4,0),"\n")
#debug concat("DI: Sweep:  ",str(Sweep,4,0),"\n")
#end

  // 2) The flying pieces
  #local R  = seed(Seed);
  #local Nx = int(ceil((Pmax.x - Pmin.x) / Step));
  #local Ny = int(ceil((Pmax.y - Pmin.y) / Step));
  #local Nz = int(ceil((Pmax.z - Pmin.z) / Step));

  #for (Ix, 0, Nx-1)
    #for (Iy, 0, Ny-1)
      #for (Iz, 0, Nz-1)
        #local P   = Pmin + <Ix + 0.5, Iy + 0.5, Iz + 0.5> * Step;
        #if (Shards)
          // Real shards: every cell is intersected with the object. Cells that
lie
          // outside it come out empty, so no inside() test is needed.
          #local Hit = 1;
        #else
          // Plain cubes: keep cells whose centre or any corner is inside the
object
          #local Hit = inside(Obj, P);
          #for (C, 0, 7)
            #if (Hit = 0)
              #local Hit = inside(Obj, P + <mod(C,2) - 0.5, mod(floor(C/2),2) -
0.5, floor(C/4) - 0.5> * Step * 0.98);
            #end
          #end
        #end

        #if (Hit)
          #local U   = (Smax - vdot(P, Dn)) / Range;     // 0 = downstream end,
1 = upstream end
          #local Tr  = Start + U*Sweep + rand(R)*Jitter; // release time
          #local Vsp = Speed * (0.5 + rand(R));
          #local Jt  = <rand(R) - 0.5, rand(R) - 0.5, rand(R) - 0.5> * 2;
          #local Rt  = <rand(R) - 0.5, rand(R) - 0.5, rand(R) - 0.5> * 2 * Spin;
          #local Age = T - Tr;

          #local Sc = 1 - Age/Life;                    // 1 at release, 0 at
Life

#if( DISINTEGRATE_DEBUG_2 & Ix=0 & Iy=0)
#debug concat("DI: Age       :  ",str(Age,4,4),"\n")
#debug concat("DI: Sc        :  ",str(Sc,4,4),"\n")
#debug concat("DI: Min_Scale :  ",str(Min_Scale,4,4),"\n")
#end

          #if ((Age >= 0) & (Sc > Min_Scale))
            #local Off = (Dn*Vsp + Spread*Speed*Jt) * Age + 0.5*Accel*Age*Age;
            #if (Shards)
              intersection {
                box { P - <H,H,H>, P + <H,H,H> }
                object { Obj }
                texture { Cut_Tex }
                //interior { Cut_Int }
                translate -P
                scale Sc
                rotate Rt * Age
                translate P + Off
              }
            #else
              box {
                <-H,-H,-H>, <H,H,H>
                texture { Cut_Tex }
                scale Sc
                rotate Rt * Age
                translate P + Off
              }
            #end
          #end
        #end
      #end
    #end
  #end
#end


Post a reply to this message

From: Maetes
Subject: Re: Disintegration Macro
Date: 27 Oct 2026 07:40:00
Message: <web.6ae08d1ca54f3a29be3cb90a7bb7ede7@news.povray.org>
I was curious and still am, but after 15 minutes of trial and error I didn't get
any result.
Do you have a working example?
Without it, such code snippets with dozens of macro parameters are rather
useless.

The last of my attempts:

#local oTest = sphere { 0,1 translate y*0 pigment { color rgb <1,1,0> } }
#local txCut = texture { pigment { color rgb <1,0,1> } }

//Disintegrate(Obj, Dir, Step, T, Start, Sweep, Jitter, Life, Min_Scale, Speed,
Spread, Spin, Accel, Seed, Cut_Tex, Cut_Int, Shards)

Disintegrate(oTest, <0,1,0>, 100, 1.3, 2, 3, 5, 100, 0.1, 0.1, 5, 20, <0,1,0>,
7, txCut, 10, 100)

m


Post a reply to this message


Attachments:
Download 'disintegrate.png' (9 KB)

Preview of image 'disintegrate.png'
disintegrate.png


 

From: MichaelJF
Subject: Re: Disintegration Macro
Date: 27 Oct 2026 15:24:52
Message: <6ae0fa84$1@news.povray.org>
Am 27.10.26 um 12:38 schrieb Maetes:
> I was curious and still am, but after 15 minutes of trial and error I didn't get
> any result.
> Do you have a working example?
> Without it, such code snippets with dozens of macro parameters are rather
> useless.
> 
> The last of my attempts:
> 
> #local oTest = sphere { 0,1 translate y*0 pigment { color rgb <1,1,0> } }
> #local txCut = texture { pigment { color rgb <1,0,1> } }
> 
> //Disintegrate(Obj, Dir, Step, T, Start, Sweep, Jitter, Life, Min_Scale, Speed,
> Spread, Spin, Accel, Seed, Cut_Tex, Cut_Int, Shards)
> 
> Disintegrate(oTest, <0,1,0>, 100, 1.3, 2, 3, 5, 100, 0.1, 0.1, 5, 20, <0,1,0>,
> 7, txCut, 10, 100)
> 
> m
If you are interested in a working explode-macro you may have a look at 
a very old code by Chris Colefax:

https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html

Example code is given there. Thanks to Cousin Ricky for for digging up 
the link.


Best regards from 200 km to the southeast,
Michael


Post a reply to this message

From: Maetes
Subject: Re: Disintegration Macro
Date: 28 Oct 2026 08:00:00
Message: <web.6ae1e376a54f3a2984777b987bb7ede7@news.povray.org>
MichaelJF <fri### [at] t-onlinede> wrote:
> If you are interested in a working explode-macro you may have a look at
> a very old code by Chris Colefax:
>
> https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html
>
> Example code is given there. Thanks to Cousin Ricky for for digging up
> the link.

I knew that at some point years ago I stumbled across an explode macro from a
well-known Povrayer, but I had no idea where to find it this days.

Thanks to you and Ricky for the link, I will try it out.

I'm curious to see if the AI has enriched itself with parts of Chris's code.


> Best regards from 200 km to the southeast,
> Michael

Another damn german?
:)

Ma
Co


Post a reply to this message

From: Maetes
Subject: Re: Disintegration Macro
Date: 28 Oct 2026 08:35:00
Message: <web.6ae1eadda54f3a29be3cb90a7bb7ede7@news.povray.org>
> MichaelJF <fri### [at] t-onlinede> wrote:
> > If you are interested in a working explode-macro you may have a look at
> > a very old code by Chris Colefax:
> > https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html

Works, see video.
I Used the teapot-example and simply the lohmueller-plane instead of the teapot.

Nice shit.
Will cost me many hours :)

M


Post a reply to this message


Attachments:
Download 'anim_00.mp4.dat' (453 KB)

From: tTh
Subject: Re: Disintegration Macro
Date: 28 Oct 2026 09:59:26
Message: <6ae1ffbe$1@news.povray.org>
On 10/28/26 13:30, Maetes wrote:
>> MichaelJF <fri### [at] t-onlinede> wrote:
>>> If you are interested in a working explode-macro you may have a look at
>>> a very old code by Chris Colefax:
>>> https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html
> 
> Works, see video.
> I Used the teapot-example and simply the lohmueller-plane instead of the teapot.

    Well done, I have to try it *now* !

-- 
**                                                            **
*                      tTh des Bourtoulots                     *
**                                                            **


Post a reply to this message

From: MichaelJF
Subject: Re: Disintegration Macro
Date: 28 Oct 2026 15:28:08
Message: <6ae24cc8@news.povray.org>
Am 28.10.26 um 13:30 schrieb Maetes:
>> MichaelJF <fri### [at] t-onlinede> wrote:
>>> If you are interested in a working explode-macro you may have a look at
>>> a very old code by Chris Colefax:
>>> https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html
> 
> Works, see video.
> I Used the teapot-example and simply the lohmueller-plane instead of the teapot.
> 
> Nice shit.
> Will cost me many hours :)
> 
> M
Nice work!

At first sight I found no obvious theft by the AI but my resources are a 
little bit limited at the moment to have a closer look into the issue.

And yes, Darmstadt is in that damn old Germany.

Best regards
Michael


Post a reply to this message

From: VAXHeadroom
Subject: Re: Disintegration Macro
Date: 29 Oct 2026 21:25:00
Message: <web.6ae3f179a54f3a29c066fef37c04d41a@news.povray.org>
MichaelJF <fri### [at] t-onlinede> wrote:
> Am 28.10.26 um 13:30 schrieb Maetes:
> >> MichaelJF <fri### [at] t-onlinede> wrote:
> >>> If you are interested in a working explode-macro you may have a look at
> >>> a very old code by Chris Colefax:
> >>> https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html
> >
> > Works, see video.
> > I Used the teapot-example and simply the lohmueller-plane instead of the teapot.
> >
> > Nice shit.
> > Will cost me many hours :)
> >
> > M
> Nice work!
>
> At first sight I found no obvious theft by the AI but my resources are a
> little bit limited at the moment to have a closer look into the issue.
>
> And yes, Darmstadt is in that damn old Germany.
>
> Best regards
> Michael

Sorry all, I should have posted the demo program along with the macro.
Also: I added the 'interior' parameter and then didn't use it, so you'd have to
add that to the demo below..

-- Emory

--

// disintegrate_demo.pov
// Still:      povray +Idisintegrate_demo.pov +W800 +H600 +A
// Animation:  povray +Idisintegrate_demo.pov +W800 +H600 +A +KFI0 +KFF90 +KC
#version 3.7;
global_settings { assumed_gamma 1.0 }
#include "colors.inc"
#include "disintegrate.inc"

background { color rgb <0.03, 0.03, 0.06> }
camera { location <-5, 4, -(20+clock)> look_at <0, 3+clock/10, 0> angle 50 }
light_source { <6, 12, -9> color White }
light_source { <-8, 6, -6> color rgb 0.4 }

plane { y, 0 pigment { checker color rgb 0.15 color rgb 0.2 } }

// The object to destroy: must be a finite, solid shape.
#declare Statue =
  union {
    sphere   { <0, 2.4, 0>, 1.5 }
    cylinder { <0, 0, 0>, <0, 2.4, 0>, 0.9 }
    texture {
      pigment { bozo color_map { [0 rgb <0.9,0.3,0.1>] [1 rgb <0.95,0.8,0.2>] }
scale 0.4 }
      finish  { phong 0.5 }
    }
  }

#declare Inner = texture { pigment { color Red } finish { ambient 0.25 } }

// Timeline (seconds): tear starts at 0.3, front crosses in 2.0, +0.5 jitter,
pieces live 1.5
Disintegrate(
  Statue,
  <0, 20, 0>,       // Dir: pieces fly to the right and slightly up
  0.1,              // Step (cell size)
  clock * 1,       // T
  0,               // Start
  final_clock-3,               // Sweep
  0.5,               // Jitter
  3,               // Life
  0.01,             // min scale threshold (below which the particle will not be
drawn)
  2,               // Speed
  0.2,              // Spread
  5,               // Spin (deg/sec)
  <0, 2, 0>,    // Accel
  7,                 // Seed
  Inner,             // Cut_Tex
  1                  // Shards (1 = real shards, 0 = plain cubes)
)


Post a reply to this message

From: VAXHeadroom
Subject: Re: Disintegration Macro
Date: 29 Oct 2026 23:00:00
Message: <web.6ae4079ca54f3a29781a1e677c04d41a@news.povray.org>
MichaelJF <fri### [at] t-onlinede> wrote:
> Am 28.10.26 um 13:30 schrieb Maetes:
> >> MichaelJF <fri### [at] t-onlinede> wrote:
> >>> If you are interested in a working explode-macro you may have a look at
> >>> a very old code by Chris Colefax:
> >>> https://geocities.restorativland.org/SiliconValley/Lakes/1434/explode.html
> >
> > Works, see video.
> > I Used the teapot-example and simply the lohmueller-plane instead of the teapot.
> >
> > Nice shit.
> > Will cost me many hours :)
> >
> > M
> Nice work!
>
> At first sight I found no obvious theft by the AI but my resources are a
> little bit limited at the moment to have a closer look into the issue.
>
> And yes, Darmstadt is in that damn old Germany.
>
> Best regards
> Michael

I (vaguely) remember this, and also had looked at Rune's particle system, but
that one in particular didn't do what I wanted. The generated file is what I
would have written to do the animation I wanted.  But I'm very short on time and
needed this particular effect to complete a VERY LONG animation I'm working
on...which I've been actually playing with since the late 1990s :)
I was actually a bit surprised it knew POVRay at all, much less that it did such
a clean job out of the gate with a one-sentence prompt.

BTW: the scene I'm using this on is 641 frames and they're currently taking 2+
hours EACH...

-- Emory


Post a reply to this message

From: MichaelJF
Subject: Re: Disintegration Macro
Date: 30 Oct 2026 00:37:10
Message: <6ae41ef6$1@news.povray.org>
Am 30.10.26 um 02:23 schrieb VAXHeadroom:
> 
> Sorry all, I should have posted the demo program along with the macro.
> Also: I added the 'interior' parameter and then didn't use it, so you'd have to
> add that to the demo below..
> 
> -- Emory
> 
I think it's easier to delete the `cut_int` parameter from the macro's 
header. And you might also want to replace `+KC` with `+KF10` in the 
command line, like this:

povray +Idisintegrate_demo.pov +W800 +H600 +A +KFI0 +KFF240 +KF10

Then you can see the effect quite clearly.

Since Chris Cason recently wrote that AI systems have used POV-Ray as a 
benchmark, I’m no longer surprised that they’re familiar with POV. Even 
though that was regarding version 2.2. Gemini, for example, provides 
reasonably useful methods for converting “halo” or “atmosphere” to
“media.”

Best regards
Michael


Post a reply to this message

From: VAXHeadroom
Subject: Re: Disintegration Macro
Date: 2 Nov 2026 09:30:00
Message: <web.6ae89e0aa54f3a299b097f817c04d41a@news.povray.org>
MichaelJF <fri### [at] t-onlinede> wrote:
> Am 30.10.26 um 02:23 schrieb VAXHeadroom:
> >
> > Sorry all, I should have posted the demo program along with the macro.
> > Also: I added the 'interior' parameter and then didn't use it, so you'd have to
> > add that to the demo below..
> >
> > -- Emory
> >
> I think it's easier to delete the `cut_int` parameter from the macro's
> header. And you might also want to replace `+KC` with `+KF10` in the
> command line, like this:
>
> povray +Idisintegrate_demo.pov +W800 +H600 +A +KFI0 +KFF240 +KF10
>
> Then you can see the effect quite clearly.
>
> Since Chris Cason recently wrote that AI systems have used POV-Ray as a
> benchmark, I’m no longer surprised that they’re familiar with POV. Even
> though that was regarding version 2.2. Gemini, for example, provides
> reasonably useful methods for converting “halo” or “atmosphere” to “media.”
>
> Best regards
> Michael

Animation still running at 2+ hours/frame...
This is scene 7 of 8 in the animation (a music video).
-- Emory


Post a reply to this message


Attachments:
Download 'povray_6days.png' (248 KB)

Preview of image 'povray_6days.png'
povray_6days.png


 

From: MichaelJF
Subject: Re: Disintegration Macro
Date: 2 Nov 2026 12:36:14
Message: <6ae8ca0e$1@news.povray.org>
adagio?


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.