access NeighborPolygons info in mental ray

Date : Thu, 15 Dec 2005 13:02:18 -0500
To : <XSI(at)Softimage.COM>
From : "Mathieu Leclaire" <mleclair(at)hybride.com>
Subject : access NeighborPolygons info in mental ray
Hi all,

I'm writing a shader and I need to access information from neighboring
polygons of the current polygon that the ray hits. From my still rather
limited experience with mental ray, I don't think I can access such
information by default so I guess I'll have to pass that information to
mental ray by a custom operator in XSI like the wireframe shader example in
the sdk. The problem is that in that example (wireframe shader), it loops
through all edges and calculates if the hit point is close enough to one of
all the edges and colors it depending on that result.

First, if I always loop through all polygons for each ray, it can become
quite long to process, especially if it's a high poly count object. There
must be an easier way to figure out on which polygon the ray interception
is?

And then I have to figure out its neighbors. Again, I don't really want to
loop so my guess is to pass from XSI to mental ray, along with each current
polygon points information, pointers to neighbor polygons with each polygon
info I pass to mental ray. So to clear things up a bit, I would pass and
array of polygons containing the following information: a index number, the
number of points on that polygon and pointers to each point?s coordinates
saved in another array that would be updated on each frame (vs. the current
information would be evaluated only in the init function), the number of
neighbors, and a pointer toward each neighboring polygons. Would that be the
right way to approach the problem?

One other thing, I need to access UVs of the hit polygon and the entire
texture information (not just the color at the hit point, but all the colors
inside the current polygon). So do I need to pass that information from XSI
as well or is there a way to access all that directly inside mental ray?

Oh and one last thing... what I want to do is extract texture information
along a certain vector direction on the polygon. So how I see it is to find
the right polygon, find the UVs and world position of each point on that
polygon. Then from the current position and the direction vector, figure out
on which edge that point/direction would intersect and from the UVs and
texture information, I could extract what colors are between the hit point
and the intersection on the edge. Again, here I'm just asking to see if I
have the best approach or if I'm missing an easier way to accomplish such a
task.

Any help/suggestions will be greatly appreciated. Thanks!


Mathieu Leclaire
R&D Programmer
Hybride




---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.