[Bf-cycles] ray/scene intersection with instancing

Mohamed Sakr 3dsakr at gmail.com
Tue May 31 20:44:47 CEST 2016


not sure, but I guess  isect.object == PRIM_NONE means it didn't intersect
anything.
2 objects have the same mesh, if the data is in local space, multiply it by
the object transform matrix and it should be in global space. "also I
didn't try this, but this is a general concept".

cheers,
Mohamed Sakr

On Tue, May 31, 2016 at 7:27 PM, <laurent.boiron at dunwich.fr> wrote:

> Hi all,
>
> I am working on path tracing kernel in cycles and I am facing a behavior
> of ray/scene intersection that I am not clearly understanding. Here is
> my problem:
>
> For a given ray sent from the camera, I try to find the object
> intersected by the ray, the point of intersection ray/triangle in world
> space and his geometric normal.
>
> My solution looks like that:
>
> ==============
> bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f,
> 0.0f);
> if( !hit ) return;
>
> //get object ID (inspired from
> int object = (isect.object == PRIM_NONE)?
> kernel_tex_fetch(__prim_object, isect.prim): isect.object;
>
> int prim = kernel_tex_fetch(__prim_index, isect.prim);
> float3 Ng,Pi;
>
> //compute intersection point and geometrical normal (from
> kernel/geom/geom_triangle.h )
> triangle_point_normal(kg, object, prim, isect.u, isect.v, &Pi, &Ng,
> &stub );
> ==============
>
> It works fine EXCEPT in some cases when I have two objects sharing the
> same mesh. In this special case the object ID is the same for both
> object and coordinates of Pi are in object space. It happens only for
> those two objects, others give correct results.
>
> So my question is:
> How should I differentiate those two objects sharing the same mesh ?
> what is exactly the meaning of isect.object == PRIM_NONE  returned by
> scene_intersect function ? And how can I guess if ray intersects unique
> mesh or a mesh instance ?
>
> Any enlightenment would be very appreciated.
>
> Thanks,
>
>
> Laurent
> _______________________________________________
> Bf-cycles mailing list
> Bf-cycles at blender.org
> https://lists.blender.org/mailman/listinfo/bf-cycles
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-cycles/attachments/20160531/7da8eebb/attachment.htm 


More information about the Bf-cycles mailing list