POV-Ray : Newsgroups : povray.newusers : Trace question : Re: Trace question Server Time
5 Nov 2024 11:19:34 EST (-0500)
  Re: Trace question  
From: Margus Ramst
Date: 7 Jul 2001 10:14:59
Message: <3b471963@news.povray.org>
"Mick Hazelgrove" <mic### [at] mhazelgrovefsnetcouk> wrote:

> I have a hf created with an isosurface. I want to place grass on it  -
> easy BUT I only want to place grass on the sides of the hills facing the
> camera. How can I test to see which slopes are facing me and which are
> hidden.
> 

Trace the point, and compare the surface normal at the point to the
camera->point vector. If the angle between the two is greater than 90
degrees, the surface is facing away from the camera. You might also want to
include points just below the horizon, i.e. points where the angle is a bit
more than 90 degrees. Example:

//CamPos: camera location
//TestPos: traced point on the HF
//N: surface normal at the point
//MaxAngle: 90 is at the horizon, >90 is beyond the horizon

#declare CamDir=vnormalize(TestPos-CamPos);
#if(vdot(CamDir,N)>cos(radians(MaxAngle)))
    //put grass here
#end

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg
Home page http://www.hot.ee/margusrt


Post a reply to this message

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