POV-Ray : Newsgroups : povray.general : image based normal maps? : Re: image based normal maps? Server Time
27 Apr 2024 13:37:44 EDT (-0400)
  Re: image based normal maps?  
From: Kenneth
Date: 21 Jan 2019 07:10:00
Message: <web.5c45b59fe20dd126cd98345b0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> 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

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