ai_texture.h
Go to the documentation of this file.
1// Copyright 2021 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_allocate.h"
14#include "ai_api.h"
15#include "ai_color.h"
16#include "ai_shaderglobals.h"
17
18// forward declares
19class AtUniverse;
20
34#define AI_WRAP_PERIODIC 0
35#define AI_WRAP_BLACK 1
36#define AI_WRAP_CLAMP 2
37#define AI_WRAP_MIRROR 3
38#define AI_WRAP_FILE 4
39/*\}*/
40
47#define AI_TEXTURE_CLOSEST 0
48#define AI_TEXTURE_BILINEAR 1
49#define AI_TEXTURE_BICUBIC 2
50#define AI_TEXTURE_SMART_BICUBIC 3
51/*\}*/
52
59#define AI_TEXTURE_MIPMODE_DEFAULT 0
60#define AI_TEXTURE_MIPMODE_NONE 1
61#define AI_TEXTURE_MIPMODE_ONE 2
62#define AI_TEXTURE_MIPMODE_TRILINEAR 3
63#define AI_TEXTURE_MIPMODE_ANISOTROPIC 4
64/*\}*/
65
68 float fill;
69 uint8_t filter : 2;
70 uint8_t wrap_s : 3;
71 uint8_t wrap_t : 3;
72 uint8_t start_channel;
73 int8_t mipmap_bias;
74 uint8_t mipmap_mode : 3;
75 bool single_channel : 1;
76 bool flip_s : 1;
77 bool flip_t : 1;
78 bool swap_st : 1;
79 float scale_s;
80 float scale_t;
81 float width_s;
82 float width_t;
83 float blur_s;
84 float blur_t;
85};
86
88
98struct AtTextureHandle;
99
107{
108 void* buffer = nullptr;
109 int width = 0;
110 int height = 0;
111 int full_width = 0;
112 int full_height = 0;
113 int x = 0;
114 int y = 0;
115 int channels = 0;
116 uint8_t format = 0;
117 AtArray* aov_names = nullptr;
118 ~AtImage()
119 {
121 AiFree(buffer);
122 }
123};
124
125AI_API AtTextureHandle* AiTextureHandleCreate(const char* filename, AtString color_space = AtString());
126AI_API AtRGBA AiTextureHandleAccess(const AtShaderGlobals* sg, AtTextureHandle* handle, const AtTextureParams& params, bool* success = NULL);
127AI_API void AiTextureHandleDestroy(AtTextureHandle* handle);
128
129AI_API AtRGBA AiTextureAccess(const AtShaderGlobals* sg, AtString filename, AtString color_space, const AtTextureParams& params, bool* success = NULL);
130AI_API bool AiTextureLoad(const AtString filename, const bool use_float, const unsigned int miplevel, void* image);
131AI_API bool AiTextureGetResolution(const char* filename, unsigned int* width, unsigned int* height);
132AI_API bool AiTextureGetNumChannels(const char* filename, unsigned int* num_channels);
133AI_API AI_PURE const char* AiTextureGetChannelName(const char* filename, unsigned int channel_index);
134AI_API bool AiTextureGetFormat(const char* filename, unsigned int* format);
135AI_API bool AiTextureGetBitDepth(const char* filename, unsigned int* bit_depth);
136AI_API bool AiTextureGetMatrices(const char* filename, AtMatrix& world_to_screen, AtMatrix& world_to_camera);
137AI_API void AiTextureInvalidate(const char* filename);
138
139AI_API AtString AiTextureGetTxFileName(const char* filename, AtString texture_color_space, AtString render_color_space, const AtUniverse* universe);
140AI_API AtString AiTextureAutoTxFlags(const char* texture_file, AtString texture_color_space, const AtUniverse* universe);
141
142AI_API bool AiReadImage(const char* filename, const uint8_t format, AtImage& image, AtParamValueMap* params = nullptr);
143AI_API bool AiWriteImage(const char* filename, const AtImage& image, AtParamValueMap* params = nullptr);
144AI_API bool AiResizeImage(const AtImage& inImage, AtImage& outImage, AtParamValueMap* params = nullptr);
145inline AI_DEPRECATED bool AiLoadImage(const char* filename, const uint8_t format, AtImage& image)
146{
147 return AiReadImage(filename, format, image, nullptr);
148}
149
153enum AtMakeTxStatus { AiTxPending, AiTxError, AiTxUpdated, AiTxUpdate_unneeded, AiTxAborted };
154
155AI_API void AiMakeTx(const char* filename, const char* flags, const AtUniverse* universe = NULL);
156AI_API unsigned AiMakeTxWaitJob(AtMakeTxStatus*& statuses, const char**& source_files, unsigned int& num_submitted_textures);
157AI_API void AiMakeTxAbort(AtMakeTxStatus*& statuses, const char**& source_files, unsigned int& num_submitted_textures);
158/*\}*/
Memory allocation routines.
DLL export prefix for API functions (necessary for multi-platform development)
Color types and utilities.
Shader globals struct, methods and macros.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
AI_API void AiFree(void *addr)
Arnold free() wrapper.
Definition: ai_memory.cpp:109
int channels
number of channels per pixel
Definition: ai_texture.h:115
int8_t mipmap_bias
mipmap level bias
Definition: ai_texture.h:73
bool flip_s
flip S coordinate
Definition: ai_texture.h:76
uint8_t format
data type of pixels AI_TYPE_(BYTE, USHORT, HALF, UINT, FLOAT)
Definition: ai_texture.h:116
int full_width
width of the full display window in pixels
Definition: ai_texture.h:111
AI_API bool AiTextureGetNumChannels(const char *filename, unsigned int *num_channels)
Query the number of channels in the specified image.
Definition: ai_texture.cpp:475
float scale_t
scale T coordinate
Definition: ai_texture.h:80
AI_API bool AiWriteImage(const char *filename, const AtImage &image, AtParamValueMap *params=nullptr)
Write the image in image out to the file specified by filename.
Definition: ai_texture.cpp:1427
AI_API bool AiResizeImage(const AtImage &inImage, AtImage &outImage, AtParamValueMap *params=nullptr)
Resize the image in inImage into outImage , overwrites the buffer of outImage.
Definition: ai_texture.cpp:1464
AI_API void AiMakeTxAbort(AtMakeTxStatus *&statuses, const char **&source_files, unsigned int &num_submitted_textures)
Abort pending maketx jobs.
Definition: ai_maketx.cpp:189
AI_API bool AiReadImage(const char *filename, const uint8_t format, AtImage &image, AtParamValueMap *params=nullptr)
Read in the image at filename into image .
Definition: ai_texture.cpp:1372
float width_t
multiplicative widening of look-ups on the T axis
Definition: ai_texture.h:82
AI_API AtTextureHandle * AiTextureHandleCreate(const char *filename, AtString color_space=AtString())
Create a handle for a given texture filename.
Definition: ai_texture.cpp:701
uint8_t wrap_s
wrap mode for S coordinate
Definition: ai_texture.h:70
bool flip_t
flip T coordinate
Definition: ai_texture.h:77
float scale_s
scale S coordinate
Definition: ai_texture.h:79
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:764
AI_API void AiTextureHandleDestroy(AtTextureHandle *handle)
Destroy an existing texture handle and its associated resources.
Definition: ai_texture.cpp:711
AI_API void AiMakeTx(const char *filename, const char *flags, const AtUniverse *universe=NULL)
Asynchronously runs a maketx job in the background.
Definition: ai_maketx.cpp:35
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:628
void * buffer
pixel values
Definition: ai_texture.h:108
AI_API void AiTextureInvalidate(const char *filename)
Invalidate a specific texture from the cache.
Definition: ai_texture.cpp:1029
bool swap_st
enable swapping of S and T coordinates
Definition: ai_texture.h:78
uint8_t start_channel
starting channel index to read from
Definition: ai_texture.h:72
AI_API bool AiTextureGetBitDepth(const char *filename, unsigned int *bit_depth)
Query the bit depth of the specified image.
Definition: ai_texture.cpp:583
bool single_channel
treat image as single channel
Definition: ai_texture.h:75
float fill
value for nonexistent channels (e.g.
Definition: ai_texture.h:68
AI_API void AiTextureParamsSetDefaults(AtTextureParams &params)
Initialize an AtTextureParams object with default values.
Definition: ai_texture.cpp:252
AI_API AtString AiTextureGetTxFileName(const char *filename, AtString texture_color_space, AtString render_color_space, const AtUniverse *universe)
Return the name of the TX filename that would be generated from the source texture by auto TX.
Definition: ai_texture.cpp:1071
uint8_t mipmap_mode
mode for mipmap blending and filtering
Definition: ai_texture.h:74
AtMakeTxStatus
Status of AiMakeTx jobs.
Definition: ai_texture.h:153
uint8_t wrap_t
wrap mode for T coordinate
Definition: ai_texture.h:71
int x
origin (upper left corner) of pixel data
Definition: ai_texture.h:113
AI_API AtString AiTextureAutoTxFlags(const char *texture_file, AtString texture_color_space, const AtUniverse *universe)
Return the flags passed to the "maketx" command during auto TX generation.
Definition: ai_texture.cpp:1101
float blur_s
additive blur in look-ups along the S axis
Definition: ai_texture.h:83
AtArray * aov_names
AtArray of AtStrings of aov names
Definition: ai_texture.h:117
AI_API bool AiTextureGetFormat(const char *filename, unsigned int *format)
Query the format of the specified image.
Definition: ai_texture.cpp:543
int y
origin (upper left corner) of pixel data
Definition: ai_texture.h:114
int width
width of the image in pixels
Definition: ai_texture.h:109
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:388
AI_API bool AiTextureGetResolution(const char *filename, unsigned int *width, unsigned int *height)
Query resolution info about a texture.
Definition: ai_texture.cpp:440
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:139
float width_s
multiplicative widening of look-ups on the S axis
Definition: ai_texture.h:81
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:347
float blur_t
additive blur in look-ups along the T axis
Definition: ai_texture.h:84
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:507
int full_height
height of the full display window in pixels
Definition: ai_texture.h:112
uint8_t filter
texture look-up mode
Definition: ai_texture.h:69
int height
height of the image in pixels
Definition: ai_texture.h:110
Structure that holds infromation for reading, writing and resizing images.
Definition: ai_texture.h:107
Definition: ai_matrix.h:30
RGB color + alpha.
Definition: ai_color.h:267
Shader globals data structure.
Definition: ai_shaderglobals.h:45
Structure that holds a handle for a given texture.
Structure that holds all of the available texture map look-up options.
Definition: ai_texture.h:67
This represents a universe in Arnold.

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