Пример #1
0
    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);
    }
Пример #2
0
  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);
  }
Пример #3
0
  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
        );
  }
Пример #4
0
    //! \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 );
    }
Пример #5
0
    void SciVisRenderer::commit()
    {
      Renderer::commit();

      lightData = (Data*)getParamData("lights");

      lightArray.clear();

      if (lightData) {
        for (int i = 0; i < lightData->size(); i++)
          lightArray.push_back(((Light**)lightData->data)[i]->getIE());
      }

      void **lightPtr = lightArray.empty() ? NULL : &lightArray[0];

      const bool shadowsEnabled = getParam1i("shadowsEnabled", 0);

      const int32 maxDepth = getParam1i("maxDepth", 10);

      int   numAOSamples = getParam1i("aoSamples", 0);
      float rayLength    = getParam1f("aoOcclusionDistance", 1e20f);
      float aoWeight     = getParam1f("aoWeight", 0.25f);

      ispc::SciVisRenderer_set(getIE(),
                               shadowsEnabled,
                               maxDepth,
                               numAOSamples,
                               rayLength,
                               aoWeight,
                               lightPtr,
                               lightArray.size());
    }
Пример #6
0
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( ));
}
Пример #7
0
  //! 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);
  }
Пример #8
0
  //! 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);
  }
Пример #9
0
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( ));
}
Пример #10
0
void ExtendedCylinders::finalize(ospray::Model *model)
{
    radius            = getParam1f("radius",0.01f);
    materialID        = getParam1i("materialID",0);
    bytesPerCylinder  = getParam1i("bytes_per_cylinder",9*sizeof(float));
    offset_v0         = getParam1i("offset_v0",0);
    offset_v1         = getParam1i("offset_v1",3*sizeof(float));
    offset_radius     = getParam1i("offset_radius",6*sizeof(float));
    offset_timestamp  = getParam1i("offset_timestamp",7*sizeof(float));
    offset_value      = getParam1i("offset_value",8*sizeof(float));
    offset_materialID = getParam1i("offset_materialID",-1);
    data              = getParamData("extendedcylinders",nullptr);

    if (data.ptr == nullptr || bytesPerCylinder == 0)
        throw std::runtime_error("#ospray:geometry/extendedcylinders: " \
                                 "no 'extendedcylinders' data specified");
    numExtendedCylinders = data->numBytes / bytesPerCylinder;
    ispc::ExtendedCylindersGeometry_set(
                getIE(),
                model->getIE(),
                data->data,
                numExtendedCylinders,
                bytesPerCylinder,
                radius,
                materialID,
                offset_v0,
                offset_v1,
                offset_radius,
                offset_timestamp,
                offset_value,
                offset_materialID);
}
Пример #11
0
  void StreamLines::finalize(Model *model) 
  {
    radius     = getParam1f("radius",0.01f);
    vertexData = getParamData("vertex",NULL);
    indexData  = getParamData("index",NULL);
    colorData  = getParamData("vertex.color",getParamData("color"));

    Assert(radius > 0.f);
    Assert(vertexData);
    Assert(indexData);

    index       = (const uint32*)indexData->data;
    numSegments = indexData->numItems;
    vertex      = (const vec3fa*)vertexData->data;
    numVertices = vertexData->numItems;
    color       = colorData ? (const vec4f*)colorData->data : NULL;

    std::cout << "#osp: creating streamlines geometry, "
              << "#verts=" << numVertices << ", "
              << "#segments=" << numSegments << ", "
              << "radius=" << radius << std::endl;
    
    ispc::StreamLineGeometry_set(getIE(),model->getIE(),radius,
                                 (ispc::vec3fa*)vertex,numVertices,
                                 (uint32_t*)index,numSegments,
                                 (ispc::vec4f*)color);
  }
Пример #12
0
      //! \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);
      }
Пример #13
0
    void SciVisRenderer::commit()
    {
      Renderer::commit();

      lightData = (Data*)getParamData("lights");

      lightArray.clear();
      vec3f aoColor = vec3f(0.f);
      bool ambientLights = false;

      if (lightData) {
        for (uint32_t i = 0; i < lightData->size(); i++)
        {
          const Light* const light = ((Light**)lightData->data)[i];
          // extract color from ambient lights and remove them
          const AmbientLight* const ambient = dynamic_cast<const AmbientLight*>(light);
          if (ambient) {
            ambientLights = true;
            aoColor += ambient->getRadiance();
          } else
            lightArray.push_back(light->getIE());
        }
      }

      void **lightPtr = lightArray.empty() ? nullptr : &lightArray[0];

      const bool shadowsEnabled = getParam1i("shadowsEnabled", 0);
      int aoSamples = getParam1i("aoSamples", 0);
      float aoDistance = getParam1f("aoDistance",
                          getParam1f("aoOcclusionDistance"/*old name*/, 1e20f));
      // "aoWeight" is deprecated, use an ambient light instead
      if (!ambientLights)
        aoColor = vec3f(getParam1f("aoWeight", 0.f));
      const bool aoTransparencyEnabled = getParam1i("aoTransparencyEnabled", 0);
      const bool oneSidedLighting = getParam1i("oneSidedLighting", 1);

      ispc::SciVisRenderer_set(getIE(),
                               shadowsEnabled,
                               aoSamples,
                               aoDistance,
                               (ispc::vec3f&)aoColor,
                               aoTransparencyEnabled,
                               lightPtr,
                               lightArray.size(),
                               oneSidedLighting);
    }
