POV-Ray : Newsgroups : povray.general : Generate normal map Server Time
28 Mar 2024 11:02:16 EDT (-0400)
  Generate normal map (Message 11 to 18 of 18)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Josh
Subject: Re: Generate normal map
Date: 6 Oct 2019 00:25:00
Message: <web.5d996b90892ac19bde26add0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I adjusted the blue channel and - I guess it looks to me like it's right.
>
> The gray asteroid has
> finish {ambient 0.5 diffuse 0.25 specular 0.25}
> because ambient 1 just gives a flat gray object with no visible features...
>
> Do you need a specular map as well?
>
> Does this need to be rendered with a transparent background (alpha channel) ?

Wow. Cool. I'd love to see the povray file. Yes, I need it rendered with a
transparent background (alpha channel).

Basically I need two images that are perfectly aligned. One is the normal map.
The other is an image of the asteroid, with the features visible, but with no
major shadows. That way the game engine can add light from any direction.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Generate normal map
Date: 6 Oct 2019 09:25:01
Message: <web.5d99ea28892ac194eec112d0@news.povray.org>
"Josh" <nomail@nomail> wrote:

Yes, I need it rendered with a
> transparent background (alpha channel).
>
> Basically I need two images that are perfectly aligned. One is the normal map.
> The other is an image of the asteroid, with the features visible, but with no
> major shadows. That way the game engine can add light from any direction.
>
> Josh

Right, so the background and the normal map look good - the part that you may
want to experiment with is the lighting.  As I mentioned, changing the lighting
- or the way the object responds to the lighting (finish) can either accentuate
- or completely wipe out any visible features.   Because light and shadow (and
highlights/reflections) are the only visual cues you have to gauge shape and
depth.

I have it set to an area light, and left in a few options and commented-out
snippets of code for you to explore.

Others more skilled in the art (basically: everyone) may have better
recommendations for lighting and antialias settings.  Because those are NOT my
strong points.

Load up the .pov file (don't render it), and then load up the .ini file.
run the .ini file, and it will render the .pov file twice - one in gray and once
in normal_map mode, with transparent background.


Post a reply to this message

From: Bald Eagle
Subject: Re: Generate normal map
Date: 6 Oct 2019 09:25:01
Message: <web.5d99ea8d892ac194eec112d0@news.povray.org>
Just copy and paste the below into a text file named [filename].ini
-------------------------------------------------------------------


; Persistence Of Vision raytracer sample file.

Antialias=On

Antialias_Threshold=0.25
Antialias_Depth=5

Test_Abort_Count=100

Input_File_Name=Asteroid_prototype.pov

Initial_Frame=1
Final_Frame=2
Initial_Clock=0
Final_Clock=1

Cyclic_Animation=off
Pause_when_Done=off


Post a reply to this message

From: Bald Eagle
Subject: Re: Generate normal map
Date: 6 Oct 2019 09:25:01
Message: <web.5d99eaaa892ac194eec112d0@news.povray.org>
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


Post a reply to this message

From: Josh
Subject: Re: Generate normal map
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

From: William F Pokorny
Subject: Re: Generate normal map
Date: 11 Oct 2019 04:01:01
Message: <5da036bd@news.povray.org>
On 10/9/19 1:21 AM, Josh wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
...
> 
> 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.
> 
> 
A guess. Perhaps the normal map image needs to be in a linear color 
space and not POV-Ray's default sRGB output space. Unsure whether the 
base sprite would need this too. Depends on what your game engine wants 
in the end.

You can specify the output file gamma to use (for PNGs) in your ini 
file. However, if the base image needs sRGB and the normal image map a 
linear representation, it might be easier to use the command line. For 
just the normal map image something like:

povray +ua +k0.0 File_Gamma=sRGB +am2 +a0.1 +r3 +oI.png BaldEagle.pov

povray +ua +k1.0 File_Gamma=1.0 +am2 +a0.1 +r3 +oN.png BaldEagle.pov

for two images using different color space encodings.

Bill P.

Aside: Anyone know if there is a short flag for File_Gamma? Looked like 
no, but not had my morning coffee.


Post a reply to this message

From: Bald Eagle
Subject: Re: Generate normal map
Date: 14 Oct 2019 16:05:06
Message: <web.5da4d42b892ac194eec112d0@news.povray.org>
"Josh" <nomail@nomail> wrote:
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.

The answer lies here:

http://www.povray.org/documentation/view/3.6.1/393/


                                                                        0.5
                                                                         |
right now, if the camera is pointing this way --->   the results are  0------1.0
                                                                         |
                                                                        0.5

So the whole normal result needs to get adjusted.
I'm not sure if there's a way to rotate the results by 90 deg along the r and g
axes...


Post a reply to this message

From: Mr
Subject: Re: Generate normal map
Date: 1 Nov 2019 06:05:01
Message: <web.5dbc02d5892ac19b12f626e0@news.povray.org>
"Josh" <nomail@nomail> wrote:

> Wow. Cool. I'd love to see the povray file.

Would using these same averaging parameters counter the long lasting slope map
default and at last allow to use the resulting normal map and apply it in POV on
the raw mesh the same way Godot can do it?


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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