POV-Ray : Newsgroups : povray.binaries.images : Asteroid Normal Map : Re: Asteroid Normal Map Server Time
1 Jun 2024 02:48:50 EDT (-0400)
  Re: Asteroid Normal Map  
From: NPC
Date: 16 Oct 2019 04:55:01
Message: <web.5da6cf2f44e99bc81dcfd3c0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> tweaked slope pigment based on wikipedia.
>
> No texture normal or additional pigment function normal.

See attached image - scene file is included below.

This texture should create a suitable bump map, when using an orthographic
camera facing in the +z direction.

You need to use 'assumed_gamma 1.0' in the scene file, and 'File_Gamma=1.0' in
the command line preserve the correct colors.

I have layered the colors using multiple textures & 'transmit' values, as it was
the first method I found that worked to get proper additive color mixing in
Povray.  Since the 'transmit 0.5' halves the 'base' layer and the 'overlay'
layer, the strength of the colors are doubled before adding them together, so
'rgb<2,0,0>' + 'rgb<0,2,0> transmit 0.5' = rgb<1,1,0>.
As I have to do two transmit layers, the first group is doubled twice.


I suspect the RGB values in a normal map are a direct translation of the xyz
VECTOR values for a normalized vector facing in any direction, rather than the
angle, so the Y value for a vector pointing at 45 degrees up would be 0.707 (Sin
45) rather than 0.5.

Because the slope map values are based on the deviation of the ANGLE from a
reference vector, I need to use 'sine_wave' rather than the default 'ramp_wave'
to get the proper output from the color map - I need equivalent vector values
rather than angle values.

I only need the part of the sine wave from the lowest point to the highest
point, so 'frequency 0.5' is added to use only the first half of the full sine
wave.  'phase 0.25' moves the sine wave along to the correct starting point.
Okay, maybe not the *correct* starting point since it now starts at 1 and
transitions down to 0, but *basically* it works if I reverse the color map
entries...

----------------------------------------------------------------

#version 3.7;

// +w500 +h500 File_Gamma=1.0 Display_Gamma=1.0 +am2 +a0.1

#global_settings{assumed_gamma 1.0}

camera{
    orthographic
    location <0, 0, -10>
    up y*10
    right x*10
    look_at <0, 0, 0>
}

// ----------------------------------------------
// TEXTURES
// ----------------------------------------------
#declare FULL_AMBIENT = finish{ambient 1 diffuse 0}

#declare X_RED =
texture{
    pigment{
        slope x
        sine_wave frequency 0.5 phase 0.25
        color_map{
            [0 color rgb<4,0,0>]
            [1 color rgb<0,0,0>]
        }
    }
    finish{FULL_AMBIENT}
}

#declare Y_GRN =
texture{
    pigment{
        slope y
        sine_wave frequency 0.5 phase 0.25
        color_map{
            [0 color rgb<0,4,0> transmit 0.5]
            [1 color rgb<0,0,0> transmit 0.5]
        }
    }
    finish{FULL_AMBIENT}
}

#declare Z_BLU =
texture{
    pigment{
        slope -z
        sine_wave frequency 0.5 phase 0.25
        color_map{
            [0 color rgb<0,0,2> transmit 0.5]
            [1 color rgb<0,0,0> transmit 0.5]
        }
    }
    finish{FULL_AMBIENT}
}

#declare XYZ_NORMAL =
texture{X_RED}
texture{Y_GRN}
texture{Z_BLU}

// ----------------------------------------------
// SCENE
// ----------------------------------------------

sphere{
    <0, 0, 0>, 2.4
    texture{XYZ_NORMAL}
    translate <-2.5, 2.5, 0>
}

intersection{
    plane{<  0,  1, -1>, 0}
    plane{<  0, -1, -1>, 0}
    plane{< -1,  0, -1>, 0}
    plane{<  1,  0, -1>, 0}
    plane{<  0,  0, -1>, -1}
    plane{<  0,  0,  1>, 2.4}
    texture{XYZ_NORMAL}
    translate < 2.5, 2.5, 0>
}

cone{
    <0, 0, 0>, 2.4, <0, 0, -2.4>, 0
    texture{XYZ_NORMAL}
    translate <-2.5, -2.5, 0>
}

#declare f_sphere = function{internal(61)}
#declare f_noise3d = function {internal(76)}

isosurface{
    function{
        f_sphere(x,y,z,2.5)
        + f_noise3d(x,y,z)*0.5
        + f_noise3d(x*8,y*8,z*8)*0.1
    }
    contained_by{sphere{<0, 0, 0>, 4}}
    threshold 0
    accuracy 0.001
    max_gradient 2
    texture{XYZ_NORMAL}
    translate < 2.5, -2.5, 0>
}


Post a reply to this message


Attachments:
Download 'normal_test.png' (123 KB)

Preview of image 'normal_test.png'
normal_test.png


 

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