POV-Ray : Newsgroups : povray.pov4.discussion.general : Playing with ideas for additional facets methods. Server Time
25 May 2024 22:09:08 EDT (-0400)
  Playing with ideas for additional facets methods. (Message 1 to 4 of 4)  
From: William F Pokorny
Subject: Playing with ideas for additional facets methods.
Date: 14 Oct 2023 18:26:04
Message: <652b157c@news.povray.org>
In one of the recent threads, Sam mentioned the facets pattern and how 
it replaces normals rather than perturbs them in one of its two modes.

It got me thinking how we might get facets like patterns without the 
need for picking different facet modes depending on the shape's form and 
surface orientation(s).

Attached is an attempt which is perhaps not bad?

It is currently set up by creating regions of constant values a little 
like cells or solid crackle, but at the moment based upon povr's 
f_hash() and a number of other newer inbuilt functions though which of 
those latter might make it into any final code is still somewhat 
undetermined.

After the value regions are set up, the 'accuracy' feature of the 
normal{} block for normal perturbations based upon scalar value patterns 
is used, but with mostly larger than typical settings due the dimensions 
of the value regions. Basically, the pattern works by taking samples 
from different value regions around the base the raw normal vector on 
the surface(*).

(*) The samples would usually come from a scalar value field and not 
discrete values.

Yes, this test code is still normal perturbation and not normal 
replacement, but I think the direction shows promise(a). Image attached 
with a constant, f_hash value regions set up - only changing the 
accuracy settings.

(a) - Thinking the end result will probably be both a scalar value 
pattern and a normal{} block modification method. Maybe calling it 
facets2 or something?

- I've still not played much with the existing facets pattern...

- The larger the accuracy setting the smoother the result, which I 
confess, I don't really understand at the moment. But, there is stuff I 
think not completely right in the way sampling gets done today - and 
there is that magic stuff sitting there in the code too. I need to dig 
into it someday.

Bill P.

Aside: Yep, it might be just using crackle as the value pattern works 
too and twiddling with accuracy works too - I've not tried it. I'm 
trying for something less expensive the crackle(z), but who knows where 
it would all come out cost wise.


(z) - The existing normal{} facets pattern itself uses the crackle 
pattern internally.


Post a reply to this message


Attachments:
Download 'facetplay.jpg' (558 KB)

Preview of image 'facetplay.jpg'
facetplay.jpg


 

From: And
Subject: Re: Playing with ideas for additional facets methods.
Date: 15 Oct 2023 02:00:02
Message: <web.652b7ec448293e7f6f4facb0aa81652d@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> In one of the recent threads, Sam mentioned the facets pattern and how
> it replaces normals rather than perturbs them in one of its two modes.
>
> It got me thinking how we might get facets like patterns without the
> need for picking different facet modes depending on the shape's form and
> surface orientation(s).
>
> Attached is an attempt which is perhaps not bad?
>
> It is currently set up by creating regions of constant values a little
> like cells or solid crackle, but at the moment based upon povr's
> f_hash() and a number of other newer inbuilt functions though which of
> those latter might make it into any final code is still somewhat
> undetermined.
>

What is the concept about f_hash()?


Post a reply to this message

From: William F Pokorny
Subject: Re: Playing with ideas for additional facets methods.
Date: 15 Oct 2023 11:14:18
Message: <652c01ca$1@news.povray.org>
On 10/15/23 01:55, And wrote:
> What is the concept about f_hash()?

Sorry, I forget I'm playing way off in the weeds!

A newsgroup thread on f_hash() can be found here:

http://news.povray.org/povray.pov4.discussion.general/thread/%3C6117bc50%241%40news.povray.org%3E/

It's basically a much more general 'cells' like capability for creating 
regions with discrete, constant values.

------

A problem I have, is that once I get an idea sort of working, I always 
doubt whether it's worthwhile enough to endure the pain of complete 
implementations! :-) What I'm posting on here isn't in a final feature 
form.

The basic idea I'm playing with here, coded as SDL in the povr fork, is 
below. If I do adopt it as full scalar value pattern and/or a normal 
perturbation method, all of it would be hard coded internally in C++ to 
speed it up.

// This f_hash() bit creates a bunch of partitioned value regions
#declare Step = e*0.011;  // e*0.015
#declare Fn00 = function {
     f_hash(
         f_hash(
             f_hash(x,now,Step,0)+
             f_hash(y,now+1,Step,0)+
             f_hash(z,now+2,Step,0),
             now+3,Step,0) +
         f_hash(
             f_hash(f_gradient(x,y,z,1,1,0),now+4,Step*1.414,0)+
             f_hash(f_gradient(x,y,z,1,0,1),now+5,Step*1.414,0)+
             f_hash(f_gradient(x,y,z,0,1,1),now+6,Step*1.414,0),
             now+7,Step,0) +
         f_hash(
             f_hash(f_gradient(x,y,z,+1,+1,+1),now+8,Step*tau,0)+
             f_hash(f_gradient(x,y,z,-1,+1,+1),now+9,Step*pi,0)+
             f_hash(f_gradient(x,y,z,+1,-1,1),now-1,Step*tau,0)+
             f_hash(f_gradient(x,y,z,+1,+1,-1),now-2,Step*pi,0)
             ,now-3,Step,0),
     now-4,0,1)
}

#declare TmpVal = pow(2,52);

// The bit below is doing a dot product of two sets(vectors) of
// 64 bits, where each bit represents -1 or 1. Why? It's a way to
// create values in a -64 to 63 integer range which conform to an
// approximate normal distribution. For something with crystal
// like facets, I don't want many final values for the normal
// perturbation vectors.

// Aside: The approach for this very fast dot product has seen
// renewed use in neural network programming. I suppose this due
// many recent, mainstream, processors adding a built in popcnt
// opcode. (I know very little about neural networks)

#declare Fn01 = function {
     f_64x_ui1_popcnt(
         f_64x_ui1_xor(
             f_64x_ui1_fltto(Fn00(x,y,z)*TmpVal),
             f_64x_ui1_ror(
                 f_64x_ui1_fltto(Fn00(z,-y,x)*TmpVal),32,0),
             1
         )
     )
}
#declare Fn02 = function {
     2.0*Fn01(x,y,z) - 64.0
}

sphere { 0, 0.7
     pigment { rgb 1 }
     normal {
         function { Fn02(x,y,z)/63.0 }
         bump_size 1 accuracy 0.0777
     }
     finish {
         brilliance 7.0 reflection { 0.01, 0.3 fresnel}
     }
     interior { ior 2.5 }
}
#declare RangoonGreen = srgb <0.1098,0.11765,0.07451>;
plane { y, -1.1
     pigment { RangoonGreen }
     normal {
         function { Fn02(x/2,y/2,z/2)/63.0 }
         bump_size 1/3 accuracy 0.1777
     }
     finish {
         brilliance 3.5 reflection { 0.01, 0.1 fresnel}
     }
     interior { ior 1.5 }
}
//---

Attaching a couple more test images images.

Bill P.


Post a reply to this message


Attachments:
Download 'facetplay2.jpg' (182 KB)

Preview of image 'facetplay2.jpg'
facetplay2.jpg


 

From: And
Subject: Re: Playing with ideas for additional facets methods.
Date: 17 Oct 2023 04:10:00
Message: <web.652e413b48293e7f103bf166aa81652d@news.povray.org>
.... Oh, it sounds like a POV-Ray internal C++ function...


Post a reply to this message

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