POV-Ray : Newsgroups : povray.binaries.images : Crackle - are we bored yet? Server Time
28 Apr 2024 17:50:31 EDT (-0400)
  Crackle - are we bored yet? (Message 21 to 27 of 27)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Crackle - are we bored yet?
Date: 3 Dec 2022 10:10:00
Message: <web.638b661d7dc652cc1f9dae3025979125@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:

> LOL !
> 2.2.1.6 User-Defined Functions
> ...Excluded are for example strlen or vlength...

Ugh.   I hate that.
// Length or Norm
#declare Vlength = function (ax, ay, az) {sqrt(ax*ax + ay*ay + az*az)}

Take that, POV-Ray, function parser!

The other thing I have learned from sifting through ShaderToy code is that
vdot (v, v) gives the square of the length of vector v.
so maybe just use that, or try sqrt(vdot(<x, y, z>, <x, y, z>)), if the parser
doesn't choke on that.
My brain has not fully "locked on" to what functions allow and what needs a
silly workaround.

And now that I'm looking for the input syntax specifics (there are none), I see:
(under math.inc) (a workaround file)

vdot(V1,V2)
Dot product of V1 and V2. Returns a float value that is the dot product
(sometimes called scalar product) of V1 with V2. It is directly proportional to
the length of the two vectors and the cosine of the angle between them. Formula
is vdot=V1.x*V2.x + V1.y*V2.y + V1.z*V2.z. See the animated demo scene VECT2.POV
for an illustration.

vlength(V)
Length of V. Returns a float value that is the length of vector V. Formula is
vlength=sqrt(vdot(A,A)). Can be used to compute the distance between two points.
Dist=vlength(V2-V1)



But just try function {x}, or y , or z.
square them
sqrt
abs()
mod (x, 1)

and then once you've discovered the sheer delight of this method, you can add
the wonderful select () into the mix.


Post a reply to this message

From: kurtz le pirate
Subject: Re: Crackle - are we bored yet?
Date: 3 Dec 2022 13:22:47
Message: <638b93f7$1@news.povray.org>
On 03/12/2022 16:07, Bald Eagle wrote:
> kurtz le pirate <kur### [at] gmailcom> wrote:
> 
>> LOL !
>> 2.2.1.6 User-Defined Functions
>> ...Excluded are for example strlen or vlength...
> 
> Ugh.   I hate that.
> // Length or Norm
> #declare Vlength = function (ax, ay, az) {sqrt(ax*ax + ay*ay + az*az)}
> 
> Take that, POV-Ray, function parser!
> 

Don't worry about the Vlength, I had corrected it myself.
But it's funny that your example falls on an unauthorized function.


I'm moving slowly but I think I've seen too much complication all at
once. I made this :

plane {
 y, 0
 pigment {
  function {
   hsl2rgb ( << selected line for the error
    fnHue(x,z),
    Saturation,
    fnLightness(x,z)
    )
   }
  }
 }

and i get this error : Float expected but vector or color expression found.

I made this (very very simplified complex representation) :
#declare fnHue = function(re,im) { mod(degrees(atan2(im,re)),360) }
#declare fnLightness = function(re,im) { sqrt(re*re+im*im) }
#declare Saturation = 1.0;


'hsl2rgb' is a small macro that converts HSL to RGB from
<https://www.rapidtables.com/convert/color/hsl-to-rgb.html>

#macro hsl2rgb (H,S,L)
 #local C=(1-abs(2*L-1))*S;
 #local X=C*(1-abs(mod(H/60,2)-1));
 #local m=L-(C/2);
 #local l = 0.99999999;
 #switch (H)
  #range (0,60*l)
   #local r=<C,X,0>;
  #break
  #range (60,120*l)
   #local r=<X,C,0>;
  #break
  #range (120,180*l)
   #local r=<0,C,X>;
  #break
  #range (180,240*l)
   #local r=<0,X,C>;
  #break
  #range (240,300*l)
   #local r=<X,0,C>;
  #break
  #range (300,360*l)
   #local r=<C,0,X>;
  #break
 #end
 r*m
#end


Why this "Float expected but vector or color expression" ?
I still have a lot to learn ...




-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: Bald Eagle
Subject: Re: Crackle - are we bored yet?
Date: 3 Dec 2022 14:25:00
Message: <web.638ba23a7dc652cc1f9dae3025979125@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:

> and i get this error : Float expected but vector or color expression found.

> Why this "Float expected but vector or color expression" ?
> I still have a lot to learn ...

What you are experiencing is the lack of crossover between the POV-Ray SDL
parser and the function parser.

When you are using x, y, z in SDL, those refer to the basis vectors of the
cardinal axes.

When those variables are evaluated in a function, they refer to the scalar
components of the pixel coordinates being evaluated.

So the function is expecting x to be a scalar value, but you are feeding it <1,
0, 0>.


Post a reply to this message

From: Bald Eagle
Subject: Re: Crackle - are we bored yet?
Date: 3 Dec 2022 14:35:00
Message: <web.638ba4527dc652cc1f9dae3025979125@news.povray.org>
I made the type of function you're looking for, but I can't find the link to it,
assuming I posted it.

But Trevor Quayle wrote one also:

http://news.povray.org/povray.general/message/%3Cweb.4784496ba8d0eaa2ae8612c0%40news.povray.org%3E/#%3Cweb.4784496ba8d0
eaa2ae8612c0%40news.povray.org%3E

See how it's written differently than a macro.

Once you define a function, that's it.  You're done.
When POV-Ray evaluates things during render time, anything in the code has
already executed and finished.  That's why you can't stick macros into functions
for render time, use macros during render time, or change what a function
evaluates to  (the underlying equation) during render time.

Functions are equations.   Macros are algorithms.  It helps to think about it
that way to understand the difference and stay out of trouble.


Post a reply to this message

From: Bald Eagle
Subject: Re: Crackle - are we bored yet?
Date: 10 Dec 2022 12:10:00
Message: <web.6394bcbb7dc652cc1f9dae3025979125@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:

> Would it be possible to vary the /size/ of the individual cells? in a
> random way?

I managed to get a tilable pattern with _more_ randomness, not sure this is
exactly what you or I was imagining.

Got some weird artifacts / cutoff / transitions when I tried to push the
envelope, so I may have to start a little fresher to get this thing to work
right.


Post a reply to this message


Attachments:
Download 'nongridtileablevoronoi.png' (171 KB)

Preview of image 'nongridtileablevoronoi.png'
nongridtileablevoronoi.png


 

From: Bald Eagle
Subject: Re: Crackle - are we bored yet?
Date: 10 Dec 2022 12:15:00
Message: <web.6394be0a7dc652cc1f9dae3025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> 4.  What you're currently looking at is a full, user-defined cell vertice
> Voronoi pattern, that is infinitely tileable, and able to be colored on a
> per-cell basis by a user-defined array.

Well.  Almost.

I have to figure out why the cells are getting colored differently across the
hard transition of the unit square.  The pattern is tiling, but the color -
isn't.

I haven't had a few clear, focused hours to pick at all the parts and invent
debugging tools to see what's happening and why.  But it's very very close.

And still very very slow.   :(


Post a reply to this message


Attachments:
Download 'tileablevoronoitest.png' (146 KB)

Preview of image 'tileablevoronoitest.png'
tileablevoronoitest.png


 

From: Paolo Gibellini
Subject: Re: Crackle - are we bored yet?
Date: 11 Dec 2022 13:25:29
Message: <63962099$1@news.povray.org>
Il 26/11/2022 00:20, Bill Pragnell ha scritto:

This is lovely!

Paolo


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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