Пример #14
0
  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
          );
    }
  }
Пример #15
0
  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);
  }
Пример #16
0
  void PathTracer::commit()
  {
    Renderer::commit();

    destroyGeometryLights();
    lightArray.clear();
    geometryLights = 0;

    const bool useGeometryLights = getParam1i("useGeometryLights", true);

    if (model && useGeometryLights) {
      areaPDF.resize(model->geometry.size());
      generateGeometryLights(model, affine3f(one), &areaPDF[0]);
      geometryLights = lightArray.size();
    }

    lightData = (Data*)getParamData("lights");
    if (lightData) {
      for (uint32_t i = 0; i < lightData->size(); i++)
        lightArray.push_back(((Light**)lightData->data)[i]->getIE());
    }

    void **lightPtr = lightArray.empty() ? nullptr : &lightArray[0];

    const int32 rouletteDepth = getParam1i("rouletteDepth", 5);
    const float maxRadiance = getParam1f("maxContribution",
                                         getParam1f("maxRadiance", inf));
    Texture2D *backplate = (Texture2D*)getParamObject("backplate", nullptr);
    vec4f shadowCatcherPlane = getParam4f("shadowCatcherPlane", vec4f(0.f));

    ispc::PathTracer_set(getIE()
        , rouletteDepth
        , maxRadiance
        , backplate ? backplate->getIE() : nullptr
        , (ispc::vec4f&)shadowCatcherPlane
        , lightPtr
        , lightArray.size()
        , geometryLights
        , &areaPDF[0]
        );
  }
Пример #17
0
 void ToneMapperPixelOp::commit()
 {
   PixelOp::commit();
     
   float exposure = getParam1f("exposure", 1.f);
   
   // Default parameters fitted to the ACES 1.0 grayscale curve (RRT.a1.0.3 + ODT.Academy.Rec709_100nits_dim.a1.0.3)
   // We included exposure adjustment to match 18% middle gray (ODT(RRT(0.18)) = 0.18)
   const float aces_contrast = 1.6773f;
   const float aces_shoulder = 0.9714f;
   const float aces_midIn    = 0.18f;
   const float aces_midOut   = 0.18f;
   const float aces_hdrMax   = 11.0785f;
   
   float a = max(getParam1f("contrast", aces_contrast), 0.0001f);
   float d = clamp(getParam1f("shoulder", aces_shoulder), 0.0001f, 1.f);
   float m = clamp(getParam1f("midIn", aces_midIn), 0.0001f, 1.f);
   float n = clamp(getParam1f("midOut", aces_midOut), 0.0001f, 1.f);
   float w = max(getParam1f("hdrMax", aces_hdrMax), 1.f);
   
   // Solve b and c
   float b = -((powf(m, -a*d)*(-powf(m, a) + (n*(powf(m, a*d)*n*powf(w, a) - powf(m, a)*powf(w, a*d))) / (powf(m, a*d)*n - n*powf(w, a*d)))) / n);
   float c = max((powf(m, a*d)*n*powf(w, a) - powf(m, a)*powf(w, a*d)) / (powf(m, a*d)*n - n*powf(w, a*d)), 0.f); // avoid discontinuous curve by clamping to 0
   
   ispc::ToneMapperPixelOp_set(ispcEquivalent, exposure, a, b, c, d);
 }
Пример #18
0
  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);
  }
Пример #19
0
  void BlockBrickedVolume::updateEditableParameters() 
  {
    //! Get the transfer function.
    transferFunction = (TransferFunction *) getParamObject("transferFunction", NULL);  exitOnCondition(transferFunction == NULL, "no transfer function specified");

    //! Get the gamma correction coefficient and exponent.
    vec2f gammaCorrection = getParam2f("gammaCorrection", vec2f(1.0f));

    //! Set the gamma correction coefficient and exponent.
    ispc::BlockBrickedVolume_setGammaCorrection(ispcEquivalent, (const ispc::vec2f &) gammaCorrection);

    //! Set the recommended sampling rate for ray casting based renderers.
    ispc::BlockBrickedVolume_setSamplingRate(ispcEquivalent, getParam1f("samplingRate", 1.0f));

    //! Set the transfer function.
    ispc::BlockBrickedVolume_setTransferFunction(ispcEquivalent, transferFunction->getEquivalentISPC());

  }
