本文整理汇总了C++中osl::TextureSystem::texture方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureSystem::texture方法的具体用法?C++ TextureSystem::texture怎么用?C++ TextureSystem::texture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osl::TextureSystem
的用法示例。
在下文中一共展示了TextureSystem::texture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 = kernel_globals->osl->ts;
bool status = ts->texture(filename, 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;
}
示例2: texture
bool OSLRenderServices::texture(ustring filename,
TextureHandle *texture_handle,
TexturePerthread *texture_thread_info,
TextureOpt &options,
OSL::ShaderGlobals *sg,
float s,
float t,
float dsdx,
float dtdx,
float dsdy,
float dtdy,
int nchannels,
float *result,
float *dresultds,
float *dresultdt,
ustring *errormessage)
{
OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
OSLTextureHandle::Type texture_type = (handle) ? handle->type : OSLTextureHandle::OIIO;
ShaderData *sd = (ShaderData *)(sg->renderstate);
KernelGlobals *kernel_globals = sd->osl_globals;
bool status = false;
switch (texture_type) {
case OSLTextureHandle::BEVEL: {
/* Bevel shader hack. */
if (nchannels >= 3) {
PathState *state = sd->osl_path_state;
int num_samples = (int)s;
float radius = t;
float3 N = svm_bevel(kernel_globals, sd, state, radius, num_samples);
result[0] = N.x;
result[1] = N.y;
result[2] = N.z;
status = true;
}
break;
}
case OSLTextureHandle::AO: {
/* AO shader hack. */
PathState *state = sd->osl_path_state;
int num_samples = (int)s;
float radius = t;
float3 N = make_float3(dsdx, dtdx, dsdy);
int flags = 0;
if ((int)dtdy) {
flags |= NODE_AO_INSIDE;
}
if ((int)options.sblur) {
flags |= NODE_AO_ONLY_LOCAL;
}
if ((int)options.tblur) {
flags |= NODE_AO_GLOBAL_RADIUS;
}
result[0] = svm_ao(kernel_globals, sd, N, state, radius, num_samples, flags);
status = true;
break;
}
case OSLTextureHandle::SVM: {
/* Packed texture. */
float4 rgba = kernel_tex_image_interp(kernel_globals, handle->svm_slot, s, 1.0f - t);
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::IES: {
/* IES light. */
result[0] = kernel_ies_interp(kernel_globals, handle->svm_slot, s, t);
status = true;
break;
}
case OSLTextureHandle::OIIO: {
/* OpenImageIO texture cache. */
OSL::TextureSystem *ts = texture_system;
if (handle && handle->oiio_handle) {
if (texture_thread_info == NULL) {
OSLThreadData *tdata = kernel_globals->osl_tdata;
texture_thread_info = tdata->oiio_thread_info;
}
status = ts->texture(handle->oiio_handle,
texture_thread_info,
options,
s,
t,
dsdx,
dtdx,
dsdy,
dtdy,
nchannels,
result,
dresultds,
//.........这里部分代码省略.........
示例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;
}