 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Does anyone know how I can apply a normal map (like this
https://imgur.com/a/GbE7K8K) to an object and have it actually behave like a
normal map (i.e. adjust the normal of the surface by it's RGB value).
Bump map doesn't do the right thing, I feel like it might be to do with
slope_map but I can't get it to take an image.
I can't believe it wouldn't be possible.
Any help would be much appreciated.
Thanks,
cloudyroo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"cloudyroo" <nomail@nomail> wrote:
> Does anyone know how I can apply a normal map (like this
> https://imgur.com/a/GbE7K8K) to an object and have it actually behave like a
> normal map (i.e. adjust the normal of the surface by it's RGB value).
> Bump map doesn't do the right thing, I feel like it might be to do with
> slope_map but I can't get it to take an image.
> I can't believe it wouldn't be possible.
> Any help would be much appreciated.
> Thanks,
> cloudyroo
Real quick (untested)
based on
http://www.povray.org/documentation/view/3.7.0/337/
and
http://www.povray.org/documentation/view/3.6.1/378/
#declare FOO = function {
pigment
{
image_map
{
[BITMAP_TYPE] "bitmap[.ext]"
[IMAGE_MAP_MODS...]
}
[PIGMENT_MODFIERS...]
}
}
and then do:
normal { // <----switched to normal instead of pigment here
function { FOO(x,y,z).green }
[PIGMENT_MODIFIERS...]
}
There may be a quicker / neater way to do it with a function pattern or pattern
function ..... but I'd use those as keywords to search the docs and the forum
posts.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17-1-2019 12:30, Bald Eagle wrote:
> Real quick (untested)
Brilliant! Why did I never think of that? :-)
> There may be a quicker / neater way to do it with a function pattern or pattern
> function ..... but I'd use those as keywords to search the docs and the forum
> posts.
>
I suppose so. Going to follow that hint...
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17-1-2019 12:30, Bald Eagle wrote:
> There may be a quicker / neater way to do it with a function pattern or pattern
> function ..... but I'd use those as keywords to search the docs and the forum
> posts.
>
>
Following up on the initial query by cloudyroo, I tried to get this to
work as a function pattern in a normal block but without success... :-/
I must admit that something escapes me and/or I misunderstand the
docs... Neither found any info in the forum posts... I seem not to have
my day ;-)
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 19.01.2019 um 13:25 schrieb Thomas de Groot:
> On 17-1-2019 12:30, Bald Eagle wrote:
>> There may be a quicker / neater way to do it with a function pattern
>> or pattern
>> function ..... but I'd use those as keywords to search the docs and
>> the forum
>> posts.
>>
>>
> Following up on the initial query by cloudyroo, I tried to get this to
> work as a function pattern in a normal block but without success... :-/
>
> I must admit that something escapes me and/or I misunderstand the
> docs... Neither found any info in the forum posts... I seem not to have
> my day ;-)
This is not a bump map (in which brightness is interpreted as height,
and the normal is defined by the gradient in the image) but a normal map
(in which the three colour channels are interpreted directly as the
coordinates ot the normal vectors).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thomas de Groot <tho### [at] degroot org> wrote:
> >
> Following up on the initial query by cloudyroo, I tried to get this to
> work as a function pattern in a normal block but without success... :-/
>
> I must admit that something escapes me and/or I misunderstand the
> docs... Neither found any info in the forum posts... I seem not to have
> my day ;-)
>
Try this set-up (using the image_map that the OP linked to in his original
post):
#declare NORM_FUNCTION =
function{
pigment{image_map{png "D9AsKLH.png" interpolate 2} scale 2}
};
box{0,1.5
texture{
pigment{rgb .5}
finish{ambient .1 diffuse .7 phong .7 phong_size 5}
normal{
function{NORM_FUNCTION(x,y,z).blue} // also try (y,y,x)
normal_map{
[0.5 bumps scale .15 bump_size 5]
[0.5 granite scale .2 bump_size 5]
}
}
}
}
Some of these values are exaggerated, for effect. I do see the normal pattern on
the box, but only on the front face; a function made from an image_map is only
meaningful in x and y, not z, since the image_map is not '3-dimensional' like
POV-Ray's built-in patterns are.
Since the use of the function requires a color component to be chosen, I used
.blue
because the blue color in this particular image_map is the dominant one, with
the most gradations. Using .red, .green, or .gray shows practically no effect.
I don't presently know how to use the *complete* range of colors in the image,
as a way to pick out the normal patterns in the normal_map-- like, red for
bumps, green for granite, and blue for a third normal pattern. It would *seem*
to be possible, though, with some SDL/function tricks(?)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
>
> ...a function made from an image_map is only
> meaningful in x and y, not z, since the image_map is not '3-dimensional'
> like POV-Ray's built-in patterns are.
>
Sorry, that's not quite true: The image_map function has 'infinite' depth in z
(just like an image_map when used as a PIGMENT.) Change the object to a sphere
to see what I mean.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> Since the use of the function requires a color component to be chosen, I used
> .blue
> because the blue color in this particular image_map is the dominant one, with
> the most gradations. Using .red, .green, or .gray shows practically no effect.
>
> I don't presently know how to use the *complete* range of colors in the image,
> as a way to pick out the normal patterns in the normal_map-- like, red for
> bumps, green for granite, and blue for a third normal pattern. It would *seem*
> to be possible, though, with some SDL/function tricks(?)
I started coding a function this morning, and just got back to it now.
Glad to see ole' Kenneth Walker is keeping his Northern namesake on his toes
with the speedy competition. ;)
Try some of this out, and see what you think:
#declare Type = 1;
#switch (Type)
#case (0)
box {<0, 0, 0>, <1, 1, 0.1>
texture {pigment {Blue*0.5} finish {specular 0.4}}
normal {bump_map {png "PovLogo.png" once} bump_size 2}
}
#break
#case (1)
#declare BumpMap = function {pigment {image_map {png "PovLogo.png"} }};
box {<0, 0, 0>, <1, 1, 0.1>
texture {pigment {Blue*0.5} finish {specular 0.4}}
//normal {function { BumpMap (x, y, z).gray}}
normal {
function {
BumpMap (x, y, z).red +
BumpMap (x, y, z).green +
BumpMap (x, y, z).blue}
}
}
#break
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 19-1-2019 20:40, Bald Eagle wrote:
> "Kenneth" <kdw### [at] gmail com> wrote:
>
>> Since the use of the function requires a color component to be chosen, I used
>> .blue
>> because the blue color in this particular image_map is the dominant one, with
>> the most gradations. Using .red, .green, or .gray shows practically no effect.
>>
>> I don't presently know how to use the *complete* range of colors in the image,
>> as a way to pick out the normal patterns in the normal_map-- like, red for
>> bumps, green for granite, and blue for a third normal pattern. It would *seem*
>> to be possible, though, with some SDL/function tricks(?)
>
>
> I started coding a function this morning, and just got back to it now.
> Glad to see ole' Kenneth Walker is keeping his Northern namesake on his toes
> with the speedy competition. ;)
>
> Try some of this out, and see what you think:
>
>
> #declare Type = 1;
> #switch (Type)
>
> #case (0)
> box {<0, 0, 0>, <1, 1, 0.1>
> texture {pigment {Blue*0.5} finish {specular 0.4}}
> normal {bump_map {png "PovLogo.png" once} bump_size 2}
>
> }
> #break
>
> #case (1)
>
> #declare BumpMap = function {pigment {image_map {png "PovLogo.png"} }};
>
>
> box {<0, 0, 0>, <1, 1, 0.1>
> texture {pigment {Blue*0.5} finish {specular 0.4}}
> //normal {function { BumpMap (x, y, z).gray}}
> normal {
> function {
> BumpMap (x, y, z).red +
> BumpMap (x, y, z).green +
> BumpMap (x, y, z).blue}
> }
> }
>
> #break
> #end
>
>
Sorry, I am afraid I made myself not too clear or, more probably, I
mis-read Bald Eagle's initial answer (the last paragraph). I certainly
got a fine working normal, but got lost with that 'function pattern'
hint at the end and went looking for function_patterns... :-)
What I did, and what worked fine was this:
#local NormalMap =
function {
pigment {
image_map {
jpeg "MyImage.jpg" gamma 1
}
}
}
sphere {
0, 1
pigment {rgb 1}
normal {
function {NormalMap(x,y,z).grey} 1.5
scale 0.5
}
finish {
diffuse 1
}
}
Note that I replaced the '.red' by '.grey' which gives a better render.
What also works fine here is '.hf' by the way. And so it seems, we were
all (Kenneth, Bald Eagle, Clipka, me) on the same wavelength.
However, Bald Eagle's
function {
NormalMap(x,y,z).red +
NormalMap(x,y,z).green +
NormalMap(x,y,z).blue
} 1.5
gives a much better result and thus may be preferred.
Kenneth's suggestion to use the three colours for three different
normals may be worth investigating further...
Now, that was a nice little experimental session. Keeps me on my toes.
Thanks all!
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
in news:5c442a26$1@news.povray.org Thomas de Groot wrote:
> However, Bald Eagle's
>
> function {
> NormalMap(x,y,z).red +
> NormalMap(x,y,z).green +
> NormalMap(x,y,z).blue
> } 1.5
>
> gives a much better result and thus may be preferred.
>
.gray and .hf = 0.3 * red + 0.59 * green + 0.11 * blue, so yes there's
quite a difference to be expected.
ingo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 20-1-2019 9:33, ingo wrote:
> in news:5c442a26$1@news.povray.org Thomas de Groot wrote:
>
>> However, Bald Eagle's
>>
>> function {
>> NormalMap(x,y,z).red +
>> NormalMap(x,y,z).green +
>> NormalMap(x,y,z).blue
>> } 1.5
>>
>> gives a much better result and thus may be preferred.
>>
>
> .gray and .hf = 0.3 * red + 0.59 * green + 0.11 * blue, so yes there's
> quite a difference to be expected.
>
> ingo
>
Ah! I didn't know that!
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 20.01.2019 um 13:07 schrieb Thomas de Groot:
> On 20-1-2019 9:33, ingo wrote:
>> in news:5c442a26$1@news.povray.org Thomas de Groot wrote:
>>
>>> However, Bald Eagle's
>>>
>>> function {
>>> NormalMap(x,y,z).red +
>>> NormalMap(x,y,z).green +
>>> NormalMap(x,y,z).blue
>>> } 1.5
>>>
>>> gives a much better result and thus may be preferred.
>>>
>>
>> .gray and .hf = 0.3 * red + 0.59 * green + 0.11 * blue, so yes there's
>> quite a difference to be expected.
To be precise, it is 0.297, 0.589 and 0.114, respectively.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thomas de Groot <tho### [at] degroot org> wrote:
> On 20-1-2019 9:33, ingo wrote:
> > .gray and .hf = 0.3 * red + 0.59 * green + 0.11 * blue, so yes there's
> > quite a difference to be expected.
> >
> > ingo
> >
>
> Ah! I didn't know that!
>
> --
> Thomas
I remember that from the LOOOOOOONG thread back at:
http://news.povray.org/povray.advanced-users/thread/%3Cweb.577e597b5ff2a8e65e7df57c0%40news.povray.org%3E/?mtop=409379
(See post by Mssr Grimbert at bottom of pg 1)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 20-1-2019 17:36, Bald Eagle wrote:
> Thomas de Groot <tho### [at] degroot org> wrote:
>> On 20-1-2019 9:33, ingo wrote:
>
>
>>> .gray and .hf = 0.3 * red + 0.59 * green + 0.11 * blue, so yes there's
>>> quite a difference to be expected.
>>>
>>> ingo
>>>
>>
>> Ah! I didn't know that!
>>
>> --
>> Thomas
>
> I remember that from the LOOOOOOONG thread back at:
>
>
http://news.povray.org/povray.advanced-users/thread/%3Cweb.577e597b5ff2a8e65e7df57c0%40news.povray.org%3E/?mtop=409379
>
> (See post by Mssr Grimbert at bottom of pg 1)
>
>
Ah, yes. Like with the oren-nayar feature, I had that little bell
ringing feebly at the back of my mind, but was unable to localise it,
deeming it an early start of senility... :-)
note: I am not going to re-read that loooooooong thread...
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
in news:5c457919$1@news.povray.org Thomas de Groot wrote:
> note: I am not going to re-read that loooooooong thread...
>
>
It's in the docs, but not where you expect it.
http://wiki.povray.org/content/Reference:File_Output_Options
Should appear in a few more places imo, like:
http://wiki.povray.org/content/Reference:Color_Expressions#Dot_Item_Access
_for_Colors
And it appears that .hf = (Red + Green/255)*0.996093 not the same as .gray
as I thought.
http://wiki.povray.org/content/Documentation:Tutorial_Section_3.2
#Noise_and_pigment_functions
The only appearence of .hf I could find,
ingo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 21-1-2019 11:05, ingo wrote:
> in news:5c457919$1@news.povray.org Thomas de Groot wrote:
>
>> note: I am not going to re-read that loooooooong thread...
>>
>>
>
> It's in the docs, but not where you expect it.
> http://wiki.povray.org/content/Reference:File_Output_Options
>
Indeed; I did not look there at all.
> Should appear in a few more places imo, like:
> http://wiki.povray.org/content/Reference:Color_Expressions#Dot_Item_Access
> _for_Colors
>
Probably, in explaining how .grey/.gray is calculated. That seems to be
missing.
> And it appears that .hf = (Red + Green/255)*0.996093 not the same as .gray
> as I thought.
>
> http://wiki.povray.org/content/Documentation:Tutorial_Section_3.2
> #Noise_and_pigment_functions
> The only appearence of .hf I could find,
>
Where also the value of .grey/.gray is given.
.hf is typically used in height_field functions like, e.g.:
height_field {function HF_res, HF_res {F_HF_01(x,y,z).hf}}
Contrary to what is said in the docs, .hf does not generate a warning
(any more).
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
>
> Glad to see ole' Kenneth Walker is keeping his Northern namesake on his toes
> with the speedy competition. ;)
Hey, cousin! :-P
>
> Try some of this out, and see what you think:
>
[snip]
>
> box {<0, 0, 0>, <1, 1, 0.1>
> texture {pigment {Blue*0.5} finish {specular 0.4}}
> //normal {function { BumpMap (x, y, z).gray}}
> normal {
> function {
> BumpMap (x, y, z).red +
> BumpMap (x, y, z).green +
> BumpMap (x, y, z).blue}
> }
> }
I've been working with your code for the last day-- it's a great way to split up
the color channels of the image function for use. Nice! I haven't yet figured
out how to use the individual channels to apply three separate normal patterns
though (in a normal_map)--- because I got sidetracked: There's something really
strange going on here (or at least unexpected)-- not with your code, but with
the basic act of transforming an image_map (OR one of POV-Ray's built-in
patterns) into a function.
I've included a test scene below, to show the interesting normals behavior; I
didn't use an image_map for the normal, but rather a bozo pattern (although the
same strange effect happens with a continuous-tone color photo and bump_map,
from testing.) Bozo by default uses the three primary colors, which I wanted.
The red arrows show the direction of the single light source, with the light
just raking the box surfaces.
When rendering the code, the box on the left shows a 'typical' applied normals
pattern (no function or bump_map.) The center box takes the bozo pattern and
turns it into a function (using .gray). The right-most box is the function
again, but uses your 'split color channels' idea (with just a single color
channel in use.)
Some observations:
There's a fundamental difference in appearance between box 1 and boxes 2 and 3.
The normals produced from the function are... layered(?), or *something*. It's
as if there are no 'blends' between the three color channels' normals-- unlike
the smooth blend in the left box. I don't know if this is expected behavior or
not.
But the strangest thing is that the *function's* normals react to the light
only in 90-degree quadrants. In other words, with the light at 45-degrees up and
to the right, the normals are a BLEND of two strict 90-degree effects
superimposed, one horizontal, the other vertical, with no 'blend' inbetween.
(This is more easily seen in an animation, with the light tracing an arc from
horizon to horizon.)
BTW, I discovered something interesting about your three added color channels
BumpMap (x, y, z).red +
BumpMap (x, y, z).green +
BumpMap (x, y, z).blue}
By using the color-to-grayscale formula posted earlier-- the three RGB values,
as multipliers-- your construction can be turned back into the simpler .gray
appearance of the 'combined' color channels:
BumpMap (x, y, z).red*0.297 +
BumpMap (x, y, z).green*0.589 +
BumpMap (x, y, z).blue}*0.114
Fun, eh?
Anyway, I'm still thinking about the function strangeness, so here's the code
test...
------------------------
// render as 16/9 ratio
#version 3.7; // or 3.71 or 3.8
global_settings{assumed_gamma 1.0}
#default{finish{ambient 0.1 emission 0 diffuse 0.7 specular 0.4}}
camera {
perspective
location <0, .8, -20>
look_at <0, .5, 0>
right x*image_width/image_height
angle 10
}
#declare LIGHT_POS = <100, 0, -15>;
#declare LIGHT_TRANSFORM = transform{rotate 45*z} // or for animation,
// rotate 180*clock*z, 200 frames
// a SINGLE light
light_source {
0*x
color rgb <1,1,1>
translate LIGHT_POS
transform{LIGHT_TRANSFORM}
}
#declare ARROW =
merge{
cylinder{.001*LIGHT_POS,0.0055*LIGHT_POS,0.006}
cone{0.0012*LIGHT_POS,0.025,<0,0,0>,0.0001}
pigment{rgbt <10,0,0,0.85>}
no_shadow
}
//----------------
// box 1
// USING A BUILT-IN PATTERN AND NO BUMP_MAP.
box {<0, 0, 0>, <1, 1, 0.1>
pigment {rgb 0.5}
normal {bozo bump_size 20 scale 0.15}
translate -1.6*x
}
object{ARROW
transform{LIGHT_TRANSFORM}
translate <-1.1,0.5,-0.1>
}
//----------------
// box 2
#declare NORM_FUNCTION = function{pigment{bozo scale .15}}
box {<0, 0, 0>, <1, 1, 0.1>
pigment {rgb .5}
normal {function {NORM_FUNCTION (x,y,z).gray} bump_size 1.0}
translate -.5*x
}
object{ARROW
transform{LIGHT_TRANSFORM}
translate <1.1,.5,-.1>
}
//----------------
// box 3 -- (using the same BumpMap function as box 2)
box {<0, 0, 0>, <1, 1, 0.1>
pigment {rgb .5}
normal {
function {
// Use the respective multipliers for these three, instead of
// 'full' intensity:
/*
NORM_FUNCTION (x, y, z).red*0.297 +
NORM_FUNCTION (x, y, z).green*0.589 +
NORM_FUNCTION (x, y, z).blue*0.114
*/
// OR... used *separately* and at full intensity...
NORM_FUNCTION (x, y, z).red
// +
// NORM_FUNCTION (x, y, z).green
// +
// NORM_FUNCTION (x, y, z).blue
}
}
translate .6*x
}
object{ARROW
transform{LIGHT_TRANSFORM}
translate <0,.5,-.1>
}
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> Some observations:
> There's a fundamental difference in appearance between box 1 and boxes 2 and 3.
> The normals produced from the function are... layered(?), or *something*. It's
> as if there are no 'blends' between the three color channels' normals-- unlike
> the smooth blend in the left box. I don't know if this is expected behavior or
> not.
Well, this is usually the point where either clipka jumps in with an inside-out
explanation, since he has the big picture of the source code in his head and can
translate, summarize, and put it in proper order and context.
Or I go digging in the source and try to puzzle out the bits.
But my first instinct is that since there a different ways to create a normal
from an image, they are all implemented under the hood differently.
Sort of like the way you can have 2 different heighfields - one "sharp" and
abrupt - and the other smoothed.
I also don't know what would happen if the box were > 1x1, if there were some
sort of interpolation. Or conversely if the image were scaled smaller and
applied to a 1x1 box.
If you want smoothing, then perhaps the simplest first experiment to try is:
"But how about if we want a smooth blend of patterns all the way through? That
is where a new feature called average can come in very handy. Average works with
pigment, normal, and texture maps, although the syntax is a little bit
different, and when we are not expecting it, the change can be confusing. Here
is a simple example. We use our standard includes, camera and light source from
above, and enter the following object.
plane { -z, 0
pigment { White }
normal {
average
normal_map {
[1, gradient x ]
[1, gradient y ]
}
}
}
"
You may have to write a function to use for the weights of the different
channels, but it's something to play with.
What I was thinking about initially was:
NORMAL:
normal {
IMAGE_PATTERN [Bump_Size]
normal_map { NORMAL_MAP_BODY }
}
{And here, 3.4.7.4.2 employs "irregardless". :| For shame. }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 21.01.2019 um 13:05 schrieb Kenneth:
> There's a fundamental difference in appearance between box 1 and boxes 2 and 3.
> The normals produced from the function are... layered(?), or *something*. It's
> as if there are no 'blends' between the three color channels' normals-- unlike
> the smooth blend in the left box. I don't know if this is expected behavior or
> not.
The "plateau" effect is indeed to be expected: When using a pattern in a
`normal` statement, the "raw" pattern is interpreted as a height value.
When instead using a pattern in a pigment (as you do in NORM_FUNCTION),
the pattern value is first translated into a colour value according to a
colour map, and then the three channels of the colour value are
translated (as per your function definition) into a scalar again, and
then /that/ value is used as the height value.
Now if the pigment has no colour map associated, then "raw" pattern
value is interpreted as a greyscale value, and the subsequent
translation from colour to scalar simply un-does the operation. But some
patterns - and `bozo` is one of them - have default colour maps associated.
In the case of `bozo` this colour map has some ranges of "raw" pattern
values where the colour (and thus the height value computed from it)
remains constant, which correspond to the "plateaus".
> But the strangest thing is that the *function's* normals react to the light
> only in 90-degree quadrants. In other words, with the light at 45-degrees up and
> to the right, the normals are a BLEND of two strict 90-degree effects
> superimposed, one horizontal, the other vertical, with no 'blend' inbetween.
> (This is more easily seen in an animation, with the light tracing an arc from
> horizon to horizon.)
This, too, can be explained:
When plugging in a pattern into a normal, the normal is computed by
first sampling the pattern at four points in 3D space, from that
computing the gradient of the pattern in 3D space, and from that
computing how to perturb the normal. The four samples are always taken
at fixed offsets relative to the intersection points, distributed in a
tetrahedral arrangement.
If you have a pattern with plateaus, and the distance between those
plateaus (the slope regions) are narrow compared to the dimensions of
the sampling tetrahedron, the four sampling points will frequently all
end up on one of the plateaus, and you'll end up with a very limited set
of possible computed gradient directions (and hence resulting normal
orientations).
With a pattern that has at least /some/ slope regions, you can work
around this by increasing the scaling factor in the pigment inside the
function by some factor Q, and compensating by scaling the normal by the
inverse of that factor, 1/Q.
With `bozo` you're out of luck though: Its default colour map consists
exclusively of plateaus, and the slopes are infinitely narrow. So as you
increase the precision of the normal computations, the slopes will
eventually vanish entirely, and you'll end up with a seemingly flat
surface (because perturbed normals don't cast shadows). So the only way
around this is to override the pattern's default colour map.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 21.01.2019 um 15:08 schrieb Bald Eagle:
> Well, this is usually the point where either clipka jumps in with an inside-out
> explanation, since he has the big picture of the source code in his head and can
> translate, summarize, and put it in proper order and context.
=:-D
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
clipka <ano### [at] anonymous org> wrote:
> Am 21.01.2019 um 13:05 schrieb Kenneth:
>
> In the case of `bozo` this colour map has some ranges of "raw" pattern
> values where the colour (and thus the height value computed from it)
> remains constant, which correspond to the "plateaus".
>
> ...Its default colour map consists
> exclusively of plateaus, and the slopes are infinitely narrow. So as you
> increase the precision of the normal computations, the slopes will
> eventually vanish entirely, and you'll end up with a seemingly flat
> surface (because perturbed normals don't cast shadows)...
Yeah, I had an intuition that bozo's flat RGB colors and sharp color borders
were at least one of the reasons for the 'plateaus' (plateux?), but I didn't
know how to put my fuzzy thoughts into words. You're much better at explanations
than I am ;-)
I'm still digesting your info, it's admittedly above my head at the moment (on a
higher plateau!)
My initial tests were actually with a continuous-tone color photo (as the
normals pattern), along with a bump_map-- then as a function normal instead, to
compare the two (which also showed the plateau difference.) THEN I chose bozo as
an 'in-built substitute' for using the color photo, to show the absolute
worst-case scenario. I wanted a *color* pattern rather than something grayscale
like bumps; but alas, POV's color patterns all have sharp color borders (bozo,
hexagon, etc.). I guess I could have made my own more 'continuous' color
pattern, but that didn't occur to me yesterday(!)
Anyway, I'm still a bit perplexed about the normals difference between the
following two constructs (using a continuous-tone color photo of your choice):
1)
box {<0, 0, 0>, <1, 1, 0.1>
pigment {rgb .5}
normal {bump_map {jpeg "my color photo.jpg" interpolate 2} bump_size 10} }
....
and 2)
#declare NORM_FUNCTION =
function {pigment {image_map {jpeg "my color photo.jpg" interpolate 2} }}
box {<0, 0, 0>, <1, 1, 0.1>
pigment {rgb .5}
normal {function { NORM_FUNCTION (x, y, z).gray} bump_size 1.0}
....
The normals on box 1) look nice-- the 'expected' embossed appearance. Box 2)
shows the plateau effect (and the 90-deg 'quadrant' behavior)-- although it will
probably be more difficult to see when using a typical 'busy' photo. This is
what originally made me think that the image-to-FUNCTION process was the sole
cause.
But now I'm wondering if box 1's normals *also* have the plateaus and 90-deg
quadrants, just on a much smaller scale that can't readily be seen?
Your detailed explanation probably describes the reason(s) for the difference,
but I'm not yet grasping it...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I just got done fiddling with an idea.
First, I'm curious how an internal/predefined function like f_noise3d still need
functions.inc .
Second - here's a noise-based normal function,
S is scale of the pattern
D is a small delta shift for the 3x3 sampling grid
0.01 seems to be where things shift from one weird version to another.
large values give some interesting repeating "ghosts" almost like a repeat warp,
and small values give closer to the native function (D=0) which has very well
defined "rings" which are much softer at D=0.1
Just thought I'd throw this in here to play with and perhaps clipka can explain
what the "rings" are.
#declare BumpMap = function {f_noise3d (x, y, z)};
#declare S=5;
#declare D = 0.01;
#declare CenterWeight = 8/9;
#declare EdgeWeight = 1/9;
box {<0, 0, 0>, <1, 1, 0.1>
texture {pigment {Blue*0.5} finish {specular 0.4}}
//normal {function { BumpMap (x, y, z).gray}}
normal {
average
normal_map {
#for (Y, -D, D, D)
#for (X, -D, D, D)
[select (Y*X, EdgeWeight, CenterWeight, EdgeWeight) function { BumpMap
((x-X)*S, (y-Y)*S, z)*3}]
#end
#end // end for Y
}
}
}
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 22.01.2019 um 00:13 schrieb Kenneth:
> Anyway, I'm still a bit perplexed about the normals difference between the
> following two constructs (using a continuous-tone color photo of your choice):
>
> 1)
> box {<0, 0, 0>, <1, 1, 0.1>
> pigment {rgb .5}
> normal {bump_map {jpeg "my color photo.jpg" interpolate 2} bump_size 10} }
> .....
>
> and 2)
> #declare NORM_FUNCTION =
> function {pigment {image_map {jpeg "my color photo.jpg" interpolate 2} }}
>
> box {<0, 0, 0>, <1, 1, 0.1>
> pigment {rgb .5}
> normal {function { NORM_FUNCTION (x, y, z).gray} bump_size 1.0}
> .....
In this case, the difference is due to another reason, namely that
`bump_map` has a special implementation: Rather than sampling somewhat
arbitrary points in the pattern, it adapts to the resolution of the
image, and also samples in the image plane. It can't do the same trick
in the function-based variant because it can't even tell that the
function is based on an image.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 22.01.2019 um 02:33 schrieb Bald Eagle:
> I just got done fiddling with an idea.
> First, I'm curious how an internal/predefined function like f_noise3d still need
> functions.inc.
POV-Ray knows a couple of inbuilt functions.
It doesn't know them by any name though, just by internal numbers.
There's a special syntax to assign names to those internal numbers,
which is exactly what `functions.inc` is doing.
> Second - here's a noise-based normal function,
> S is scale of the pattern
> D is a small delta shift for the 3x3 sampling grid
>
> 0.01 seems to be where things shift from one weird version to another.
> large values give some interesting repeating "ghosts" almost like a repeat warp,
> and small values give closer to the native function (D=0) which has very well
> defined "rings" which are much softer at D=0.1
My guess is that it's some interference between your oversampling of the
normal and the normal's internal sampling.
BTW, while working on the parser source code I just noticed that there's
a parameter to control the "resolution" of the internal sampling, called
`accuracy`. It defaults to 0.02, which explains why it's at this order
of magnitude that strange things kick in.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
ingo <ing### [at] tag povray org> wrote:
>
> ...it appears that .hf = (Red + Green/255)*0.996093 not the same as .gray
> as I thought.
>
> http://wiki.povray.org/content/Documentation:Tutorial_Section_3.2
> #Noise_and_pigment_functions
> The only appearence of .hf I could find,
Thomas wrote:
> .hf is typically used in height_field functions like, e.g.:
> height_field {function HF_res, HF_res {F_HF_01(x,y,z).hf}}
I knew I had seen .hf *somewhere* but didn't know where to look. Thanks, Ingo.
But it comes as a fascinating surprise (to me) that .gray and .hf use different
color-to-grayscale formulas...
.gray to get the gray value of the color vector:
gray value = Red*29.7% + Green*58.9% + Blue*11.4%
.hf to get the height_field value of the color vector:
hf value = (Red + Green/255)*0.996093
I don't think I've ever actually used .hf (in either a height_field OR a
function)-- but I'm mostly curious as to why they are different. And/or the
historical significance of the .hf formula. AFAIU, the .gray formula is the de
facto standard in POV-Ray for internal color conversions; but is there something
'special' about height_field/FUNCTION use that requires a different formula?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> BTW, while working on the parser source code I just noticed that there's
> a parameter to control the "resolution" of the internal sampling, called
> `accuracy`. It defaults to 0.02, which explains why it's at this order
> of magnitude that strange things kick in.
Nice. I love it when all of these posts and experiments and collaborations and
under-the-hood investigations have their periodic coincidences. :)
So many little thing to be learned even after all this time.
Can you comment on the sharp rings / elevation lines in the noise pattern?
(I can post a render in p.b.i. if needed)
It was unexpected, and I couldn't get rid of them by changing the [over]sampling
delta. There's a soft, fluffy, smooth noise as the background - softer than
expected, actually, but then the rings were "WTH are _those_?"
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
in news:web.5c46ee32e20dd126cd98345b0@news.povray.org Kenneth wrote:
> And/or the
> historical significance of the .hf formula
In the days of old, the red+green chanel of 8 bit images where (ab)used to
store 16 bit grayscale values for use in hight_field,
ingo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 22-1-2019 12:26, ingo wrote:
> in news:web.5c46ee32e20dd126cd98345b0@news.povray.org Kenneth wrote:
>
>> And/or the
>> historical significance of the .hf formula
>
> In the days of old, the red+green chanel of 8 bit images where (ab)used to
> store 16 bit grayscale values for use in hight_field,
>
Ah ha! of course! Now this makes me curious about subtle visual
differences between height_field functions using .hf or .grey, because
there should be some, shouldn't there? I shall investigate.
--
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 19-01-22 à 05:19, Kenneth a écrit :
> ingo <ing### [at] tag povray org> wrote:
>>
>> ...it appears that .hf = (Red + Green/255)*0.996093 not the same as .gray
>> as I thought.
>>
>> http://wiki.povray.org/content/Documentation:Tutorial_Section_3.2
>> #Noise_and_pigment_functions
>> The only appearence of .hf I could find,
>
> Thomas wrote:
>
>> .hf is typically used in height_field functions like, e.g.:
>> height_field {function HF_res, HF_res {F_HF_01(x,y,z).hf}}
>
> I knew I had seen .hf *somewhere* but didn't know where to look. Thanks, Ingo.
>
> But it comes as a fascinating surprise (to me) that .gray and .hf use different
> color-to-grayscale formulas...
>
> .gray to get the gray value of the color vector:
> gray value = Red*29.7% + Green*58.9% + Blue*11.4%
>
> .hf to get the height_field value of the color vector:
> hf value = (Red + Green/255)*0.996093
>
> I don't think I've ever actually used .hf (in either a height_field OR a
> function)-- but I'm mostly curious as to why they are different. And/or the
> historical significance of the .hf formula. AFAIU, the .gray formula is the de
> facto standard in POV-Ray for internal color conversions; but is there something
> 'special' about height_field/FUNCTION use that requires a different formula?
>
>
>
>
>
.hf use the red as the upper, or most significative, 8 bits and green as
the lower, or least significative, 8 bits of a 16 bits value to be used
as a height field. The *0.996093 is there as a fudge value to prevent
clipping at the higher end of the range. The blue channel is ignored.
.grey use a ponderated average to get a grey equivalent of the colour.
Different intent and use, different ways to get the end value.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 22.01.2019 um 17:47 schrieb Alain:
> ..hf use the red as the upper, or most significative, 8 bits and green
> as the lower, or least significative, 8 bits of a 16 bits value to be
> used as a height field. The *0.996093 is there as a fudge value to
> prevent clipping at the higher end of the range. The blue channel is
> ignored.
BTW, 0.996093 is 255/256.
The function might also be written as:
hf value = (Red * 255 + Green) / 256
I think for technical reasons the function _should_ be
hf value = (Red * 256 + Green) / 257
but alas! it isn't.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |