void AO16Material::commit() { Kd = getParam3f("color", getParam3f("kd", getParam3f("Kd", vec3f(.8f)))); map_Kd = (Texture2D*)getParamObject("map_Kd", getParamObject("map_kd", NULL)); ispc::AO16Material_set(getIE(), (const ispc::vec3f&)Kd, map_Kd.ptr!=NULL?map_Kd->getIE():NULL); }
void PerspectiveCamera::commit() { // ------------------------------------------------------------------ // first, "parse" the expected parameters // ------------------------------------------------------------------ pos = getParam3f("pos",vec3fa(0.f)); dir = getParam3f("dir",vec3fa(0.f,0.0f,1.f)); up = getParam3f("up", vec3fa(0.f,1.0f,0.f)); near = getParamf("near",0.f); far = getParamf("far", std::numeric_limits<float>::infinity()); fovy = getParamf("fovy",60.f); aspect = getParamf("aspect",1.f); // ------------------------------------------------------------------ // now, update the local precomptued values // ------------------------------------------------------------------ vec3f dz = normalize(dir); vec3f dx = normalize(cross(dz,up)); vec3f dy = normalize(cross(dx,dz)); float imgPlane_size_y = 2.f*sinf(fovy/2.f*M_PI/180.); float imgPlane_size_x = imgPlane_size_y * aspect; dir_00 = dz - (.5f * imgPlane_size_x) * dx - (.5f * imgPlane_size_y) * dy; dir_du = dx * imgPlane_size_x; dir_dv = dy * imgPlane_size_y; ispc::PerspectiveCamera_set(getIE(), (const ispc::vec3f&)pos, (const ispc::vec3f&)dir_00, (const ispc::vec3f&)dir_du, (const ispc::vec3f&)dir_dv); }
//! \brief commit the material's parameters virtual void commit() override { if (getIE() == nullptr) { ispcEquivalent = ispc::PathTracer_Glass_create(); } const float etaInside = getParamf("etaInside", getParamf("eta", 1.5f)); const float etaOutside = getParamf("etaOutside", 1.f); const vec3f& attenuationColorInside = getParam3f("attenuationColorInside", getParam3f("attenuationColor", getParam3f("color", vec3f(1.f)))); const vec3f& attenuationColorOutside = getParam3f("attenuationColorOutside", vec3f(1.f)); const float attenuationDistance = getParamf("attenuationDistance", getParamf("distance", 1.0f)); ispc::PathTracer_Glass_set( ispcEquivalent, etaInside, (const ispc::vec3f&)attenuationColorInside, etaOutside, (const ispc::vec3f&)attenuationColorOutside, attenuationDistance); }
void Camera::commit() { // "parse" the general expected parameters pos = getParam3f("pos", vec3f(0.f)); dir = getParam3f("dir", vec3f(0.f, 0.f, 1.f)); up = getParam3f("up", vec3f(0.f, 1.f, 0.f)); nearClip = getParam1f("nearClip", getParam1f("near_clip", 1e-6f)); imageStart = getParam2f("imageStart", getParam2f("image_start", vec2f(0.f))); imageEnd = getParam2f("imageEnd", getParam2f("image_end", vec2f(1.f))); shutterOpen = getParam1f("shutterOpen", 0.0f); shutterClose = getParam1f("shutterClose", 0.0f); linear3f frame; frame.vz = -normalize(dir); frame.vx = normalize(cross(up, frame.vz)); frame.vy = cross(frame.vz, frame.vx); ispc::Camera_set(getIE() , (const ispc::vec3f&)pos , (const ispc::LinearSpace3f&)frame , nearClip , (const ispc::vec2f&)imageStart , (const ispc::vec2f&)imageEnd , shutterOpen , shutterClose ); }
void SciVisMaterial::commit() { map_d = (Texture2D*)getParamObject("map_d", nullptr); map_Kd = (Texture2D*)getParamObject("map_Kd", getParamObject("map_kd", nullptr)); map_Ks = (Texture2D*)getParamObject("map_Ks", getParamObject("map_ks", nullptr)); map_Ns = (Texture2D*)getParamObject("map_Ns", getParamObject("map_ns", nullptr)); map_Bump = (Texture2D*)getParamObject("map_Bump", getParamObject("map_bump",nullptr)); d = getParam1f("d", 1.f); Kd = getParam3f("kd", getParam3f("Kd", vec3f(.8f))); Ks = getParam3f("ks", getParam3f("Ks", vec3f(0.f))); Ns = getParam1f("ns", getParam1f("Ns", 10.f)); volume = (Volume *)getParamObject("volume", nullptr); ispc::SciVisMaterial_set(getIE(), map_d ? map_d->getIE() : nullptr, d, map_Kd ? map_Kd->getIE() : nullptr, (ispc::vec3f&)Kd, map_Ks ? map_Ks->getIE() : nullptr, (ispc::vec3f&)Ks, map_Ns ? map_Ns->getIE() : nullptr, Ns, map_Bump != nullptr ? map_Bump->getIE():nullptr, volume ? volume->getIE() : nullptr); }
void RaycastVolumeRenderer::Material::commit() { Kd = getParam3f("color", getParam3f("kd", getParam3f("Kd", vec3f(1.0f)))); volume = (Volume *)getParamObject("volume", NULL); ispc::RaycastVolumeRendererMaterial_set(getIE(), (const ispc::vec3f&)Kd, volume ? volume->getIE() : NULL); }
//! \brief commit the material's parameters void OBJMaterial::commit() { if (ispcEquivalent == NULL) ispcEquivalent = ispc::OBJMaterial_create(this); map_d = (Texture2D*)getParamObject("map_d", NULL); map_Kd = (Texture2D*)getParamObject("map_Kd", getParamObject("map_kd", NULL)); map_Ks = (Texture2D*)getParamObject("map_Ks", getParamObject("map_ks", NULL)); map_Ns = (Texture2D*)getParamObject("map_Ns", getParamObject("map_ns", NULL)); map_Bump = (Texture2D*)getParamObject("map_Bump", getParamObject("map_bump", NULL)); d = getParam1f("d", 1.f); Kd = getParam3f("kd", getParam3f("Kd", vec3f(.8f))); Ks = getParam3f("ks", getParam3f("Ks", vec3f(0.f))); Ns = getParam1f("ns", getParam1f("Ns", 10.f)); ispc::OBJMaterial_set(getIE(), map_d ? map_d->getIE() : NULL, d, map_Kd ? map_Kd->getIE() : NULL, (ispc::vec3f&)Kd, map_Ks ? map_Ks->getIE() : NULL, (ispc::vec3f&)Ks, map_Ns ? map_Ns->getIE() : NULL, Ns, map_Bump != NULL ? map_Bump->getIE() : NULL ); }
//! \brief commit the material's parameters virtual void commit() override { const vec3f& color = getParam3f("color", vec3f(0.9f)); Texture2D *map_color = (Texture2D*)getParamObject("map_color"); affine2f xform_color = getTextureTransform("map_color"); const vec3f& edgeColor = getParam3f("edgeColor", vec3f(1.f)); Texture2D *map_edgeColor = (Texture2D*)getParamObject("map_edgeColor"); affine2f xform_edgeColor = getTextureTransform("map_edgeColor"); const float roughness = getParamf("roughness", 0.1f); Texture2D *map_roughness = (Texture2D*)getParamObject("map_roughness"); affine2f xform_roughness = getTextureTransform("map_roughness"); ispc::PathTracer_Alloy_set(getIE() , (const ispc::vec3f&)color , map_color ? map_color->getIE() : nullptr , (const ispc::AffineSpace2f&)xform_color , (const ispc::vec3f&)edgeColor , map_edgeColor ? map_edgeColor->getIE() : nullptr , (const ispc::AffineSpace2f&)xform_edgeColor , roughness , map_roughness ? map_roughness->getIE() : nullptr , (const ispc::AffineSpace2f&)xform_roughness ); }
void SpotLight::commit() { Light::commit(); position = getParam3f("position", vec3f(0.f)); direction = getParam3f("direction", vec3f(0.f, 0.f, 1.f)); color = getParam3f("color", vec3f(1.f)); intensity = getParam1f("intensity", 1.f); openingAngle = getParam1f("openingAngle", 2.0f * getParam1f("halfAngle"/*deprecated*/, 90.f)); penumbraAngle = getParam1f("penumbraAngle", 5.f); radius = getParam1f("radius", 0.f); // check ranges and pre-compute parameters vec3f power = color * intensity; direction = normalize(direction); openingAngle = clamp(openingAngle, 0.f, 180.f); penumbraAngle = clamp(penumbraAngle, 0.f, 0.5f*openingAngle); const float cosAngleMax = ospcommon::cos(deg2rad(0.5f*openingAngle)); const float cosAngleMin = ospcommon::cos(deg2rad(0.5f*openingAngle - penumbraAngle)); const float cosAngleScale = 1.0f/(cosAngleMin - cosAngleMax); ispc::SpotLight_set(getIE(), (ispc::vec3f&)position, (ispc::vec3f&)direction, (ispc::vec3f&)power, cosAngleMax, cosAngleScale, radius); }
void SimulationRenderer::commit( ) { Renderer::commit(); lightData = ( ospray::Data* )getParamData( "lights" ); lightArray.clear( ); if( lightData ) for( size_t i=0; i < lightData->size( ); ++i ) lightArray.push_back( ( ( ospray::Light** )lightData->data )[ i ]->getIE( )); void **lightPtr = lightArray.empty() ? nullptr : &lightArray[0]; ospray::vec3f bgColor = getParam3f( "bgColor", ospray::vec3f( 1.f )); shadowsEnabled = bool( getParam1i( "shadowsEnabled", 1 )); softShadowsEnabled = bool(getParam1i( "softShadowsEnabled", 1 )); ambientOcclusionStrength = getParam1f( "ambientOcclusionStrength", 0.f ); shadingEnabled = bool( getParam1i( "shadingEnabled", 1 )); randomNumber = getParam1i( "randomNumber", 0 ); moving = bool( getParam1i( "moving", 0 )); timestamp = getParam1f( "timestamp", 0.f ); spp = getParam1i("spp", 1); electronShadingEnabled = bool( getParam1i( "electronShading", 0 )); ospray::vec3f scale = getParam3f( "scale", ospray::vec3f( 1.f )); simulationNbOffsets = getParam1i( "simulationNbOffsets", 0 ); simulationNbFrames = getParam1i( "simulationNbFrames", 0 ); // Those materials are used for simulation mapping only materialData = ( ospray::Data* )getParamData( "materials" ); materialArray.clear( ); if( materialData ) for( size_t i = 0; i < materialData->size( ); ++i ) materialArray.push_back( ( ( ospray::Material** )materialData->data )[i]->getIE( )); void **materialPtr = materialArray.empty( ) ? nullptr : &materialArray[0]; ispc::SimulationRenderer_set( getIE( ), ( ispc::vec3f& )bgColor, ( ispc::vec3f& )scale, shadowsEnabled, softShadowsEnabled, ambientOcclusionStrength, shadingEnabled, randomNumber, moving, timestamp, spp, electronShadingEnabled, simulationNbOffsets, simulationNbFrames, lightPtr, lightArray.size( ), materialPtr, materialArray.size( )); }
//! Commit parameters understood by the PointLight void PointLight::commit() { position = getParam3f("position", vec3f(0.f)); color = getParam3f("color", vec3f(1.f)); intensity = getParam1f("intensity", 1.f); radius = getParam1f("radius", 0.f); vec3f power = color * intensity; ispc::PointLight_set(getIE(), (ispc::vec3f&)position, (ispc::vec3f&)power, radius); }
//! Commit parameters understood by the DirectionalLight void DirectionalLight::commit() { direction = getParam3f("direction", vec3f(0.f, 0.f, 1.f)); color = getParam3f("color", vec3f(1.f)); intensity = getParam1f("intensity", 1.f); angularDiameter = getParam1f("angularDiameter", .0f); const vec3f radiance = color * intensity; direction = -normalize(direction); // the ispc::DirLight expects direction towards light source angularDiameter = clamp(angularDiameter, 0.f, 180.f); const float cosAngle = cos(deg2rad(0.5f*angularDiameter)); ispc::DirectionalLight_set(getIE(), (ispc::vec3f&)direction, (ispc::vec3f&)radiance, cosAngle); }
void ProximityRenderer::commit( ) { Renderer::commit( ); lightData = ( ospray::Data* )getParamData( "lights" ); lightArray.clear( ); if( lightData ) for( size_t i = 0; i < lightData->size( ); ++i ) lightArray.push_back(((Light**)lightData->data)[i]->getIE()); void **lightPtr = lightArray.empty( ) ? NULL : &lightArray[0]; vec3f bgColor = getParam3f( "bgColor", vec3f( 0.f )); vec3f nearColor = getParam3f( "detectionNearColor", vec3f( 0.f, 1.f, 0.f )); vec3f farColor = getParam3f( "detectionFarColor", vec3f( 1.f, 0.f, 0.f )); detectionDistance = getParam1f( "detectionDistance", 1.f ); detectionOnDifferentMaterial = bool( getParam1i( "detectionOnDifferentMaterial", 0 )); randomNumber = getParam1i( "randomNumber", 0 ); timestamp = getParam1f( "timestamp", 0.f ); spp = getParam1i( "spp", 1 ); electronShadingEnabled = bool( getParam1i( "electronShading", 1 )); // Those materials are used for skybox mapping only materialData = ( ospray::Data* )getParamData( "materials" ); materialArray.clear( ); if( materialData ) for( size_t i = 0; i < materialData->size( ); ++i ) materialArray.push_back( ( ( ospray::Material** )materialData->data )[i]->getIE( )); void **materialArrayPtr = materialArray.empty( ) ? nullptr : &materialArray[0]; ispc::ProximityRenderer_set( getIE( ), ( ispc::vec3f& )bgColor, ( ispc::vec3f& )nearColor, ( ispc::vec3f& )farColor, detectionDistance, detectionOnDifferentMaterial, randomNumber, timestamp, spp, electronShadingEnabled, lightPtr, lightArray.size( ), materialArrayPtr, materialArray.size( )); }
void QuadLight::commit() { Light::commit(); position = getParam3f("position", vec3f(0.f)); edge1 = getParam3f("edge1", vec3f(1.f, 0.f, 0.f)); edge2 = getParam3f("edge2", vec3f(0.f, 1.f, 0.f)); color = getParam3f("color", vec3f(1.f)); intensity = getParam1f("intensity", 1.f); vec3f radiance = color * intensity; ispc::QuadLight_set(getIE(), (ispc::vec3f&)position, (ispc::vec3f&)edge1, (ispc::vec3f&)edge2, (ispc::vec3f&)radiance); }
//! \brief commit the material's parameters virtual void commit() override { const vec3f pigmentColor = getParam3f("pigmentColor",vec3f(1.f)); const float eta = getParamf("eta",1.4f); const float roughness = getParamf("roughness",0.01f); ispc::PathTracer_Plastic_set (getIE(), (const ispc::vec3f&)pigmentColor,eta,roughness); }
void AmbientLight::commit() { Light::commit(); color = getParam3f("color", vec3f(1.f)); intensity = getParam1f("intensity", 1.f); vec3f radiance = getRadiance(); ispc::AmbientLight_set(getIE(), (ispc::vec3f&)radiance); }
//! \brief commit the material's parameters virtual void commit() { if (getIE() != NULL) return; const vec3f pigmentColor = getParam3f("pigmentColor",vec3f(1.f)); const float eta = getParamf("eta",1.4f); const float roughness = getParamf("roughness",0.01f); // const float rcpRoughness = rcpf(roughness); ispcEquivalent = ispc::PathTracer_Plastic_create ((const ispc::vec3f&)pigmentColor,eta,roughness); }
void AO16Renderer<NUM_SAMPLES_PER_FRAME>::commit() { Renderer::commit(); model = (Model *)getParamObject("world",NULL); // old naming model = (Model *)getParamObject("model",model); // new naming camera = (Camera *)getParamObject("camera",NULL); bgColor = getParam3f("bgColor",vec3f(1.f)); ispc::AO16Renderer_set(getIE(), NUM_SAMPLES_PER_FRAME, (const ispc::vec3f&)bgColor, model?model->getIE():NULL, camera?camera->getIE():NULL); }
void RaycastVolumeRenderer::commit() { // Create the equivalent ISPC RaycastVolumeRenderer object. if (ispcEquivalent == NULL) ispcEquivalent = ispc::RaycastVolumeRenderer_createInstance(); // Get the background color. vec3f bgColor = getParam3f("bgColor", vec3f(1.f)); // Set the background color. ispc::RaycastVolumeRenderer_setBackgroundColor(ispcEquivalent, (const ispc::vec3f&) bgColor); // Set the lights if any. ispc::RaycastVolumeRenderer_setLights(ispcEquivalent, getLightsFromData(getParamData("lights", NULL))); // Initialize state in the parent class, must be called after the ISPC object is created. Renderer::commit(); }
void Renderer::commit() { autoEpsilon = getParam1i("autoEpsilon", true); epsilon = getParam1f("epsilon", 1e-6f); spp = std::max(1, getParam1i("spp", 1)); const int32 maxDepth = getParam1i("maxDepth", 20); const float minContribution = getParam1f("minContribution", 0.001f); errorThreshold = getParam1f("varianceThreshold", 0.f); maxDepthTexture = (Texture2D*)getParamObject("maxDepthTexture", nullptr); model = (Model*)getParamObject("model", getParamObject("world")); if (maxDepthTexture) { if (maxDepthTexture->type != OSP_TEXTURE_R32F || !(maxDepthTexture->flags & OSP_TEXTURE_FILTER_NEAREST)) { static WarnOnce warning("maxDepthTexture provided to the renderer " "needs to be of type OSP_TEXTURE_R32F and have " "the OSP_TEXTURE_FILTER_NEAREST flag"); } } vec3f bgColor3 = getParam3f("bgColor", vec3f(getParam1f("bgColor", 0.f))); bgColor = getParam4f("bgColor", vec4f(bgColor3, 0.f)); if (getIE()) { ManagedObject* camera = getParamObject("camera"); if (model) { const float diameter = model->bounds.empty() ? 1.0f : length(model->bounds.size()); epsilon *= diameter; } ispc::Renderer_set(getIE() , model ? model->getIE() : nullptr , camera ? camera->getIE() : nullptr , autoEpsilon , epsilon , spp , maxDepth , minContribution , (ispc::vec4f&)bgColor , maxDepthTexture ? maxDepthTexture->getIE() : nullptr ); } }
//! \brief commit the material's parameters virtual void commit() override { if (getIE() == nullptr) ispcEquivalent = ispc::PathTracer_OBJ_create(); Texture2D *map_d = (Texture2D*)getParamObject("map_d"); affine2f xform_d = getTextureTransform("map_d"); Texture2D *map_Kd = (Texture2D*)getParamObject("map_Kd", getParamObject("map_kd", getParamObject("colorMap"))); affine2f xform_Kd = getTextureTransform("map_Kd") * getTextureTransform("map_kd") * getTextureTransform("colorMap"); Texture2D *map_Ks = (Texture2D*)getParamObject("map_Ks", getParamObject("map_ks")); affine2f xform_Ks = getTextureTransform("map_Ks") * getTextureTransform("map_ks"); Texture2D *map_Ns = (Texture2D*)getParamObject("map_Ns", getParamObject("map_ns")); affine2f xform_Ns = getTextureTransform("map_Ns") * getTextureTransform("map_ns"); Texture2D *map_Bump = (Texture2D*)getParamObject("map_Bump", getParamObject("map_bump", getParamObject("normalMap", getParamObject("bumpMap")))); affine2f xform_Bump = getTextureTransform("map_Bump") * getTextureTransform("map_bump") * getTextureTransform("normalMap") * getTextureTransform("BumpMap"); linear2f rot_Bump = xform_Bump.l.orthogonal().transposed(); const float d = getParam1f("d", getParam1f("alpha", 1.f)); vec3f Kd = getParam3f("Kd", getParam3f("kd", getParam3f("color", vec3f(0.8f)))); vec3f Ks = getParam3f("Ks", getParam3f("ks", vec3f(0.f))); const float Ns = getParam1f("Ns", getParam1f("ns", 10.f)); vec3f Tf = getParam3f("Tf", getParam3f("tf", vec3f(0.0f))); const float color_total = reduce_max(Kd + Ks + Tf); if (color_total > 1.0) { postStatusMsg() << "#osp:PT: warning: OBJ material produces energy " << "(Kd + Ks + Tf = " << color_total << ", should be <= 1). Scaling down to 1."; Kd /= color_total; Ks /= color_total; Tf /= color_total; } ispc::PathTracer_OBJ_set(ispcEquivalent, map_d ? map_d->getIE() : nullptr, (const ispc::AffineSpace2f&)xform_d, d, map_Kd ? map_Kd->getIE() : nullptr, (const ispc::AffineSpace2f&)xform_Kd, (const ispc::vec3f&)Kd, map_Ks ? map_Ks->getIE() : nullptr, (const ispc::AffineSpace2f&)xform_Ks, (const ispc::vec3f&)Ks, map_Ns ? map_Ns->getIE() : nullptr, (const ispc::AffineSpace2f&)xform_Ns, Ns, (const ispc::vec3f&)Tf, map_Bump ? map_Bump->getIE() : nullptr, (const ispc::AffineSpace2f&)xform_Bump, (const ispc::LinearSpace2f&)rot_Bump); }
//! Allocate storage and populate the volume. void AMRVolume::commit() { updateEditableParameters(); // Make the voxel value range visible to the application. if (findParam("voxelRange") == nullptr) setParam("voxelRange", voxelRange); else voxelRange = getParam2f("voxelRange", voxelRange); auto methodStringFromEnv = utility::getEnvVar<std::string>("OSPRAY_AMR_METHOD"); std::string methodString = methodStringFromEnv.value_or(getParamString("amrMethod","current")); if (methodString == "finest" || methodString == "finestLevel") ispc::AMR_install_finest(getIE()); else if (methodString == "current" || methodString == "currentLevel") ispc::AMR_install_current(getIE()); else if (methodString == "octant") ispc::AMR_install_octant(getIE()); if (data != nullptr) //TODO: support data updates return; brickInfoData = getParamData("brickInfo"); assert(brickInfoData); assert(brickInfoData->data); brickDataData = getParamData("brickData"); assert(brickDataData); assert(brickDataData->data); data = make_unique<amr::AMRData>(*brickInfoData,*brickDataData); accel = make_unique<amr::AMRAccel>(*data); // finding coarset cell size + finest level cell width float coarsestCellWidth = 0.f; float finestLevelCellWidth = data->brick[0].cellWidth; box3i rootLevelBox = empty; for (auto &b : data->brick) { if (b.level == 0) rootLevelBox.extend(b.box); finestLevelCellWidth = min(finestLevelCellWidth, b.cellWidth); coarsestCellWidth = max(coarsestCellWidth, b.cellWidth); } vec3i rootGridDims = rootLevelBox.size() + vec3i(1); ospLogF(1) << "found root level dimensions of " << rootGridDims; ospLogF(1) << "coarsest cell width is " << coarsestCellWidth << std::endl; auto rateFromEnv = utility::getEnvVar<float>("OSPRAY_AMR_SAMPLING_STEP"); float samplingStep = rateFromEnv.value_or(0.1f * coarsestCellWidth); box3f worldBounds = accel->worldBounds; const vec3f gridSpacing = getParam3f("gridSpacing", vec3f(1.f)); const vec3f gridOrigin = getParam3f("gridOrigin", vec3f(0.f)); voxelType = getParamString("voxelType", "unspecified"); auto voxelTypeID = getVoxelType(); switch (voxelTypeID) { case OSP_UCHAR: break; case OSP_SHORT: break; case OSP_USHORT: break; case OSP_FLOAT: break; case OSP_DOUBLE: break; default: throw std::runtime_error("amrVolume unsupported voxel type '" + voxelType + "'"); } ispc::AMRVolume_set(getIE(), (ispc::box3f&)worldBounds, samplingStep, (const ispc::vec3f&)gridOrigin, (const ispc::vec3f&)gridSpacing); ispc::AMRVolume_setAMR(getIE(), accel->node.size(), &accel->node[0], accel->leaf.size(), &accel->leaf[0], accel->level.size(), &accel->level[0], voxelTypeID, (ispc::box3f &)worldBounds); tasking::parallel_for(accel->leaf.size(),[&](size_t leafID) { ispc::AMRVolume_computeValueRangeOfLeaf(getIE(), leafID); }); }
void Instance::finalize(Model *model) { xfm.l.vx = getParam3f("xfm.l.vx",vec3f(1.f,0.f,0.f)); xfm.l.vy = getParam3f("xfm.l.vy",vec3f(0.f,1.f,0.f)); xfm.l.vz = getParam3f("xfm.l.vz",vec3f(0.f,0.f,1.f)); xfm.p = getParam3f("xfm.p",vec3f(0.f,0.f,0.f)); instancedScene = (Model *)getParamObject("model", nullptr); assert(instancedScene); if (!instancedScene->embreeSceneHandle) { instancedScene->commit(); } RTCGeometry embreeGeom = rtcNewGeometry(ispc_embreeDevice(),RTC_GEOMETRY_TYPE_INSTANCE); embreeGeomID = rtcAttachGeometry(model->embreeSceneHandle,embreeGeom); rtcSetGeometryInstancedScene(embreeGeom,instancedScene->embreeSceneHandle); const box3f b = instancedScene->bounds; if (b.empty()) { // for now, let's just issue a warning since not all ospray // geometries do properly set the boudning box yet. as soon as // this gets fixed we will actually switch to reporting an error static WarnOnce warning("creating an instance to a model that does not" " have a valid bounding box. epsilons for" " ray offsets may be wrong"); } const vec3f v000(b.lower.x,b.lower.y,b.lower.z); const vec3f v001(b.upper.x,b.lower.y,b.lower.z); const vec3f v010(b.lower.x,b.upper.y,b.lower.z); const vec3f v011(b.upper.x,b.upper.y,b.lower.z); const vec3f v100(b.lower.x,b.lower.y,b.upper.z); const vec3f v101(b.upper.x,b.lower.y,b.upper.z); const vec3f v110(b.lower.x,b.upper.y,b.upper.z); const vec3f v111(b.upper.x,b.upper.y,b.upper.z); bounds = empty; bounds.extend(xfmPoint(xfm,v000)); bounds.extend(xfmPoint(xfm,v001)); bounds.extend(xfmPoint(xfm,v010)); bounds.extend(xfmPoint(xfm,v011)); bounds.extend(xfmPoint(xfm,v100)); bounds.extend(xfmPoint(xfm,v101)); bounds.extend(xfmPoint(xfm,v110)); bounds.extend(xfmPoint(xfm,v111)); rtcSetGeometryTransform(embreeGeom,0,RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR,&xfm); rtcCommitGeometry(embreeGeom); rtcReleaseGeometry(embreeGeom); AffineSpace3f rcp_xfm = rcp(xfm); areaPDF.resize(instancedScene->geometry.size()); ispc::InstanceGeometry_set(getIE(), (ispc::AffineSpace3f&)xfm, (ispc::AffineSpace3f&)rcp_xfm, instancedScene->getIE(), &areaPDF[0]); for (auto volume : instancedScene->volume) { ospSet3f((OSPObject)volume.ptr, "xfm.l.vx", xfm.l.vx.x, xfm.l.vx.y, xfm.l.vx.z); ospSet3f((OSPObject)volume.ptr, "xfm.l.vy", xfm.l.vy.x, xfm.l.vy.y, xfm.l.vy.z); ospSet3f((OSPObject)volume.ptr, "xfm.l.vz", xfm.l.vz.x, xfm.l.vz.y, xfm.l.vz.z); ospSet3f((OSPObject)volume.ptr, "xfm.p", xfm.p.x, xfm.p.y, xfm.p.z); } }