#!/usr/pkg/bin/bash
# XScreenSaver, Copyright © 2026 Jamie Zawinski <jwz@jwz.org>
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation.  No representations are made about the suitability of this
# software for any purpose.  It is provided "as is" without express or 
# implied warranty.

PATH="$PATH":"$(dirname "$0")"
exec -a "noxfire" \
xshadertoy "$@" \
 --program0 - \
<< "_XSCREENSAVER_EOF_"

// Title:  Nox Fire
// Author: Matt Vianueva <diatribes@gmail.com>
// URL:    https://www.shadertoy.com/view/wfG3Dz
// Date:   24-May-2025
// Desc:   Nox Fire

// Relicensed as MIT License, by permission, 8-Mar-2026.

/*

    -4 from FabriceNeyret2
    
    Thanks :D !

*/

	void mainImage(out vec4 o, vec2 u) {
	o = vec4(0,0,0,0);
	float i=0., d=0., s=0., n=0., t=iTime;
	vec3 p = iResolution;
	u = (u-p.xy/2.)/p.y;
	for(o*=i; i++<1e2; ) {
	p = vec3(u * d, d + t*4.);
	p += cos(p.z+t+p.yzx*.5)*.6;
	s = 4.+sin(t*.7)*4.-length(p.xy);
	p.xy *= mat2(cos(t+vec4(0,33,11,0)));
	for (n = 1.6; n < 32.; n += n )
	s -= abs(dot(sin( p.z + t + p*n ), vec3(1.12))) / n;
	d += s = .01 + abs(s)*.1;
	o += 1. / s;
	}
	o = tanh(vec4(5,2,1,1) * o * o / d / 2e6);
	}

_XSCREENSAVER_EOF_
