当前位置: 首页>>代码示例>>C++>>正文


C++ TextureSystem::texture3d方法代码示例

本文整理汇总了C++中osl::TextureSystem::texture3d方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureSystem::texture3d方法的具体用法?C++ TextureSystem::texture3d怎么用?C++ TextureSystem::texture3d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osl::TextureSystem的用法示例。


在下文中一共展示了TextureSystem::texture3d方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
                                  OSL::ShaderGlobals *sg, const OSL::Vec3 &P,
                                  const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy,
                                  const OSL::Vec3 &dPdz, float *result)
{
	OSL::TextureSystem *ts = osl_ts;
	ShaderData *sd = (ShaderData *)(sg->renderstate);
	KernelGlobals *kg = sd->osl_globals;
	OSLThreadData *tdata = kg->osl_tdata;
	OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;

	OIIO::TextureSystem::TextureHandle *th =  ts->get_texture_handle(filename, thread_info);

	bool status = ts->texture3d(th, thread_info,
	                            options, P, dPdx, dPdy, dPdz, result);

	if(!status) {
		if(options.nchannels == 3 || options.nchannels == 4) {
			result[0] = 1.0f;
			result[1] = 0.0f;
			result[2] = 1.0f;

			if(options.nchannels == 4)
				result[3] = 1.0f;
		}

	}

	return status;
}
开发者ID:ShaderManager,项目名称:MayaToCycles,代码行数:30,代码来源:osl_services.cpp

示例2:

bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
                                  OSL::ShaderGlobals *sg, const OSL::Vec3 &P,
                                  const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy,
                                  const OSL::Vec3 &dPdz, float *result)
{
    OSL::TextureSystem *ts = kernel_globals->osl->ts;
    bool status = ts->texture3d(filename, options, P, dPdx, dPdy, dPdz, result);

    if(!status) {
        if(options.nchannels == 3 || options.nchannels == 4) {
            result[0] = 1.0f;
            result[1] = 0.0f;
            result[2] = 1.0f;

            if(options.nchannels == 4)
                result[3] = 1.0f;
        }

    }

    return status;
}
开发者ID:scorpion81,项目名称:blender-voro,代码行数:22,代码来源:osl_services.cpp

示例3: if

bool OSLRenderServices::texture3d(ustring filename,
                                  TextureHandle *texture_handle,
                                  TexturePerthread *texture_thread_info,
                                  TextureOpt &options,
                                  OSL::ShaderGlobals *sg,
                                  const OSL::Vec3 &P,
                                  const OSL::Vec3 &dPdx,
                                  const OSL::Vec3 &dPdy,
                                  const OSL::Vec3 &dPdz,
                                  int nchannels,
                                  float *result,
                                  float *dresultds,
                                  float *dresultdt,
                                  float *dresultdr,
                                  ustring *errormessage)
{
  OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
  OSLTextureHandle::Type texture_type = (handle) ? handle->type : OSLTextureHandle::OIIO;
  bool status = false;

  switch (texture_type) {
    case OSLTextureHandle::SVM: {
      /* Packed texture. */
      ShaderData *sd = (ShaderData *)(sg->renderstate);
      KernelGlobals *kernel_globals = sd->osl_globals;
      int slot = handle->svm_slot;
      float4 rgba = kernel_tex_image_interp_3d(
          kernel_globals, slot, P.x, P.y, P.z, INTERPOLATION_NONE);

      result[0] = rgba[0];
      if (nchannels > 1)
        result[1] = rgba[1];
      if (nchannels > 2)
        result[2] = rgba[2];
      if (nchannels > 3)
        result[3] = rgba[3];
      status = true;
      break;
    }
    case OSLTextureHandle::OIIO: {
      /* OpenImageIO texture cache. */
      OSL::TextureSystem *ts = texture_system;

      if (handle && handle->oiio_handle) {
        if (texture_thread_info == NULL) {
          ShaderData *sd = (ShaderData *)(sg->renderstate);
          KernelGlobals *kernel_globals = sd->osl_globals;
          OSLThreadData *tdata = kernel_globals->osl_tdata;
          texture_thread_info = tdata->oiio_thread_info;
        }

        status = ts->texture3d(handle->oiio_handle,
                               texture_thread_info,
                               options,
                               P,
                               dPdx,
                               dPdy,
                               dPdz,
                               nchannels,
                               result,
                               dresultds,
                               dresultdt,
                               dresultdr);
      }
      else {
        status = ts->texture3d(filename,
                               options,
                               P,
                               dPdx,
                               dPdy,
                               dPdz,
                               nchannels,
                               result,
                               dresultds,
                               dresultdt,
                               dresultdr);
      }

      if (!status) {
        /* This might be slow, but prevents error messages leak and
         * other nasty stuff happening. */
        ts->geterror();
      }
      else if (handle && handle->processor) {
        ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels);
      }
      break;
    }
    case OSLTextureHandle::IES:
    case OSLTextureHandle::AO:
    case OSLTextureHandle::BEVEL: {
      status = false;
      break;
    }
  }

  if (!status) {
    if (nchannels == 3 || nchannels == 4) {
      result[0] = 1.0f;
      result[1] = 0.0f;
//.........这里部分代码省略.........
开发者ID:dfelinto,项目名称:blender,代码行数:101,代码来源:osl_services.cpp


注:本文中的osl::TextureSystem::texture3d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。