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


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

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


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

示例1: environment

bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
                                    OSL::ShaderGlobals *sg, const OSL::Vec3 &R,
                                    const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, 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->environment(th, thread_info,
	                              options, R, dRdx, dRdy, 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,代码行数:27,代码来源:osl_services.cpp

示例2: return

TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(ustring filename)
{
  OSLTextureHandleMap::iterator it = textures.find(filename);

  /* For non-OIIO textures, just return a pointer to our own OSLTextureHandle. */
  if (it != textures.end()) {
    if (it->second->type != OSLTextureHandle::OIIO) {
      return (TextureSystem::TextureHandle *)it->second.get();
    }
  }

  /* Get handle from OpenImageIO. */
  OSL::TextureSystem *ts = texture_system;
  TextureSystem::TextureHandle *handle = ts->get_texture_handle(filename);
  if (handle == NULL) {
    return NULL;
  }

  /* Insert new OSLTextureHandle if needed. */
  if (it == textures.end()) {
    textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::OIIO));
    it = textures.find(filename);
  }

  /* Assign OIIO texture handle and return. */
  it->second->oiio_handle = handle;
  return (TextureSystem::TextureHandle *)it->second.get();
}
开发者ID:dfelinto,项目名称:blender,代码行数:28,代码来源:osl_services.cpp

示例3: texture

bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
                                OSL::ShaderGlobals *sg,
                                float s, float t, float dsdx, float dtdx,
                                float dsdy, float dtdy, float *result)
{
	OSL::TextureSystem *ts = osl_ts;
	ShaderData *sd = (ShaderData *)(sg->renderstate);
	KernelGlobals *kg = sd->osl_globals;

#ifdef WITH_PTEX
	/* todo: this is just a quick hack, only works with particular files and options */
	if(string_endswith(filename.string(), ".ptx")) {
		float2 uv;
		int faceid;

		if(!primitive_ptex(kg, sd, &uv, &faceid))
			return false;

		float u = uv.x;
		float v = uv.y;
		float dudx = 0.0f;
		float dvdx = 0.0f;
		float dudy = 0.0f;
		float dvdy = 0.0f;

		Ptex::String error;
		PtexPtr<PtexTexture> r(ptex_cache->get(filename.c_str(), error));

		if(!r) {
			//std::cerr << error.c_str() << std::endl;
			return false;
		}

		bool mipmaplerp = false;
		float sharpness = 1.0f;
		PtexFilter::Options opts(PtexFilter::f_bicubic, mipmaplerp, sharpness);
		PtexPtr<PtexFilter> f(PtexFilter::getFilter(r, opts));

		f->eval(result, options.firstchannel, options.nchannels, faceid, u, v, dudx, dvdx, dudy, dvdy);

		for(int c = r->numChannels(); c < options.nchannels; c++)
			result[c] = result[0];

		return true;
	}
#endif

	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->texture(th, thread_info,
	                          options, s, t, dsdx, dtdx, dsdy, dtdy, 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,代码行数:68,代码来源:osl_services.cpp


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