RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.37k stars 389 forks source link

new geometry buffer components size #437

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi,

The doc says that the lib expects a 32 bit unsigned number for the geometry indices function, but glTF format has it as a 16-bit ushort.

So, could the following code be made valid?

 auto *indices = std::bit_cast <uint16_t *> ( rtcSetNewGeometryBuffer( geom,
                                                                  RTC_BUFFER_TYPE_INDEX,
                                                                  0,
                                                                  RTC_FORMAT_USHORT3,
                                                                  3 * sizeof( uint16_t ),
                                                                  indices_buffer_from_glb_file.size() ) );

otherwise that would mean that a -boring- first pass to convert elements is needed.

Thanks

svenwoop commented 1 year ago

You need to convert the index buffer to uint32 as Embree does not support ushort3 as index format.

ghost commented 1 year ago

ok,

std::transform( begin( el.indices ), end( el.indices ), indices, []( u16 val ){

        u32 v = val;

        return v;

} );

will do then. thanks!