Пример #20
0
      //! \brief commit the material's parameters
      virtual void commit() override
      {
        if (getIE() == nullptr)
          ispcEquivalent = ispc::PathTracer_Mix_create();

        float factor = getParam1f("factor", 0.5f);
        Texture2D *map_factor  = (Texture2D*)getParamObject("map_factor", nullptr);
        affine2f xform_factor  = getTextureTransform("map_factor");
        ospray::Material* mat1 = (ospray::Material*)getParamObject("material1", nullptr);
        ospray::Material* mat2 = (ospray::Material*)getParamObject("material2", nullptr);

        ispc::PathTracer_Mix_set(ispcEquivalent
            , factor
            , map_factor ? map_factor->getIE() : nullptr
            , (const ispc::AffineSpace2f&)xform_factor
            , mat1 ? mat1->getIE() : nullptr
            , mat2 ? mat2->getIE() : nullptr
            );
      }
Пример #21
0
  void Cylinders::finalize(Model *model)
  {
    radius            = getParam1f("radius",0.01f);
    materialID        = getParam1i("materialID",0);
    bytesPerCylinder  = getParam1i("bytes_per_cylinder",6*sizeof(float));
    offset_v0         = getParam1i("offset_v0",0);
    offset_v1         = getParam1i("offset_v1",3*sizeof(float));
    offset_radius     = getParam1i("offset_radius",-1);
    offset_materialID = getParam1i("offset_materialID",-1);
    offset_colorID    = getParam1i("offset_colorID",-1);
    cylinderData      = getParamData("cylinders");
    materialList      = getParamData("materialList");
    colorData         = getParamData("color");

    if (cylinderData.ptr == NULL || bytesPerCylinder == 0)
      throw std::runtime_error("#ospray:geometry/cylinders: no 'cylinders' data specified");
    numCylinders = cylinderData->numBytes / bytesPerCylinder;
    std::cout << "#osp: creating 'cylinders' geometry, #cylinders = " << numCylinders << std::endl;

    if (_materialList) {
      free(_materialList);
      _materialList = NULL;
    }

    if (materialList) {
      void **ispcMaterials = (void**) malloc(sizeof(void*) * materialList->numItems);
      for (int i=0;i<materialList->numItems;i++) {
        Material *m = ((Material**)materialList->data)[i];
        ispcMaterials[i] = m?m->getIE():NULL;
      }
      _materialList = (void*)ispcMaterials;
    }

    ispc::CylindersGeometry_set(getIE(),model->getIE(),
                                cylinderData->data,_materialList,
                                colorData?(ispc::vec4f*)colorData->data:NULL,
                                numCylinders,bytesPerCylinder,
                                radius,materialID,
                                offset_v0,offset_v1,
                                offset_radius,
                                offset_materialID,offset_colorID);
  }
Пример #22
0
  void BlockBrickedVolume::createEquivalentISPC() 
  {
    //! Get the voxel type.
    voxelType = getParamString("voxelType", "unspecified");  exitOnCondition(getVoxelType() == OSP_UNKNOWN, "unrecognized voxel type");

    //! Create an ISPC BlockBrickedVolume object and assign type-specific function pointers.
    ispcEquivalent = ispc::BlockBrickedVolume_createInstance((int) getVoxelType());

    //! Get the volume dimensions.
    volumeDimensions = getParam3i("dimensions", vec3i(0));  exitOnCondition(reduce_min(volumeDimensions) <= 0, "invalid volume dimensions");

    //! Get the transfer function.
    transferFunction = (TransferFunction *) getParamObject("transferFunction", NULL);  exitOnCondition(transferFunction == NULL, "no transfer function specified");

    //! Get the value range.
    //! Voxel range not used for now.
    // vec2f voxelRange = getParam2f("voxelRange", vec2f(0.0f));  exitOnCondition(voxelRange == vec2f(0.0f), "no voxel range specified");

    //! Get the gamma correction coefficient and exponent.
    vec2f gammaCorrection = getParam2f("gammaCorrection", vec2f(1.0f));

    //! Set the volume dimensions.
    ispc::BlockBrickedVolume_setVolumeDimensions(ispcEquivalent, (const ispc::vec3i &) volumeDimensions);

    //! Set the value range (must occur before setting the transfer function).
    //ispc::BlockBrickedVolume_setValueRange(ispcEquivalent, (const ispc::vec2f &) voxelRange);

    //! Set the transfer function.
    ispc::BlockBrickedVolume_setTransferFunction(ispcEquivalent, transferFunction->getEquivalentISPC());

    //! Set the recommended sampling rate for ray casting based renderers.
    ispc::BlockBrickedVolume_setSamplingRate(ispcEquivalent, getParam1f("samplingRate", 1.0f));

    //! Set the gamma correction coefficient and exponent.
    ispc::BlockBrickedVolume_setGammaCorrection(ispcEquivalent, (const ispc::vec2f &) gammaCorrection);

    //! Allocate memory for the voxel data in the ISPC object.
    ispc::BlockBrickedVolume_allocateMemory(ispcEquivalent);

  }