POV-Ray : Newsgroups : povray.newusers : Clipping macro : Re: Clipping macro Server Time
5 Sep 2024 08:19:53 EDT (-0400)
  Re: Clipping macro  
From: Chris Colefax
Date: 20 Apr 2001 05:37:27
Message: <3ae00357@news.povray.org>
Nekar Xenos <vir### [at] iconcoza> wrote:
> Is there anyone that could help me with a macro to do this? I'll also be
> needing it for other scenes so the basic principle would be to replace low
> detail objects with detailed objects when they are within a certain
radius.

This shouldn't be difficult to do, using the camera position and the vlength
() function.  Begin by declaring a Tree object (with the full detail you
want), and a QuickTree object (a simpler version, such as a box with an
image-map created by rendering the full detailed tree with the alpha option
enabled).  Then when you place your trees, check each tree's position
against the camera location, e.g.:

    #declare camera_location = <-10, 20, -30>;
    camera {location camera_location}

    #declare R1 = seed(0);
    #declare Count = 0; #while (Count < 1000)    // 1000 random trees
        #declare TreePosition = (<rand(R1), 0, rand(R1)>-0.5)*<2000, 0,
2000>;
        #if (vlength(TreePosition - camera_location) < 100)
            object {Tree translate TreePosition}
        #else
            object {QuickTree translate TreePosition}
        #end
    #declare Count = Count + 1; #end

Any tree closer than 100 units to the camera uses the full details,
otherwise the quick version is used.  You could also use the #switch and
#range functions if you wanted more than two levels of detail, or use macros
to create the trees in different ways depending on the distance to the
camera.


Post a reply to this message

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