Various utility functions for shader writers. More...
#include "ai_bbox.h"#include "ai_color.h"#include "ai_vector.h"#include "ai_api.h"#include "ai_shaderglobals.h"Go to the source code of this file.
Typedefs | |
Utility Helper Types | |
| typedef float(* | AtFloatBumpEvaluator) (AtShaderGlobals *sg, void *data) |
| This function pointer points to float-based bump-mapping function for use by AiShaderGlobalsEvaluateBump(). More... | |
Functions | |
Lighting Functions | |
| AI_API AI_DEVICE AI_GPU_FORCE_INLINE AtRGB | AiOcclusion (const AtVector &N, const AtVector &Ng, AtShaderGlobals *sg, float mint, float maxt, float spread, float falloff, const AtSampler *sampler, AtVector *Nbent) |
| Returns the ambient occlusion at a shading point. More... | |
| AI_API AI_DEVICE AI_GPU_FORCE_INLINE AtRGB | AiSelfOcclusion (const AtVector &N, const AtVector &Ng, AtShaderGlobals *sg, float mint, float maxt, float spread, float falloff, const AtSampler *sampler, AtVector *Nbent) |
| Returns the ambient occlusion at a shading point, only considering the same object. More... | |
| AI_API AtRGB | AiDirectDiffuse (const AtVector &N, AtShaderGlobals *sg) |
| Returns the direct-lighting component of the irradiance at a shading point. More... | |
| AI_API AtRGB | AiIndirectDiffuse (const AtVector &N, AtShaderGlobals *sg, const AtRGB &weight) |
| Returns the indirect-lighting component of the irradiance at a shading point. More... | |
BSDF Utility Functions | |
| AI_API AI_DEVICE AtVector | AiReflect (const AtVector &I, const AtVector &N) |
| Returns specular direction from incident direction I and normal N. More... | |
| AI_API AtVectorDv | AiReflectWithDerivs (const AtVectorDv &I, const AtVectorDv &N) |
| Returns specular direction from incident direction I and normal N, with derivatives. More... | |
| AI_API AI_DEVICE AtVector | AiReflectSafe (const AtVector &I, const AtVector &N, const AtVector &Ng) |
| Returns specular direction from incident direction I and normal N. More... | |
| AI_API AI_DEVICE bool | AiRefract (const AtVector &I, const AtVector &N, AtVector &T, float n1, float n2) |
| Returns transmitted direction T from incident direction I and normal N. More... | |
| AI_API bool | AiRefractWithDerivs (const AtVectorDv &I, const AtVectorDv &N, AtVectorDv &T, float n1, float n2) |
| Returns transmitted direction T from incident direction I and normal N, with derivatives. More... | |
| AI_API AI_DEVICE AI_CONST float | AiSchlickFresnel (const AtVector &N, const AtVector &Rd, float Krn) |
| Computes Fresnel reflectance at an air-dielectric interface for given normal and viewing vectors. More... | |
| AI_API AI_CONST AtRGB | AiSchlickFresnelRGB (const AtVector &N, const AtVector &Rd, const AtRGB &Krn) |
| Optimized version of AiSchlickFresnel() for RGB reflectance. More... | |
| AI_API AI_CONST AtRGB | AiConductorFresnel (const AtVector &N, const AtVector &Rd, const AtRGB &n, const AtRGB &k) |
| Computes Fresnel reflectance at a conductor interface for given normal and viewing vectors. More... | |
| AI_API AI_CONST float | AiDielectricFresnel (const AtVector &N, const AtVector &Rd, float eta) |
| Computes Fresnel reflectance at a dielectric interface for given normal and viewing vectors. More... | |
| AI_API AI_DEVICE void | AiArtisticToConductorFresnel (const AtRGB &reflectivity, const AtRGB &edgetint, AtRGB &n, AtRGB &k) |
| Convert artist friendly metallic Fresnel parameters to complex refractive indices for conductor Fresnel. More... | |
| AI_API AI_DEVICE void | AiFaceForward (AtVector &N, const AtVector &I) |
| Make a normal vector face forward with respect to a given vector. More... | |
Utility Functions | |
| AI_API AI_DEVICE bool | AiShaderGlobalsGetTriangle (const AtShaderGlobals *sg, int key, AtVector p[3]) |
| Get triangle vertices at a given motion key. More... | |
| AI_API bool | AiShaderGlobalsGetVertexNormals (const AtShaderGlobals *sg, int key, AtVector n[3]) |
| Get normal vectors for all triangle vertices. More... | |
| AI_API bool | AiShaderGlobalsGetVertexUVs (const AtShaderGlobals *sg, const AtString uvset, AtVector2 uv[3]) |
| Get UV coordinates for all triangle vertices. More... | |
| AI_API AI_DEVICE uint32_t | AiShaderGlobalsGetPolygon (const AtShaderGlobals *sg, int key, AtVector *p) |
| Get polygon vertices at a given motion key. More... | |
| AI_API AI_DEVICE uint32_t | AiShaderGlobalsGetUniformID (const AtShaderGlobals *sg) |
| Get unique per face, subdivision patch, curve or point ID. More... | |
| AI_API AI_DEVICE void | AiShaderGlobalsGetPositionAtTime (const AtShaderGlobals *sg, float time, AtVector &P, AtVector *N, AtVector *Ng, AtVector *Ns) |
| Reproject the shading point to a different time. More... | |
| AI_API AI_DEVICE AI_PURE AtVector2 | AiShaderGlobalsGetPixelMotionVector (const AtShaderGlobals *sg, float time0, float time1) |
| Compute motion vector. More... | |
| AI_API AI_PURE AtBBox | AiShaderGlobalsGetBBoxLocal (const AtShaderGlobals *sg) |
| Get the object-space bounds of the current object. More... | |
| AI_API AI_PURE AtBBox | AiShaderGlobalsGetBBoxWorld (const AtShaderGlobals *sg) |
| Get the world-space bounds of the current object. More... | |
| AI_API AtNode * | AiShaderGlobalsGetShader (const AtShaderGlobals *sg) |
| Get shader assigned to the object at the current shading point. More... | |
| AI_API AI_DEVICE int32_t | AiShaderGlobalsGetSelectedOutput (const AtShaderGlobals *sg) |
| AI_API AI_DEVICE AI_PURE AtVector | AiShaderGlobalsTransformNormal (const AtShaderGlobals *sg, AtVector N, int space) |
| AI_API AI_DEVICE AI_PURE AtVector | AiShaderGlobalsTransformPoint (const AtShaderGlobals *sg, AtVector P, int space) |
| AI_API AI_DEVICE AI_PURE AtVector | AiShaderGlobalsTransformVector (const AtShaderGlobals *sg, AtVector V, int space) |
| AI_API void | AiShaderGlobalsSetTraceSet (AtShaderGlobals *sg, const AtString set, bool inclusive) |
| Takes a trace-set string and assigns it to the shader globals. More... | |
| AI_API void | AiShaderGlobalsUnsetTraceSet (AtShaderGlobals *sg) |
| Resets the trace-set for this shader globals. More... | |
| AI_API void * | AiShaderGlobalsQuickAlloc (const AtShaderGlobals *sg, uint32_t size) |
| Allocates temporary memory for this ray-tree. More... | |
| AI_API AI_PURE AtVector | AiShaderGlobalsEvaluateBump (AtShaderGlobals *sg, AtFloatBumpEvaluator bump_func, void *data) |
| Computes and returns a normal based on the current shading point and the specified bump-function. More... | |
| AI_API AI_DEVICE AtRGB | AiShaderGlobalsStochasticOpacity (AtShaderGlobals *sg, const AtRGB &opacity) |
| Performs some optimizations and returns a modified opacity value which allows for increased performance. More... | |
| AI_API AI_DEVICE AI_PURE float | AiShaderGlobalsArea (const AtShaderGlobals *sg) |
| Computes the world space area being shaded or displaced. More... | |
| AI_API AI_DEVICE AI_PURE float | AiShaderGlobalsEdgeLength (const AtShaderGlobals *sg) |
| Computes the maximum (for now) edge length of a given polygon. More... | |
| AI_API AI_DEVICE AI_PURE float | AiWireframe (const AtShaderGlobals *sg, float line_width, bool raster_space, int edge_type) |
| Computes wireframe shading for a mesh. More... | |
| AI_API AI_PURE bool | AiShaderGlobalsIsObjectMatte (const AtShaderGlobals *sg) |
| Retrieve the matte setting for the current object. More... | |
| AI_API AI_PURE bool | AiShaderGlobalsIsObjectOpaque (const AtShaderGlobals *sg) |
| Retrieve the opaque setting for the current object. More... | |
| AI_DEVICE AtVector | AiFaceViewer (const AtShaderGlobals *sg) |
| Make the surface normal face the viewer. More... | |
Camera Information | |
| AI_API AI_PURE float | AiCameraGetShutterStart () |
| Fetch camera shutter start. More... | |
| AI_API AI_PURE float | AiCameraGetShutterEnd () |
| Fetch camera shutter end. More... | |
| AI_API AI_DEVICE void | AiCameraToWorldMatrix (const AtNode *node, float time, AtMatrix &out) |
| Computes camera to world matrix. More... | |
| AI_API AI_DEVICE void | AiWorldToCameraMatrix (const AtNode *node, float time, AtMatrix &out) |
| Computes world to camera matrix. More... | |
| AI_API AI_DEVICE void | AiWorldToScreenMatrix (const AtNode *node, float time, AtMatrix &out) |
| Computes world to screen matrix. More... | |
Environment Mappings | |
| AI_API void | AiMappingMirroredBall (const AtVector &dir, float &u, float &v) |
| Maps a world-space direction vector to texture coordinates (u,v) based on the mirrored-ball mapping. More... | |
| AI_API void | AiMappingAngularMap (const AtVector &dir, float &u, float &v) |
| Maps a world-space direction vector to texture coordinates (u,v) based on an angular mapping. More... | |
| AI_API void | AiMappingLatLong (const AtVector &dir, float &u, float &v) |
| Maps a world-space direction vector to texture coordinates (u,v) based on the Latitude/Longitude mapping. More... | |
Derivatives for Environment Mappings | |
| AI_API AI_DEVICE void | AiMappingMirroredBallDerivs (const AtVector &dir, const AtVector &dDdx, const AtVector &dDdy, float &u, float &v, float &dudx, float &dudy, float &dvdx, float &dvdy) |
| Derivative version of AiMappingMirroredBall(). More... | |
| AI_API AI_DEVICE void | AiMappingAngularMapDerivs (const AtVector &dir, const AtVector &dDdx, const AtVector &dDdy, float &u, float &v, float &dudx, float &dudy, float &dvdx, float &dvdy) |
| Derivative version of AiMappingAngularMap(). More... | |
| AI_API AI_DEVICE void | AiMappingLatLongDerivs (const AtVector &dir, const AtVector &dDdx, const AtVector &dDdy, float &u, float &v, float &dudx, float &dudy, float &dvdx, float &dvdy) |
| Derivative version of AiMappingLatLong(). More... | |
Point Cloud Queries | |
| AI_API AI_DEVICE int | AiPointCloudSearch (const AtShaderGlobals *sg, AtString name, const AtVector &P, float radius, int max_points, bool sort, size_t *out_indices, float *out_distances_squared) |
| Search a pointcloud for the nearest max_points. More... | |
Point cloud values query | |||||||||||
From a given set of point indices, query point attributes. This is usually used in conjunction with AiShaderGlobalsPointCloudSearch() where the indices have been found, and then further attributes can be obtained from the corresponding points with this method.
| |||||||||||
| #define | AiPointCloudGetBool(name, indices, count, attr, out_values) AiPointCloudGetBoolFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetByte(name, indices, count, attr, out_values) AiPointCloudGetByteFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetInt(name, indices, count, attr, out_values) AiPointCloudGetIntFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetUInt(name, indices, count, attr, out_values) AiPointCloudGetUIntFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetFlt(name, indices, count, attr, out_values) AiPointCloudGetFltFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetRGB(name, indices, count, attr, out_values) AiPointCloudGetRGBFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetRGBA(name, indices, count, attr, out_values) AiPointCloudGetRGBAFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetVec(name, indices, count, attr, out_values) AiPointCloudGetVecFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetVec2(name, indices, count, attr, out_values) AiPointCloudGetVec2Func(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetStr(name, indices, count, attr, out_values) AiPointCloudGetStrFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetPtr(name, indices, count, attr, out_values) AiPointCloudGetPtrFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetNode(name, indices, count, attr, out_values) AiPointCloudGetNodeFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetArray(name, indices, count, attr, out_values) AiPointCloudGetArrayFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| #define | AiPointCloudGetMatrix(name, indices, count, attr, out_values) AiPointCloudGetMatrixFunc(sg, name, indices, count, attr, out_values) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetBoolFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, bool *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetByteFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, uint8_t *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetIntFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, int *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetUIntFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, unsigned int *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetFltFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, float *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetRGBFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtRGB *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetRGBAFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtRGBA *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetVecFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtVector *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetVec2Func (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtVector2 *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetStrFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtString *) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetPtrFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, void **) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetNodeFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtNode **) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetArrayFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtArray **) | ||||||||||
| AI_API AI_DEVICE bool | AiPointCloudGetMatrixFunc (const AtShaderGlobals *, AtString, const size_t *, int, AtString, AtMatrix *) | ||||||||||
Various utility functions for shader writers.