Exemplo n.º 1
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* initialize last seen camera */
  g_accu_vx = Vec3fa(0.0f);
  g_accu_vy = Vec3fa(0.0f);
  g_accu_vz = Vec3fa(0.0f);
  g_accu_p  = Vec3fa(0.0f);

  /* initialize hair colors */
  hair_K  = Vec3fa(0.8f,0.57f,0.32f);
  hair_dK = Vec3fa(0.1f,0.12f,0.08f);
  hair_Kr = 0.2f*hair_K;    //!< reflectivity of hair
  hair_Kt = 0.8f*hair_K;    //!< transparency of hair

  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* set start render mode */
  renderPixel = renderPixelStandard;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 2
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device, RTC_SCENE_STATIC,RTC_INTERSECT1 | RTC_INTERPOLATE);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* add curve */
  addCurve(g_scene,Vec3fa(0.0f,0.0f,0.0f));

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  renderTile = renderTileStandard;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 3
0
 EmbreeScene *embree_init(OzyScene ozy_scene) {
     RTCDevice dev = rtcNewDevice(NULL);
     RTCScene scene = rtcDeviceNewScene(dev,RTC_SCENE_STATIC, RTC_INTERSECT1);
     for(unsigned i=0;i<ozy_scene.objects.count;i++){
         Object *obj = ozy_scene.objects.data + i;
         unsigned geomID = rtcNewTriangleMesh(scene, RTC_GEOMETRY_STATIC ,
                 obj->num_tris, obj->num_verts);
         float* vertices = static_cast<float*>(rtcMapBuffer(scene, geomID,
                     RTC_VERTEX_BUFFER));
         for(u32 ii=0;ii<obj->num_verts;ii++){
             vertices[ii * 4 + 0] = obj->verts[ii].x;
             vertices[ii * 4 + 1] = obj->verts[ii].y;
             vertices[ii * 4 + 2] = obj->verts[ii].z;
         }
         rtcUnmapBuffer(scene, geomID, RTC_VERTEX_BUFFER);
         u32* triangles = static_cast<u32*>( rtcMapBuffer(scene, geomID, RTC_INDEX_BUFFER));
         for(u32 ii=0;ii<obj->num_tris*3;ii++){
             triangles[ii] = obj->tris[ii];
         }
         rtcUnmapBuffer(scene, geomID, RTC_INDEX_BUFFER);
     }
     rtcCommit(scene);
     EmbreeScene *embree_scene = new EmbreeScene;
     embree_scene->dev = dev;
     embree_scene->scene = scene;
     return embree_scene;
 }
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);

  /* configure the size of the software cache used for subdivision geometry */
  rtcDeviceSetParameter1i(g_device,RTC_SOFTWARE_CACHE_SIZE,100*1024*1024);

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device,RTC_SCENE_DYNAMIC | RTC_SCENE_ROBUST,RTC_INTERSECT1 | RTC_INTERPOLATE);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* add cube */
  addCube(g_scene);

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  renderPixel = renderPixelStandard;
  key_pressed_handler = device_key_pressed_default;
}
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(nullptr,rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction2(g_device,error_handler,nullptr);

  /* create scene */
  RTCAlgorithmFlags aflags;
  if (g_mode == MODE_NORMAL) aflags = RTC_INTERSECT1;
  else                       aflags = RTC_INTERSECT1 | RTC_INTERSECT_STREAM;
  g_scene = rtcDeviceNewScene(g_device, RTC_SCENE_STATIC | RTC_SCENE_HIGH_QUALITY,aflags);

  /* add cube */
  addCube(g_scene,Vec3fa(0.0f,0.0f,0.0f),Vec3fa(10.0f,1.0f,1.0f),45.0f);
  //addSubdivCube(g_scene);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  if (g_mode == MODE_NORMAL) renderTile = renderTileStandard;
  else                       renderTile = renderTileStandardStream;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 6
0
 /* called by the C++ code for initialization */
 extern "C" void device_init (char* cfg)
 {
   /* create new Embree device */
   g_device = rtcNewDevice(cfg);
   error_handler(rtcDeviceGetError(g_device));
   
   /* set error handler */
   rtcDeviceSetErrorFunction(g_device,error_handler);
   
   /* set start render mode */
   renderTile = renderTileStandard;
   
   /* create random bounding boxes */
   const size_t N = 2300000;
   isa::PrimInfo pinfo(empty);
   avector<PrimRef> prims; 
   for (size_t i=0; i<N; i++) {
     const float x = float(drand48());
     const float y = float(drand48());
     const float z = float(drand48());
     const Vec3fa p = 1000.0f*Vec3fa(x,y,z);
     const BBox3fa b = BBox3fa(p,p+Vec3fa(1.0f));
     pinfo.add(b);
     const PrimRef prim = PrimRef(b,i);
     prims.push_back(prim);
   }
   
   build_sah(prims,pinfo);
   build_morton(prims,pinfo);
 }
Exemplo n.º 7
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  RTCAlgorithmFlags aflags;
  if (g_mode == MODE_NORMAL) aflags = RTC_INTERSECT1;
  else                       aflags = RTC_INTERSECT1 | RTC_INTERSECT_STREAM;

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device, RTC_SCENE_DYNAMIC,aflags);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcDeviceNewScene(g_device, RTC_SCENE_STATIC,aflags);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(-1, 0, 0),0.5);
  rtcCommit (g_scene1);

  /* instantiate geometry */
  g_instance0 = rtcNewInstance(g_scene,g_scene1);
  g_instance1 = rtcNewInstance(g_scene,g_scene1);
  g_instance2 = rtcNewInstance(g_scene,g_scene1);
  g_instance3 = rtcNewInstance(g_scene,g_scene1);
  createGroundPlane(g_scene);

  /* set all colors */
  colors[0][0] = Vec3fa(0.25,0,0);
  colors[0][1] = Vec3fa(0.50,0,0);
  colors[0][2] = Vec3fa(0.75,0,0);
  colors[0][3] = Vec3fa(1.00,0,0);

  colors[1][0] = Vec3fa(0,0.25,0);
  colors[1][1] = Vec3fa(0,0.50,0);
  colors[1][2] = Vec3fa(0,0.75,0);
  colors[1][3] = Vec3fa(0,1.00,0);

  colors[2][0] = Vec3fa(0,0,0.25);
  colors[2][1] = Vec3fa(0,0,0.50);
  colors[2][2] = Vec3fa(0,0,0.75);
  colors[2][3] = Vec3fa(0,0,1.00);

  colors[3][0] = Vec3fa(0.25,0.25,0);
  colors[3][1] = Vec3fa(0.50,0.50,0);
  colors[3][2] = Vec3fa(0.75,0.75,0);
  colors[3][3] = Vec3fa(1.00,1.00,0);

  /* set start render mode */
  if (g_mode == MODE_NORMAL) renderTile = renderTileStandard;
  else                       renderTile = renderTileStandardStream;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 8
