ai_texture.h
Go to the documentation of this file.
1 // Copyright 2020 Autodesk, Inc. All rights reserved.
2 //
3 // Use of this software is subject to the terms of the Autodesk license
4 // agreement provided at the time of installation or download, or which
5 // otherwise accompanies this software in either electronic or hard copy form.
6 
12 #pragma once
13 #include "ai_color.h"
14 #include "ai_api.h"
15 #include "ai_shaderglobals.h"
16 
30 #define AI_WRAP_PERIODIC 0
31 #define AI_WRAP_BLACK 1
32 #define AI_WRAP_CLAMP 2
33 #define AI_WRAP_MIRROR 3
34 #define AI_WRAP_FILE 4
35 /*\}*/
36 
43 #define AI_TEXTURE_CLOSEST 0
44 #define AI_TEXTURE_BILINEAR 1
45 #define AI_TEXTURE_BICUBIC 2
46 #define AI_TEXTURE_SMART_BICUBIC 3
47 /*\}*/
48 
55 #define AI_TEXTURE_MIPMODE_DEFAULT 0
56 #define AI_TEXTURE_MIPMODE_NONE 1
57 #define AI_TEXTURE_MIPMODE_ONE 2
58 #define AI_TEXTURE_MIPMODE_TRILINEAR 3
59 #define AI_TEXTURE_MIPMODE_ANISOTROPIC 4
60 /*\}*/
61 
64  float fill;
65  uint8_t filter : 2;
66  uint8_t wrap_s : 3;
67  uint8_t wrap_t : 3;
68  uint8_t start_channel;
69  int8_t mipmap_bias;
70  uint8_t mipmap_mode : 3;
71  bool single_channel : 1;
72  bool flip_s : 1;
73  bool flip_t : 1;
74  bool swap_st : 1;
75  float scale_s;
76  float scale_t;
77  float width_s;
78  float width_t;
79  float blur_s;
80  float blur_t;
81 };
82 
83 AI_API void AiTextureParamsSetDefaults(AtTextureParams& params);
84 
94 struct AtTextureHandle;
95 
96 AI_API AtTextureHandle* AiTextureHandleCreate(const char* filename, AtString color_space = AtString());
97 AI_API AtRGBA AiTextureHandleAccess(const AtShaderGlobals* sg, AtTextureHandle* handle, const AtTextureParams& params, bool* success = NULL);
98 AI_API void AiTextureHandleDestroy(AtTextureHandle* handle);
99 
100 AI_API AtRGBA AiTextureAccess(const AtShaderGlobals* sg, AtString filename, AtString color_space, const AtTextureParams& params, bool* success = NULL);
101 AI_API bool AiTextureLoad(const AtString filename, const bool use_float, const unsigned int miplevel, void* image);
102 AI_API bool AiTextureGetResolution(const char* filename, unsigned int* width, unsigned int* height);
103 AI_API bool AiTextureGetNumChannels(const char* filename, unsigned int* num_channels);
104 AI_API AI_PURE const char* AiTextureGetChannelName(const char* filename, unsigned int channel_index);
105 AI_API bool AiTextureGetFormat(const char* filename, unsigned int* format);
106 AI_API bool AiTextureGetBitDepth(const char* filename, unsigned int* bit_depth);
107 AI_API bool AiTextureGetMatrices(const char* filename, AtMatrix& world_to_screen, AtMatrix& world_to_camera);
108 AI_API void AiTextureInvalidate(const char* filename);
109 
113 enum AtMakeTxStatus { AiTxPending, AiTxError, AiTxUpdated, AiTxUpdate_unneeded, AiTxAborted };
114 
115 AI_API void AiMakeTx(const char* filename, const char* flags);
116 AI_API unsigned AiMakeTxWaitJob(AtMakeTxStatus*& statuses, const char**& source_files, unsigned int& num_submitted_textures);
117 AI_API void AiMakeTxAbort(AtMakeTxStatus*& statuses, const char**& source_files, unsigned int& num_submitted_textures);
118 /*\}*/
float fill
value for nonexistent channels (e.g.
Definition: ai_texture.h:64
uint8_t wrap_s
wrap mode for S coordinate
Definition: ai_texture.h:66
float blur_s
additive blur in look-ups along the S axis
Definition: ai_texture.h:79
uint8_t start_channel
starting channel index to read from
Definition: ai_texture.h:68
AI_API void AiMakeTxAbort(AtMakeTxStatus *&statuses, const char **&source_files, unsigned int &num_submitted_textures)
Abort pending maketx jobs.
Definition: ai_maketx.cpp:334
float width_s
multiplicative widening of look-ups on the S axis
Definition: ai_texture.h:77
Shader globals struct, methods and macros.
AI_API AI_PURE const char * AiTextureGetChannelName(const char *filename, unsigned int channel_index)
Query the name of a channel in the specified image.
Definition: ai_texture.cpp:477
float width_t
multiplicative widening of look-ups on the T axis
Definition: ai_texture.h:78
uint8_t mipmap_mode
mode for mipmap blending and filtering
Definition: ai_texture.h:70
AI_API void AiTextureInvalidate(const char *filename)
Invalidate a specific texture from the cache.
Definition: ai_texture.cpp:972
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
AI_API bool AiTextureGetResolution(const char *filename, unsigned int *width, unsigned int *height)
Query resolution info about a texture.
Definition: ai_texture.cpp:412
AI_API AtTextureHandle * AiTextureHandleCreate(const char *filename, AtString color_space=AtString())
Create a handle for a given texture filename.
Definition: ai_texture.cpp:667
bool flip_s
flip S coordinate
Definition: ai_texture.h:72
bool flip_t
flip T coordinate
Definition: ai_texture.h:73
float scale_t
scale T coordinate
Definition: ai_texture.h:76
float blur_t
additive blur in look-ups along the T axis
Definition: ai_texture.h:80
Color types and utilities.
AI_API unsigned AiMakeTxWaitJob(AtMakeTxStatus *&statuses, const char **&source_files, unsigned int &num_submitted_textures)
This function will block until at least one job has been finished.
Definition: ai_maketx.cpp:290
Definition: ai_matrix.h:30
DLL export prefix for API functions (necessary for multi-platform development)
bool swap_st
enable swapping of S and T coordinates
Definition: ai_texture.h:74
Structure that holds all of the available texture map look-up options.
Definition: ai_texture.h:63
AI_API bool AiTextureGetNumChannels(const char *filename, unsigned int *num_channels)
Query the number of channels in the specified image.
Definition: ai_texture.cpp:446
int8_t mipmap_bias
mipmap level bias
Definition: ai_texture.h:69
Shader globals data structure.
Definition: ai_shaderglobals.h:45
uint8_t filter
texture look-up mode
Definition: ai_texture.h:65
AI_API bool AiTextureLoad(const AtString filename, const bool use_float, const unsigned int miplevel, void *image)
This is currently an EXPERIMENTAL function and might be modified in future Arnold releases...
Definition: ai_texture.cpp:356
AI_API bool AiTextureGetMatrices(const char *filename, AtMatrix &world_to_screen, AtMatrix &world_to_camera)
Query the matrices associated with the specified texture.
Definition: ai_texture.cpp:595
AI_API void AiTextureParamsSetDefaults(AtTextureParams &params)
Initialize an AtTextureParams object with default values.
Definition: ai_texture.cpp:220
AI_API AtRGBA AiTextureHandleAccess(const AtShaderGlobals *sg, AtTextureHandle *handle, const AtTextureParams &params, bool *success=NULL)
Perform a texture look-up through a handle.
Definition: ai_texture.cpp:730
RGB color + alpha.
Definition: ai_color.h:266
float scale_s
scale S coordinate
Definition: ai_texture.h:75
AI_API AtRGBA AiTextureAccess(const AtShaderGlobals *sg, AtString filename, AtString color_space, const AtTextureParams &params, bool *success=NULL)
Perform a texture look-up through a filename string.
Definition: ai_texture.cpp:316
AI_API void AiMakeTx(const char *filename, const char *flags)
Asynchronously runs a maketx job in the background.
Definition: ai_maketx.cpp:199
AI_API void AiTextureHandleDestroy(AtTextureHandle *handle)
Destroy an existing texture handle and its associated resources.
Definition: ai_texture.cpp:677
AI_API bool AiTextureGetFormat(const char *filename, unsigned int *format)
Query the format of the specified image.
Definition: ai_texture.cpp:512
AtMakeTxStatus
Status of AiMakeTx jobs.
Definition: ai_texture.h:113
bool single_channel
treat image as single channel
Definition: ai_texture.h:71
AI_API bool AiTextureGetBitDepth(const char *filename, unsigned int *bit_depth)
Query the bit depth of the specified image.
Definition: ai_texture.cpp:551
Structure that holds a handle for a given texture.
uint8_t wrap_t
wrap mode for T coordinate
Definition: ai_texture.h:67

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com