View Full Version : node to determine line-of-sight visibility?

08-18-2010, 07:24 PM
what i want to do is create a node that can determine if a certain point on the terrain is in direct view of a light, or certain null object. if there were a node that could tell me the number of surfaces a direct ray between two points would encounter, i suppose i could use that: if at least one surface is intersected, the area is in shadow.

the traditional alternative would be to put a point light at some location and let it cast shadows on the terrain, but that does not give me the control of the surface that i want....i need to completely matte out the areas that are in shadow (or NOT in shadow, or both in different colors).

is this possible?

08-18-2010, 08:17 PM
Raycast will do it.

You'll have to use SpotInfo to determine the location of the current spot being rendered and feed that into the Position input of the RayCast node. Take the location of the Null/light etc by using the ItemInfo nodes World Position output. Subtract the SpotInfo->World Position from that and Normalize. Check the return value from RayCast and see if it's less than the distance from the SpotInfo->WorldPosition to ItemInfo->WorldPosition. If it is, there is something blocking it. If the distance is the same or greater, nothing blocking. However, if the distance is -1 there is also nothing blocking it.

You should also check if the point on the terrain is even facing the test object too.

One possible solution is attached.

08-18-2010, 08:19 PM
thanks, i was just starting to explore the raycast method and it shows promise...your inputs are much appreciated and when i find the appropriate solution i'll do my best to post it with some renders.

08-20-2010, 05:25 PM
ok, i solved this while typing but thought it worth posting anyway......

the solution is the Tools...Vector Scalar node, it allows me to do what i need. it will output a scalar (one-dimensional value) from a vector for any of the following you choose:

minimum of X, Y, Z
maximum of X, Y, Z
overall length

unfortunately it won't let you attach to more than one of those at a time! what a waste of a good node!! it also doesn't give any direction information, which i know there is a node for that, but why not a vector supernode?

here is my question to myself===============================
this should be simpler, i'm missing something obvious. i want to break out the Y component of two vectors and determine if the point at the end of vector A is above vector B. i have a solution setup for this but it seems way more complicated than it needs to be.

isn't there a node that takes a vector input and lets me connect to either X Y or Z of that vector? i.e. one vector input and three scalar outputs? actually someone should make one that takes one vector input and outputs ALL data about the vector including the X, Y, Z, angle in XY plane, YZ plane, etc...