0
int main(int argc, char* argv[])
{
  /* for best performance set FTZ and DAZ flags in MXCSR control and status register */
  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);

  /* create new Embree device */
  RTCDevice device = rtcNewDevice("verbose=1");

  /* ddelete device again */
  rtcDeleteDevice(device);
  
  return 0;
}
Exemplo n.º 9
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(nullptr,rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction2(g_device,error_handler,nullptr);

  /* set start render mode */
  renderTile = renderTileStandard;
  key_pressed_handler = device_key_pressed_handler;
  old_p = Vec3fa(1E10);
}
Exemplo n.º 10
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* create scene */
  g_scene = convertScene(g_ispc_scene);
  rtcCommit (g_scene);

  /* set render tile function to use */
  renderTile = renderTileStandard;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 11
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device,RTC_SCENE_DYNAMIC | RTC_SCENE_ROBUST, RTC_INTERSECT1);

  /* create some triangulated spheres */
  for (int i=0; i<numSpheres; i++)
  {
    const float phi = i*2.0f*float(pi)/numSpheres;
    const float r = 2.0f*float(pi)/numSpheres;
    const Vec3fa p = 2.0f*Vec3fa(sin(phi),0.0f,-cos(phi));
    //RTCGeometryFlags flags = i%3 == 0 ? RTC_GEOMETRY_STATIC : i%3 == 1 ? RTC_GEOMETRY_DEFORMABLE : RTC_GEOMETRY_DYNAMIC;
    RTCGeometryFlags flags = i%2 ? RTC_GEOMETRY_DEFORMABLE : RTC_GEOMETRY_DYNAMIC;
    //RTCGeometryFlags flags = RTC_GEOMETRY_DEFORMABLE;
    int id = createSphere(flags,p,r);
    position[id] = p;
    radius[id] = r;
    colors[id].x = (i%16+1)/17.0f;
    colors[id].y = (i%8+1)/9.0f;
    colors[id].z = (i%4+1)/5.0f;
  }

  /* add ground plane to scene */
  int id = addGroundPlane(g_scene);
  colors[id] = Vec3fa(1.0f,1.0f,1.0f);

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  renderPixel = renderPixelStandard;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 12
0
void RayEngine::embreeInit() {

	cout << "Starting Embree..." << endl;

	// Init library
	Embree.device = rtcNewDevice(NULL);
	_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
	_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);

	// Generate texture
	glGenTextures(1, &Embree.texture);
	glBindTexture(GL_TEXTURE_2D, Embree.texture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glBindTexture(GL_TEXTURE_2D, 0);

	// Init scenes
	userData = this;
	for (uint i = 0; i < scenes.size(); i++)
		scenes[i]->embreeInit(Embree.device);

}
Exemplo n.º 13
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
    /* create new Embree device */
    g_device = rtcNewDevice(cfg);

    /* set error handler */
    rtcDeviceSetErrorFunction(g_device,error_handler);

    /* create scene */
    g_scene = rtcDeviceNewScene(g_device,RTC_SCENE_STATIC,RTC_INTERSECT1);

    /* instantiate geometry */
    createGroundPlane(g_scene);
    for (size_t i=0; i<numSpheres; i++) {
        float a = 2.0*float(pi)*(float)i/(float)numSpheres;
        createLazyObject(g_scene,i,10.0f*Vec3fa(cosf(a),0,sinf(a)),1);
    }
    rtcCommit (g_scene);

    /* set start render mode */
    renderPixel = renderPixelStandard;
    key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 14
