POV-Ray : Newsgroups : povray.general : Generate normal map : Re: Generate normal map Server Time
28 Apr 2024 23:16:27 EDT (-0400)
  Re: Generate normal map  
From: Josh
Date: 9 Oct 2019 01:25:01
Message: <web.5d9d6e3e892ac19bde26add0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Just copy and paste the below into a text file named [filename].pov
> -------------------------------------------------------------------
>
> #version 3.8;
> global_settings {
>  assumed_gamma 1.0
>  ambient_light 1.0
> }
> #include "colors.inc"
> #include "functions.inc"
>
> #declare Zoom = 30;
>  camera {
>   orthographic
>   right     x*image_width/(Zoom)
>   up   y*image_height/(Zoom)
>   location <0, 0, -10>
>   look_at  <0, 0, 0>
>  }
>
> background {color rgbt <0,0,0,1>}
>
> #declare Lighting = 1;
>
> #switch (Lighting)
>
> #case (0)
>  light_source {<0, 0, -10> colour rgb 1}
> #break
>
> #case (1)
>  // An area light (creates soft shadows)
>  light_source {
>    <0,0,0>             // light's position (translated below)
>    color rgb 1.0       // light's color
>    area_light
>    <20, 0, 0> <0, 20, 0> // lights spread out across the plane defined by these
> vectors
>    4, 4                // total number of lights in grid (4x*4z = 16 lights)
>    area_illumination off
>    adaptive 0          // 0,1,2,3...
>    jitter              // adds random softening of light
>    //circular            // make the shape of the light circular
>    orient              // orient light
>    translate <0, 0, -10>   // <x y z> position of light
>  }
> #break
>
> #case (2)
>  sphere {0, 11
>   clipped_by {plane {-z, -1}}
>   texture {pigment {rgb 0.9} finish {emission 1}}
>  }
> #break
>
> #else
>  light_source {<10, 0, -10> colour rgb 1}
> #end
>
> //==================================================
>
> // 1: plain gray
> // 2: normal map for Godot shading
>
> #declare Sprite = 1; //<--- use this to manually switch between gray and normal
> map
>
> //==================================================
>
> #declare RedX =
> pigment {
>  slope {x}
>   color_map {
>    [ 0 color rgb <0, 0, 0> ]
>    [ 1 color rgb <1, 0, 0> ]
>   }
> }
>
> #declare GreenY =
> pigment {
>  slope {y}
>   color_map {
>    [ 0 color rgb <0, 0, 0> ]
>    [ 1 color rgb <0, 1, 0> ]
>   }
> }
>
> #declare BlueZ =
> pigment {
>  slope {z}
>   color_map {
>    [ 0 color rgb <0, 0, 0.5> ]
>    [ 1 color rgb <0, 0, 1> ]
>  }
> }
>
>
> #declare NormalMap =
> texture {
>  pigment {
>   average
>    pigment_map {
>     [3 RedX ]
>     [3 GreenY ]
>     [3 BlueZ ]
>    }
>  }
>  finish { ambient 1 diffuse 0 }
> }
>
>
> //==================================================
>
>
> #declare Radius = 2;
> #declare Noise = function {f_noise3d (x, y, z) }
> #declare P = pigment {Gray50} // may need adjusting
> #declare G = function {pigment {granite scale 1.5}} // optional - see end of
> isosurface function
> #declare NS = 0.7; // NoiseScale
> #declare NoiseStrength = 0.5;
>
> #declare Asteroid =
> isosurface {
>  //function {y - Noise (x, 0, z) * 2 }
>  function {
>   sqrt(pow (x, 2) + pow (y, 2) + pow (z, 2)) -
>   Radius -
>   (Noise (x/NS, y/NS, z/NS)*NoiseStrength)} // <-- delete this } to use function
> G
>   // - G(x,y,z).x*0.25 }
>
>  max_gradient 2
>  accuracy 0.0001
>  contained_by {box {<-Radius, -Radius, -Radius>*2, <Radius, Radius*3, Radius>*2}
> }
>  scale <1, 1.5, 1>
> }
>
> #switch (clock)
>
> #case (0)
> object {Asteroid
>  texture {
>   pigment {P}
>   finish {ambient 0.5 diffuse 0.25} // specular 0.25}
>   //normal {granite scale 1.5}
>  }
>  //translate -x*3
> }
> #break
>
> #case (1)
> object {Asteroid
>  texture {NormalMap}
>  //translate  x*3
> }
> #break
>
> #else text {ttf "cyrvetic.ttf", "NOPE.", 0.1, <0, 0> pigment {rgb <1, 0, 0>}
> scale 5}
>
> #end

Thank you so much for sending this. I think I got it working. But from what I
can tell, the normal map isn't quite right. All the colors are 'washed out'. I
would expect that near the center of the asteroid, the color would be RGB
128,128,255, and that near the right edge the red component would be 255, and
near the left edge the red component near 0, and the same for the green, close
to 0 and 255 near the edges. Maybe mind didn't render correctly or it isn't
quite right yet.


Post a reply to this message

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