Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPUs.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Hairs with Embree

Mos__Keicam
Beginner
442 Views

Hi,

I try to add hair geometry to embree (3.20)

-RTCGeometry geom = rtcNewGeometry(*g_device, RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE);

Unfortunetely it crashes when BVH build "embree::avx::UnalignedHeuristicArrayBinningSAH<embree::PrimRef, 32ul>::computeAlignedSpace() at 0x7f82e8211a6a "

I put all vertices in an array.  (vertices_radius - vec4 with radius on 4 coord).

In vertices_indices for each fiber i vertices_indices.push_back(ISPCHair(offsets, i));  ( offsets - is index position )

rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, &(vertices_indices[0]), 0,
                sizeof(ISPCHair), fiber_count);

rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT4,
                &(vertices_radius[0]), 0, sizeof(EmbreeVertex4), vertex_count);

Does fibers have to have the same number of control vertices? Or is it Embree's limitations ?

I followed tutorial.  From my understanding i needed to put in  vertices_indices a structure 2 unsigned int : 

struct ISPCHair
{
    unsigned int vertex;
    unsigned int id;
} ;

where vertex is position of the vertex in vertices_radius and id is fibers index. Is it right?

 

 

 

 

 

0 Kudos
6 Replies
SvenW_Intel
Moderator
442 Views

Looks correct to me. Maybe there is a problem with alignment. Could you please allocate a 16 byte aligned buffer for the vertices and try again?

Mos__Keicam
Beginner
442 Views

I works !!! It was alignment problem thanks.

SvenW_Intel
Moderator
442 Views

Just checked the code, and vertex buffers to not have to get aligned. Did you use precompiled binaries? If not, which compiler did you use to compile the code?

Mos__Keicam
Beginner
442 Views

I've changed :

rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, &(vertices_indices[0]), 0,
                sizeof(ISPCHair), fiber_count);

to :

vertices_indices = (unsigned int*) rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, sizeof(unsigned int), 2*fiber_count);

And i tried vertices_indices = (unsigned int*) rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT2, sizeof(ISPCHair), fiber_count); but apparently there was a format's error.  RTC_FORMAT_UINT2 ?

 

Mos__Keicam
Beginner
442 Views

Hi, 

I have another question about hairs with different geometry types for curve.

Should i pass each curve of hairs as a separate geometry or it's better to put every curve in one geometry ?

In that case of one geometry i would in indices i should put :

vertices_indices[2*i] = offsets;  
vertices_indices[2*i+1] = i;

where i is i-th curve and and offets is the position in vertex buffer. 

vertices_indices = (unsigned int*) rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, sizeof(unsigned int), 2*fiber_count). Is it better to stash each curve in separete geometry?

In case of RTC_GEOMETRY_TYPE_ROUND_BEZIER_CURVE and RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE should the number of control vertices should always be 4? Can it vary from one curve to another if we pass all curve in geometry?

Thanks, in advance.

 

 

 

SvenW_Intel
Moderator
442 Views

Please put many curves inside one geometry to improve memory consumption.

In your rtcSetNewGeometrBuffer example you have to set the stride to 2*sizeof(unsigned int) as you store 2 ints per curve.

In the Bezier basis each curve has 4 control points. However, one can share the ends of the control points between two curves. If that sharing is possible just set the start of the next curve to the end of the previous and add 3 more points.

Reply