POV-Ray : Newsgroups : povray.binaries.images : Triplanar Mapping : Re: Triplanar Mapping Server Time
19 Apr 2024 17:41:55 EDT (-0400)
  Re: Triplanar Mapping  
From: Samuel B 
Date: 15 Jan 2024 20:25:00
Message: <web.65a5da7193092b9916bed5696e741498@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> Op 15-1-2024 om 01:44 schreef Samuel B.:
> > "Samuel B." <stb### [at] hotmailcom> wrote:
> >> triplanar mapping
> >
>
> Very good!
>
> This is what I get with a rapid test of your code. Also attached is the
> crater map I use.
>
> --
> Thomas

Hmm, I don't know what's causing those parallel lines, but it might be the lack
of a sharpness value. I updated the macro, and its new sharpness input /should/
help mitigate such errors plus any warping caused planar mapping. Also, that
crater map has some issues... not sure what the problem is. The attached is a
test render I made today, and the code below is what produced it.

Sam

/*
 triplanar-craters-test.pov

 2024 stb

 +fn +f +a0.3 +am2 +r2 +w768 +h768
*/


#version 3.7;

#default{ finish{ambient 0} }

global_settings{
 assumed_gamma 1.0
 #if(true)
  radiosity{
   pretrace_end .04
   count 32
   error_bound .25
   recursion_limit 1
   nearest_count 10
   normal on
  }
 #end
}

camera{
 right x up y
 location -z*1000
 look_at 0
 scale .0027
}

// sunlight
#if(true)
 light_source{
  <1, .5, 0>*1e5, srgb <1.5, 1.4, 1.3>
  #if(true)
   #declare ALRes = 2;
   #declare ALSize = .06*1e5;
   area_light x*ALSize, z*ALSize, ALRes, ALRes
   jitter
   adaptive 1
   area_illumination
  #end
 }
#end

// starry background
#if(true)
 sky_sphere{
  pigment{
   granite
   scale .05
   poly_wave 32
   pigment_map{
    [0 rgb 0]
    [.25 bozo scale .01]
   }
  }
 }
#end

// some triplanar mapping settings
#declare TriplanarScale   = 1.5;     // triplanar image scaling
#declare TriplanarTranslate = <0, .25, 0>; // triplanar image translation
#declare TriplanarAccuracy = 1.0;     // accuracy of triplanar surface normals
(1=default; higher=smoother)
#declare TriplanarSharpness = 0.7;     // 0 to 1

// input image for triplanar color and normal
#declare PImg =
 pigment{
  image_map{
   png "craters.png"
   interpolate 2
  }
  scale TriplanarScale
 }

// try to find a proper normal accuracy value based on TriplanarScale and image
size
#declare ImageRes = max_extent(PImg);
#declare ImageRes = min(ImageRes.x, ImageRes.y);

// isosurface displacement
#declare FDisp =
 function{
  pattern{
   bumps
   scale .65
   turbulence .3
   translate 2.5*z
  }
 }

// triplanar macro (Pigment in z-direction; Sharpness value between 0 and 1)
#macro Triplanar(Pigment, Sharpness)
 pigment_pattern{
  slope x
  triangle_wave
 }
 pigment_map{
  [0+.5*Sharpness Pigment rotate y*90]
  [1-.5*Sharpness
   pigment_pattern{
    slope y
    triangle_wave
   }
   pigment_map{
    [0+.5*Sharpness Pigment rotate x*90]
    [1-.5*Sharpness Pigment rotate z*165]
   }
  ]
 }
 translate TriplanarTranslate
#end

// asteroid
isosurface{
 function{
  sqrt(x*x+y*y+z*z)
  -.5*FDisp(x, y, z)
  -.5
 }
 accuracy .001
 max_gradient 1.54

 texture{
  pigment{
   pigment_pattern{Triplanar(PImg, TriplanarSharpness)}
   color_map{
    [0 rgb <0, .05, .1>]
    [1 rgb 1]
   }
  }
  normal{
   pigment_pattern{Triplanar(PImg, TriplanarSharpness)}
   poly_wave .5
   bump_size .75
   accuracy TriplanarAccuracy / ImageRes
  }
 }
}


Post a reply to this message


Attachments:
Download 'triplanar-craters-test0m_28s.jpg' (47 KB)

Preview of image 'triplanar-craters-test0m_28s.jpg'
triplanar-craters-test0m_28s.jpg


 

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