POV-Ray : Newsgroups : povray.binaries.images : Crater field update - Mars : Re: Crater field update - Mars Server Time
7 Aug 2024 07:16:51 EDT (-0400)
  Re: Crater field update - Mars  
From: Mike Sobers
Date: 19 Jul 2006 11:50:01
Message: <web.44be539ab22ae3491009749b0@news.povray.org>
"PM 2Ring" <nomail@nomail> wrote:
>
> I don't have a Windows C compiler, which is why I only posted a Linux
> version (I don't think anybody wants the Amiga version :). I've only done
> non-platform-specific coding on the PC: Javascript & HTML, Postscript, and
> of course, POV SDL.
>
>
> Here's a pic, with exaggerated heights, from when the "outer wall blending
> into the background" algorithm was not quite right...


Looks great!  These craters seem volcanic in origin - maybe another option
to add?

You can download my source from
http://michaelsobers.home.mindspring.com/tests/NewCrater2.zip

The random number code is now:
//#define random(x) (((x)*(rand()>>15UL))>>16UL)
#define random(x) (( (x)*rand() )/RAND_MAX)

Where RAND_MAX is an identifier (maybe Windows only?) that is the maximum
number that can be returned by rand() (I think it's the maximum integer
value).

The central peak code is simply adds to the current crater interior profile:

 if(d<irad) {
     float rmax = irad;
     float radius = d;
  c = c + pow8((rmax-radius)/rmax)*h/4;
 }

Where the variable redefinition to float forces the code to use floating
point operations on the division (using integers didn't work).  From trial
and error, it seemed that h/2 was the height of the rim of the crater, so
the function varies from zero at the edge, to a peak about 1/2 the crater
rim height at the center.

Here's the function pow8, which is just a function to raise the argument to
the eighth power:

float pow8(float x)
{
  float x2 = x*x;
  float x4 = x2*x2;
  return (x4*x4);
}

The rest is just command line options and logic to decide when to implement
the central peaks and when to avoid it.  I'm sure there are more elegant
approaches than mine, especially to minimze the number of operations in
each cycle, which becomes important when running the loop 10 million times
or so.

My smoothing function is crummy so I'd avoid using it and just postprocess
the image with Gaussian blur to simulate erosion.

Mike


Post a reply to this message

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