|
|
Thomas de Groot <tho### [at] degrootorg> wrote:
> I am presently looking at Bald Eagle's code with the intention to
> implement it inside the granite macro. In that case, all declares will
> become locals obviously and stop giving problems like you encountered.
I personally might try to rename the parameters to make them unique to the
include file. GranInc_K or something like that. 1000 times less likely that
someone will try to use that compared to N, NN or K.
> Another consequence will be that I shall need to define at least three
> additional parameters for the granite macro: Start, End, Turbulence.
>
> @Bald Eagle: in your original code you also defined a parameter "Scale"
> which subsequently was not used. Where did you want to place it? It
> might be an interesting fourth addition.
I defined that in order to scale all of the textures at once when I was
comparing f_noise3D, StepNoise, and cells.
If you see a place where you'd like to scale the function independently of where
things might all be scaled together with the scale keyword, then it would get
placed inside the N parts of the StepNoise function like: N(x/Scale).
> My reworking of the code would look like this:
>
> //---start code---
> #ifndef (SN_Start) #local SN_Start = 0.2; #end
> #ifndef (SN_End) #local SN_End = 0.8; #end
> #ifndef (SN_Turb) #local SN_Turb = 0.325; #end
> #ifndef (SN_Scale) #local SN_Scale = 0.25; #end
>
> // smoothstep function
> #local K = function (t1, t2, T) {max (0, min(1, (T-t1)/(t2-t1) ) )}
> #local Smoothstep = function (t1, t2, T) {pow (K(t1, t2, T), 2) *
> (3-2*K(t1, t2, T))}
>
> // mod function that plays nice when crossing 0
> #local Mod = function (T) {select (T, 1-mod (abs(T), 1), mod (abs(T),
> 1) )}
>
> // smooth step function
> //#local N = function (NN) {floor (NN-0.5) + Smoothstep (SN_Start,
> SN_End, abs(Mod(NN-0.5)-0.5) )}
> #local N = function (NN) {floor (NN) + Smoothstep (SN_Start, SN_End,
> Mod(NN) )}
>
> /* usage
> #declare StepNoise =
> pigment {
> function {f_noise3d (N(x), N(y), N(z))}
> turbulence SN_Turb
> }
> */
> //---end code---
>
>
> --
> Thomas
Maybe rename/preface Mod and SmoothStep.
Also, to remove the dependency on functions.inc, f_noise3D id defined as
function {internal(76)}.
So maybe do: #declare GraniteNoise = function {internal(76)}
But I think that until you release a test version "into the wild", we won't be
able to predict where some tricky problems may be hiding.
Post a reply to this message
|
|