0
    void MPIDistributedDevice::commit()
    {
      if (!initialized) {
        int _ac = 1;
        const char *_av[] = {"ospray_mpi_distributed_device"};

        auto *setComm =
          static_cast<MPI_Comm*>(getParam<void*>("worldCommunicator", nullptr));
        shouldFinalizeMPI = mpicommon::init(&_ac, _av, setComm == nullptr);

        if (setComm) {
          MPI_CALL(Comm_dup(*setComm, &mpicommon::world.comm));
          MPI_CALL(Comm_rank(mpicommon::world.comm, &mpicommon::world.rank));
          MPI_CALL(Comm_size(mpicommon::world.comm, &mpicommon::world.size));
        }

        auto &embreeDevice = api::ISPCDevice::embreeDevice;

        embreeDevice = rtcNewDevice(generateEmbreeDeviceCfg(*this).c_str());
        rtcSetDeviceErrorFunction(embreeDevice, embreeErrorFunc, nullptr);
        RTCError erc = rtcGetDeviceError(embreeDevice);
        if (erc != RTC_ERROR_NONE) {
          // why did the error function not get called !?
          postStatusMsg() << "#osp:init: embree internal error number " << erc;
          assert(erc == RTC_ERROR_NONE);
        }
        initialized = true;
      }

      Device::commit();

      masterRank = getParam<int>("masterRank", 0);

      TiledLoadBalancer::instance =
                      make_unique<staticLoadBalancer::Distributed>();
    }
Exemplo n.º 15
0
EmbreeDevice::EmbreeDevice()
{
    // todo: set number of threads.
    m_device = rtcNewDevice(nullptr);
};
Exemplo n.º 16
0
 extern "C" RTCDevice ispcNewDevice(const char* cfg) {
   return rtcNewDevice(cfg);
 }