ai_shader_util.h
1 /*
2  * Arnold API header file
3  * Copyright (c) 1998-2009 Marcos Fajardo, (c) 2009-2013 Solid Angle SL
4  */
5 
11 #pragma once
12 #include "ai_bbox.h"
13 #include "ai_color.h"
14 #include "ai_vector.h"
15 #include "ai_api.h"
16 #include "ai_shaderglobals.h"
17 
18 // forward declaration
19 struct AtSampler;
20 struct AtNode;
21 
29 #define AI_WORLD_TO_OBJECT 1
30 #define AI_OBJECT_TO_WORLD 2
31 /* \}*/
32 
36 #define AI_WIREFRAME_TRIANGLES 0
37 #define AI_WIREFRAME_POLYGONS 1
38 #define AI_WIREFRAME_PATCHES 2
39 /* \}*/
40 
44 AI_API AtColor AiOcclusion(const AtVector* N, const AtVector* Ng, AtShaderGlobals* sg, float mint, float maxt, float spread, float falloff, const AtSampler* sampler, AtVector* Nbent);
45 AI_API AtColor AiDirectDiffuse(const AtVector* N, AtShaderGlobals* sg);
46 AI_API AtColor AiHairDirectDiffuseCache(const struct AtShaderGlobals* sg);
48 
49 AI_API void AiReflect(const AtVector* I, const AtVector* N, AtVector* R);
50 AI_API void AiReflectSafe(const AtVector* I, const AtVector* N, const AtVector* Ng, AtVector* R);
51 AI_API bool AiRefract(const AtVector* I, const AtVector* N, AtVector* T, float n1, float n2);
52 AI_API float AiFresnelWeight(AtVector N, AtVector Rd, float Krn);
53 AI_API void AiFresnelWeightRGB(const AtVector* N, const AtVector* Rd, const AtColor* Krn, AtColor* Kf);
54 AI_API void AiFaceForward(AtVector* N, AtVector I);
55 AI_API void AiBuildLocalFrameShirley(AtVector* u, AtVector* v, const AtVector* N);
56 AI_API void AiBuildLocalFramePolar(AtVector* u, AtVector* v, const AtVector* N);
57 /* \}*/
58 
75 typedef float (*AtFloatBumpEvaluator)(AtShaderGlobals* sg, void* data);
76 /* \}*/
77 
81 AI_API bool AiShaderGlobalsGetTriangle(const AtShaderGlobals* sg, int key, AtPoint p[3]);
82 AI_API bool AiShaderGlobalsGetVertexNormals(const AtShaderGlobals* sg, int key, AtVector n[3]);
83 AI_API bool AiShaderGlobalsGetVertexUVs(const AtShaderGlobals* sg, AtPoint2 uv[3]);
84 AI_API AtUInt32 AiShaderGlobalsGetPolygon(const AtShaderGlobals* sg, int key, AtPoint* p);
85 AI_API void AiShaderGlobalsGetPositionAtTime(const AtShaderGlobals* sg, float time, AtPoint* P, AtVector* N, AtVector* Ng, AtVector* Ns);
86 AI_API AtPoint2 AiShaderGlobalsGetPixelMotionVector(const AtShaderGlobals* sg, float time0, float time1);
89 AI_API AtVector AiShaderGlobalsTransformNormal(const AtShaderGlobals* sg, AtVector N, int space);
90 AI_API AtPoint AiShaderGlobalsTransformPoint(const AtShaderGlobals* sg, AtPoint P, int space);
91 AI_API AtVector AiShaderGlobalsTransformVector(const AtShaderGlobals* sg, AtVector V, int space);
92 AI_API void AiShaderGlobalsSetTraceSet(AtShaderGlobals* sg, const char* set, bool inclusive);
94 AI_API void* AiShaderGlobalsQuickAlloc(const AtShaderGlobals* sg, AtUInt32 size);
96 AI_API bool AiShaderGlobalsApplyOpacity(AtShaderGlobals* sg, AtRGB opacity);
97 AI_API float AiShaderGlobalsEdgeLength(const AtShaderGlobals* sg);
98 AI_API float AiWireframe(const AtShaderGlobals* sg, float line_width, bool raster_space, int edge_type);
99 
109 inline void AiFaceViewer(const AtShaderGlobals* sg, AtVector& n)
110 {
111  n = (AiV3Dot(sg->Ng, sg->Rd) > 0.0f) ? -sg->N : sg->N;
112 }
113 
114 /* \}*/
115 
119 AI_API float AiCameraGetShutterStart();
120 AI_API float AiCameraGetShutterEnd();
121 AI_API void AiCameraToWorldMatrix(const AtNode* node, float time, AtMatrix out);
122 AI_API void AiWorldToCameraMatrix(const AtNode* node, float time, AtMatrix out);
123 AI_API void AiWorldToScreenMatrix(const AtNode* node, float time, AtMatrix out);
124 /* \}*/
125 
129 AI_API void AiMappingMirroredBall(const AtVector* dir, float* u, float* v);
130 AI_API void AiMappingAngularMap (const AtVector* dir, float* u, float* v);
131 AI_API void AiMappingLatLong (const AtVector* dir, float* u, float* v);
132 AI_API void AiMappingCubicMap (const AtVector* dir, float* u, float* v);
133 /* \}*/
134 
138 AI_API void AiMappingMirroredBallDerivs(const AtVector* dir, const AtVector* dDdx, const AtVector* dDdy, float* u, float* v, float* dudx, float* dudy, float* dvdx, float* dvdy);
139 AI_API void AiMappingAngularMapDerivs (const AtVector* dir, const AtVector* dDdx, const AtVector* dDdy, float* u, float* v, float* dudx, float* dudy, float* dvdx, float* dvdy);
140 AI_API void AiMappingLatLongDerivs (const AtVector* dir, const AtVector* dDdx, const AtVector* dDdy, float* u, float* v, float* dudx, float* dudy, float* dvdx, float* dvdy);
141 AI_API void AiMappingCubicMapDerivs (const AtVector* dir, const AtVector* dDdx, const AtVector* dDdy, float* u, float* v, float* dudx, float* dudy, float* dvdx, float* dvdy);
142 /* \}*/
143 
144 /*\}*/

© 2009-2013 Solid Angle SL · all rights reserved · www.solidangle.com