POV-Ray : Newsgroups : povray.general : image based normal maps? Server Time
28 Mar 2024 06:09:04 EDT (-0400)
  image based normal maps? (Message 1 to 10 of 30)  
Goto Latest 10 Messages Next 10 Messages >>>
From: cloudyroo
Subject: image based normal maps?
Date: 17 Jan 2019 06:20:00
Message: <web.5c40648670ba4e38fdc0473a0@news.povray.org>
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

From: Bald Eagle
Subject: Re: image based normal maps?
Date: 17 Jan 2019 06:35:00
Message: <web.5c406753e20dd126765e06870@news.povray.org>
"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

From: Thomas de Groot
Subject: Re: image based normal maps?
Date: 18 Jan 2019 06:57:28
Message: <5c41bf28$1@news.povray.org>
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

From: Thomas de Groot
Subject: Re: image based normal maps?
Date: 19 Jan 2019 07:25:13
Message: <5c431729$1@news.povray.org>
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

From: clipka
Subject: Re: image based normal maps?
Date: 19 Jan 2019 09:01:58
Message: <5c432dd6$1@news.povray.org>
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

From: Kenneth
Subject: Re: image based normal maps?
Date: 19 Jan 2019 14:00:01
Message: <web.5c43731ce20dd126cd98345b0@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> 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

From: Kenneth
Subject: Re: image based normal maps?
Date: 19 Jan 2019 14:20:00
Message: <web.5c437707e20dd126cd98345b0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> 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

From: Bald Eagle
Subject: Re: image based normal maps?
Date: 19 Jan 2019 14:45:01
Message: <web.5c437d14e20dd126765e06870@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> 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

From: Thomas de Groot
Subject: Re: image based normal maps?
Date: 20 Jan 2019 02:58:30
Message: <5c442a26$1@news.povray.org>
On 19-1-2019 20:40, Bald Eagle wrote:
> "Kenneth" <kdw### [at] gmailcom> 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

From: ingo
Subject: Re: image based normal maps?
Date: 20 Jan 2019 03:33:17
Message: <XnsA9DD6134B76CFseed7@news.povray.org>
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

Goto Latest 10 Messages Next 10 Messages >>>

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