POV-Ray : Newsgroups : povray.newusers : TRON Game Grid... : Re: TRON Game Grid... Server Time
29 Jul 2024 06:23:10 EDT (-0400)
  Re: TRON Game Grid...  
From: Slime
Date: 8 Jul 2006 20:47:27
Message: <44b0521f@news.povray.org>
> However I'd like a TRON grid.  In TRON the width of the grid lines doesn't
> narrow with distance from the camera quite as it should.  There is some
> narrowing going on but note in the gif I posted above that the narrow
white
> lines soon fill the entire plane in the distance.  Its this effect that
has
> now been copied in Realsoft 3D and I'm curious if POV-Ray can do it as
well.

An interesting problem. In the below code I've used a function to make the
lines get thicker as they get farther away from the camera. They still
appear thinner in some places, because the angle from the camera to the
plane gets shallower. I also used a function to create the "horizon glow"
effect. It should be fully animatable if you want to change the camera
location (camloc). I'll post an image in p.b.i shortly.

#declare camloc = <0,5,0>;

camera
{
 location camloc
 look_at <5,0,10>
}

#include "functions.inc"

#declare camlocx = camloc.x;
#declare camlocy = camloc.y;
#declare camlocz = camloc.z;

// replace the contents of getThickness with a single number
// (such as .03) to have a uniform line thickness everywhere.
#declare getThickness = function(x,y,z) {
 //.03

 // we want the thickness at <x,y,z> to be proportional
 // to the distance from the camera
 .003 * f_sphere(x - camlocx, y - camlocy, z - camlocz, 0)

 // if the effect is too strong, the above could be
 // combined with a constant number; for instance
 // (the above equation) * .7 + (normal line thickness) * (1 - .7)
}

#declare gridlinefunc = function(x, Thickness) {
 min( x - floor(x), 1 - (x - floor(x)) ) + max(.5 - Thickness, 0)
}
#declare gridfunchelper = function(x,y, Thickness) {
 min(gridlinefunc(x, Thickness), gridlinefunc(y, Thickness))
}
#declare gridfunc = function(x,y,z) {
 gridfunchelper(x, z, getThickness(x,y,z))
}

// returns dot product of angle to camera and <0,0,1>
#declare angleToCamera = function(x,y,z) {
 (camlocy - y) / f_sphere(x - camlocx, y - camlocy, z - camlocz, 0)
}

plane
{
 y, 0

 texture
 {
  pigment
  {
   function {gridfunc(x,y,z)}
   pigment_map {
    [.49 rgb 1] // white line
    [.51
     // blue turning to green in the distance
     function {angleToCamera(x,y,z)}
     color_map {
      [0 rgb <.3,.9,1>] // horizon color
      [1 rgb <.3,.6,1>*.85] // nearby color
     }
     // use poly_wave numbers closer to 0 to favor
     // the nearby color, closer to 1 or higher to
     // favor the horizon color
     poly_wave .3
    ]
   }
  }

  finish {ambient 1 diffuse 0}
 }
}


 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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