Exemplo n.º 1
0
      //! \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
            );
      }
Exemplo n.º 2
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);
      }
Exemplo n.º 3
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
            );
      }