PageRenderTime 98ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/cocos3d/cocos3d/Shaders/CC3ShaderSemantics.m

https://github.com/SandraGuzman/cocos3d
Objective C | 1739 lines | 1405 code | 180 blank | 154 comment | 74 complexity | cdf98d8faeea0cf87577a72ea094f72b MD5 | raw file
  1. /*
  2. * CC3ShaderSemantics.m
  3. *
  4. * cocos3d 2.0.0
  5. * Author: Bill Hollings
  6. * Copyright (c) 2011-2014 The Brenwill Workshop Ltd. All rights reserved.
  7. * http://www.brenwill.com
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. * http://en.wikipedia.org/wiki/MIT_License
  28. *
  29. * See header file CC3ShaderSemantics.h for full API documentation.
  30. */
  31. #import "CC3ShaderSemantics.h"
  32. #import "CC3GLSLVariable.h"
  33. #import "CC3NodeVisitor.h"
  34. #import "CC3MeshNode.h"
  35. #import "CC3Camera.h"
  36. #import "CC3Light.h"
  37. #import "CC3Scene.h"
  38. #import "CC3PointParticles.h"
  39. #import "CC3NodeAnimation.h"
  40. #import "CC3VertexSkinning.h"
  41. #import "CC3OpenGL.h"
  42. NSString* NSStringFromCC3Semantic(CC3Semantic semantic) {
  43. switch (semantic) {
  44. case kCC3SemanticNone: return @"kCC3SemanticNone";
  45. // VERTEX CONTENT --------------
  46. case kCC3SemanticVertexLocation: return @"kCC3SemanticVertexLocation";
  47. case kCC3SemanticVertexNormal: return @"kCC3SemanticVertexNormal";
  48. case kCC3SemanticVertexTangent: return @"kCC3SemanticVertexTangent";
  49. case kCC3SemanticVertexBitangent: return @"kCC3SemanticVertexBitangent";
  50. case kCC3SemanticVertexColor: return @"kCC3SemanticVertexColor";
  51. case kCC3SemanticVertexPointSize: return @"kCC3SemanticVertexPointSize";
  52. case kCC3SemanticVertexBoneWeights: return @"kCC3SemanticVertexBoneWeights";
  53. case kCC3SemanticVertexBoneIndices: return @"kCC3SemanticVertexBoneIndices";
  54. case kCC3SemanticVertexTexture: return @"kCC3SemanticVertexTexture";
  55. case kCC3SemanticHasVertexNormal: return @"kCC3SemanticHasVertexNormal";
  56. case kCC3SemanticShouldNormalizeVertexNormal: return @"kCC3SemanticShouldNormalizeVertexNormal";
  57. case kCC3SemanticShouldRescaleVertexNormal: return @"kCC3SemanticShouldRescaleVertexNormal";
  58. case kCC3SemanticHasVertexTangent: return @"kCC3SemanticHasVertexTangent";
  59. case kCC3SemanticHasVertexBitangent: return @"kCC3SemanticHasVertexBitangent";
  60. case kCC3SemanticHasVertexColor: return @"kCC3SemanticHasVertexColor";
  61. case kCC3SemanticHasVertexWeight: return @"kCC3SemanticHasVertexWeight";
  62. case kCC3SemanticHasVertexMatrixIndex: return @"kCC3SemanticHasVertexMatrixIndex";
  63. case kCC3SemanticHasVertexTextureCoordinate: return @"kCC3SemanticHasVertexTextureCoordinate";
  64. case kCC3SemanticHasVertexPointSize: return @"kCC3SemanticHasVertexPointSize";
  65. case kCC3SemanticIsDrawingPoints: return @"kCC3SemanticIsDrawingPoints";
  66. case kCC3SemanticShouldDrawFrontFaces: return @"kCC3SemanticShouldDrawFrontFaces";
  67. case kCC3SemanticShouldDrawBackFaces: return @"kCC3SemanticShouldDrawBackFaces";
  68. // ENVIRONMENT MATRICES --------------
  69. case kCC3SemanticModelLocalMatrix: return @"kCC3SemanticModelLocalMatrix";
  70. case kCC3SemanticModelLocalMatrixInv: return @"kCC3SemanticModelLocalMatrixInv";
  71. case kCC3SemanticModelLocalMatrixInvTran: return @"kCC3SemanticModelLocalMatrixInvTran";
  72. case kCC3SemanticModelMatrix: return @"kCC3SemanticModelMatrix";
  73. case kCC3SemanticModelMatrixInv: return @"kCC3SemanticModelMatrixInv";
  74. case kCC3SemanticModelMatrixInvTran: return @"kCC3SemanticModelMatrixInvTran";
  75. case kCC3SemanticViewMatrix: return @"kCC3SemanticViewMatrix";
  76. case kCC3SemanticViewMatrixInv: return @"kCC3SemanticViewMatrixInv";
  77. case kCC3SemanticViewMatrixInvTran: return @"kCC3SemanticViewMatrixInvTran";
  78. case kCC3SemanticModelViewMatrix: return @"kCC3SemanticModelViewMatrix";
  79. case kCC3SemanticModelViewMatrixInv: return @"kCC3SemanticModelViewMatrixInv";
  80. case kCC3SemanticModelViewMatrixInvTran: return @"kCC3SemanticModelViewMatrixInvTran";
  81. case kCC3SemanticProjMatrix: return @"kCC3SemanticProjMatrix";
  82. case kCC3SemanticProjMatrixInv: return @"kCC3SemanticProjMatrixInv";
  83. case kCC3SemanticProjMatrixInvTran: return @"kCC3SemanticProjMatrixInvTran";
  84. case kCC3SemanticViewProjMatrix: return @"kCC3SemanticViewProjMatrix";
  85. case kCC3SemanticViewProjMatrixInv: return @"kCC3SemanticViewProjMatrixInv";
  86. case kCC3SemanticViewProjMatrixInvTran: return @"kCC3SemanticViewProjMatrixInvTran";
  87. case kCC3SemanticModelViewProjMatrix: return @"kCC3SemanticModelViewProjMatrix";
  88. case kCC3SemanticModelViewProjMatrixInv: return @"kCC3SemanticModelViewProjMatrixInv";
  89. case kCC3SemanticModelViewProjMatrixInvTran: return @"kCC3SemanticModelViewProjMatrixInvTran";
  90. // CAMERA -----------------
  91. case kCC3SemanticCameraLocationModelSpace: return @"kCC3SemanticCameraLocationModelSpace";
  92. case kCC3SemanticCameraLocationGlobal: return @"kCC3SemanticCameraLocationGlobal";
  93. case kCC3SemanticCameraFrustum: return @"kCC3SemanticCameraFrustum";
  94. case kCC3SemanticCameraFrustumDepth: return @"kCC3SemanticCameraFrustumDepth";
  95. // MATERIALS --------------
  96. case kCC3SemanticColor: return @"kCC3SemanticColor";
  97. case kCC3SemanticMaterialColorAmbient: return @"kCC3SemanticMaterialColorAmbient";
  98. case kCC3SemanticMaterialColorDiffuse: return @"kCC3SemanticMaterialColorDiffuse";
  99. case kCC3SemanticMaterialColorSpecular: return @"kCC3SemanticMaterialColorSpecular";
  100. case kCC3SemanticMaterialColorEmission: return @"kCC3SemanticMaterialColorEmission";
  101. case kCC3SemanticMaterialOpacity: return @"kCC3SemanticMaterialOpacity";
  102. case kCC3SemanticMaterialShininess: return @"kCC3SemanticMaterialShininess";
  103. case kCC3SemanticMaterialReflectivity: return @"kCC3SemanticMaterialReflectivity";
  104. // LIGHTING --------------
  105. case kCC3SemanticIsUsingLighting: return @"kCC3SemanticIsUsingLighting";
  106. case kCC3SemanticSceneLightColorAmbient: return @"kCC3SemanticSceneLightColorAmbient";
  107. case kCC3SemanticLightIsEnabled: return @"kCC3SemanticLightIsEnabled";
  108. case kCC3SemanticLightPositionGlobal: return @"kCC3SemanticLightPositionGlobal";
  109. case kCC3SemanticLightPositionEyeSpace: return @"kCC3SemanticLightPositionEyeSpace";
  110. case kCC3SemanticLightPositionModelSpace: return @"kCC3SemanticLightPositionModelSpace";
  111. case kCC3SemanticLightInvertedPositionGlobal: return @"kCC3SemanticLightInvertedPositionGlobal";
  112. case kCC3SemanticLightInvertedPositionEyeSpace: return @"kCC3SemanticLightInvertedPositionEyeSpace";
  113. case kCC3SemanticLightInvertedPositionModelSpace: return @"kCC3SemanticLightInvertedPositionModelSpace";
  114. case kCC3SemanticLightColorAmbient: return @"kCC3SemanticLightColorAmbient";
  115. case kCC3SemanticLightColorDiffuse: return @"kCC3SemanticLightColorDiffuse";
  116. case kCC3SemanticLightColorSpecular: return @"kCC3SemanticLightColorSpecular";
  117. case kCC3SemanticLightAttenuation: return @"kCC3SemanticLightAttenuation";
  118. case kCC3SemanticLightSpotDirectionGlobal: return @"kCC3SemanticLightSpotDirectionGlobal";
  119. case kCC3SemanticLightSpotDirectionEyeSpace: return @"kCC3SemanticLightSpotDirectionEyeSpace";
  120. case kCC3SemanticLightSpotDirectionModelSpace: return @"kCC3SemanticLightSpotDirectionModelSpace";
  121. case kCC3SemanticLightSpotExponent: return @"kCC3SemanticLightSpotExponent";
  122. case kCC3SemanticLightSpotCutoffAngle: return @"kCC3SemanticLightSpotCutoffAngle";
  123. case kCC3SemanticLightSpotCutoffAngleCosine: return @"kCC3SemanticLightSpotCutoffAngleCosine";
  124. case kCC3SemanticFogIsEnabled: return @"kCC3SemanticFogIsEnabled";
  125. case kCC3SemanticFogColor: return @"kCC3SemanticFogColor";
  126. case kCC3SemanticFogAttenuationMode: return @"kCC3SemanticFogAttenuationMode";
  127. case kCC3SemanticFogDensity: return @"kCC3SemanticFogDensity";
  128. case kCC3SemanticFogStartDistance: return @"kCC3SemanticFogStartDistance";
  129. case kCC3SemanticFogEndDistance: return @"kCC3SemanticFogEndDistance";
  130. // TEXTURES --------------
  131. case kCC3SemanticTextureCount: return @"kCC3SemanticTextureCount";
  132. case kCC3SemanticTextureSampler: return @"kCC3SemanticTextureSampler";
  133. case kCC3SemanticTexture2DCount: return @"kCC3SemanticTexture2DCount";
  134. case kCC3SemanticTexture2DSampler: return @"kCC3SemanticTexture2DSampler";
  135. case kCC3SemanticTextureCubeCount: return @"kCC3SemanticTextureCubeCount";
  136. case kCC3SemanticTextureCubeSampler: return @"kCC3SemanticTextureCubeSampler";
  137. case kCC3SemanticTexUnitMode: return @"kCC3SemanticTexUnitMode";
  138. case kCC3SemanticTexUnitConstantColor: return @"kCC3SemanticTexUnitConstantColor";
  139. case kCC3SemanticTexUnitCombineRGBFunction: return @"kCC3SemanticTexUnitCombineRGBFunction";
  140. case kCC3SemanticTexUnitSource0RGB: return @"kCC3SemanticTexUnitSource0RGB";
  141. case kCC3SemanticTexUnitSource1RGB: return @"kCC3SemanticTexUnitSource1RGB";
  142. case kCC3SemanticTexUnitSource2RGB: return @"kCC3SemanticTexUnitSource2RGB";
  143. case kCC3SemanticTexUnitOperand0RGB: return @"kCC3SemanticTexUnitOperand0RGB";
  144. case kCC3SemanticTexUnitOperand1RGB: return @"kCC3SemanticTexUnitOperand1RGB";
  145. case kCC3SemanticTexUnitOperand2RGB: return @"kCC3SemanticTexUnitOperand2RGB";
  146. case kCC3SemanticTexUnitCombineAlphaFunction: return @"kCC3SemanticTexUnitCombineAlphaFunction";
  147. case kCC3SemanticTexUnitSource0Alpha: return @"kCC3SemanticTexUnitSource0Alpha";
  148. case kCC3SemanticTexUnitSource1Alpha: return @"kCC3SemanticTexUnitSource1Alpha";
  149. case kCC3SemanticTexUnitSource2Alpha: return @"kCC3SemanticTexUnitSource2Alpha";
  150. case kCC3SemanticTexUnitOperand0Alpha: return @"kCC3SemanticTexUnitOperand0Alpha";
  151. case kCC3SemanticTexUnitOperand1Alpha: return @"kCC3SemanticTexUnitOperand1Alpha";
  152. case kCC3SemanticTexUnitOperand2Alpha: return @"kCC3SemanticTexUnitOperand2Alpha";
  153. // MODEL ----------------
  154. case kCC3SemanticAnimationFraction: return @"kCC3SemanticAnimationFraction";
  155. case kCC3SemanticCenterOfGeometry: return @"kCC3SemanticCenterOfGeometry";
  156. case kCC3SemanticBoundingBoxMin: return @"kCC3SemanticBoundingBoxMin";
  157. case kCC3SemanticBoundingBoxMax: return @"kCC3SemanticBoundingBoxMax";
  158. case kCC3SemanticBoundingBoxSize: return @"kCC3SemanticBoundingBoxSize";
  159. case kCC3SemanticBoundingRadius: return @"kCC3SemanticBoundingRadius";
  160. // BONE SKINNING
  161. case kCC3SemanticVertexBoneCount: return @"kCC3SemanticVertexBoneCount";
  162. case kCC3SemanticBatchBoneCount: return @"kCC3SemanticBatchBoneCount";
  163. // BONE SKINNING MATRICES
  164. case kCC3SemanticBoneMatricesGlobal: return @"kCC3SemanticBoneMatricesGlobal";
  165. case kCC3SemanticBoneMatricesInvTranGlobal: return @"kCC3SemanticBoneMatricesInvTranGlobal";
  166. case kCC3SemanticBoneMatricesEyeSpace: return @"kCC3SemanticBoneMatricesEyeSpace";
  167. case kCC3SemanticBoneMatricesInvTranEyeSpace: return @"kCC3SemanticBoneMatricesInvTranEyeSpace";
  168. case kCC3SemanticBoneMatricesModelSpace: return @"kCC3SemanticBoneMatricesModelSpace";
  169. case kCC3SemanticBoneMatricesInvTranModelSpace: return @"kCC3SemanticBoneMatricesInvTranModelSpace";
  170. // BONE SKINNING DISCRETE TRANSFORMS
  171. case kCC3SemanticBoneQuaternionsGlobal: return @"kCC3SemanticBoneQuaternionsGlobal";
  172. case kCC3SemanticBoneTranslationsGlobal: return @"kCC3SemanticBoneTranslationsGlobal";
  173. case kCC3SemanticBoneScalesGlobal: return @"kCC3SemanticBoneScalesGlobal";
  174. case kCC3SemanticBoneQuaternionsEyeSpace: return @"kCC3SemanticBoneQuaternionsEyeSpace";
  175. case kCC3SemanticBoneTranslationsEyeSpace: return @"kCC3SemanticBoneTranslationsEyeSpace";
  176. case kCC3SemanticBoneScalesEyeSpace: return @"kCC3SemanticBoneScalesEyeSpace";
  177. case kCC3SemanticBoneQuaternionsModelSpace: return @"kCC3SemanticBoneQuaternionsModelSpace";
  178. case kCC3SemanticBoneTranslationsModelSpace: return @"kCC3SemanticBoneTranslationsModelSpace";
  179. case kCC3SemanticBoneScalesModelSpace: return @"kCC3SemanticBoneScalesModelSpace";
  180. // PARTICLES ------------
  181. case kCC3SemanticPointSize: return @"kCC3SemanticPointSize";
  182. case kCC3SemanticPointSizeAttenuation: return @"kCC3SemanticPointSizeAttenuation";
  183. case kCC3SemanticPointSizeMinimum: return @"kCC3SemanticPointSizeMinimum";
  184. case kCC3SemanticPointSizeMaximum: return @"kCC3SemanticPointSizeMaximum";
  185. case kCC3SemanticPointSpritesIsEnabled: return @"kCC3SemanticPointSpritesIsEnabled";
  186. // TIME ------------------
  187. case kCC3SemanticFrameTime: return @"kCC3SemanticFrameTime";
  188. case kCC3SemanticSceneTime: return @"kCC3SemanticSceneTime";
  189. case kCC3SemanticSceneTimeSine: return @"kCC3SemanticSceneTimeSine";
  190. case kCC3SemanticSceneTimeCosine: return @"kCC3SemanticSceneTimeCosine";
  191. case kCC3SemanticSceneTimeTangent: return @"kCC3SemanticSceneTimeTangent";
  192. // MISC ENVIRONMENT ---------
  193. case kCC3SemanticViewport: return @"kCC3SemanticViewport";
  194. case kCC3SemanticDrawCountCurrentFrame: return @"kCC3SemanticDrawCountCurrentFrame";
  195. case kCC3SemanticRandomNumber: return @"kCC3SemanticRandomNumber";
  196. case kCC3SemanticAppBase: return @"kCC3SemanticAppBase";
  197. case kCC3SemanticMax: return @"kCC3SemanticMax";
  198. default: return [NSString stringWithFormat: @"Unknown state semantic (%u)", semantic];
  199. }
  200. }
  201. #pragma mark -
  202. #pragma mark CC3GLSLVariableConfiguration
  203. @implementation CC3GLSLVariableConfiguration
  204. @synthesize name=_name, semantic=_semantic, semanticIndex=_semanticIndex;
  205. -(void) dealloc {
  206. [_name release];
  207. [super dealloc];
  208. }
  209. -(id) init {
  210. if ( (self = [super init]) ) {
  211. _name = nil;
  212. _semantic = kCC3SemanticNone;
  213. _semanticIndex = 0;
  214. }
  215. return self;
  216. }
  217. @end
  218. #pragma mark -
  219. #pragma mark CC3ShaderSemanticsBase
  220. @implementation CC3ShaderSemanticsBase
  221. +(id) semanticsDelegate { return [[[self alloc] init] autorelease]; }
  222. -(NSString*) nameOfSemantic: (GLenum) semantic { return NSStringFromCC3Semantic(semantic); }
  223. -(BOOL) configureVariable: (CC3GLSLVariable*) variable { return NO; }
  224. /**
  225. * Returns a variable scope derived from the specified semantic.
  226. *
  227. * Subclasses that permit application-specific semantics should override this method to
  228. * handle those additional semantics if they should not default to kCC3GLSLVariableScopeNode.
  229. */
  230. -(CC3GLSLVariableScope) variableScopeForSemantic: (GLenum) semantic {
  231. switch (semantic) {
  232. // Draw scope semantics
  233. case kCC3SemanticDrawCountCurrentFrame:
  234. case kCC3SemanticRandomNumber:
  235. case kCC3SemanticBatchBoneCount:
  236. case kCC3SemanticBoneMatricesGlobal:
  237. case kCC3SemanticBoneMatricesInvTranGlobal:
  238. case kCC3SemanticBoneMatricesEyeSpace:
  239. case kCC3SemanticBoneMatricesInvTranEyeSpace:
  240. case kCC3SemanticBoneMatricesModelSpace:
  241. case kCC3SemanticBoneMatricesInvTranModelSpace:
  242. case kCC3SemanticBoneQuaternionsGlobal:
  243. case kCC3SemanticBoneTranslationsGlobal:
  244. case kCC3SemanticBoneScalesGlobal:
  245. case kCC3SemanticBoneQuaternionsEyeSpace:
  246. case kCC3SemanticBoneTranslationsEyeSpace:
  247. case kCC3SemanticBoneScalesEyeSpace:
  248. case kCC3SemanticBoneQuaternionsModelSpace:
  249. case kCC3SemanticBoneTranslationsModelSpace:
  250. case kCC3SemanticBoneScalesModelSpace:
  251. return kCC3GLSLVariableScopeDraw;
  252. // Scene scope semantics
  253. case kCC3SemanticViewMatrix:
  254. case kCC3SemanticViewMatrixInv:
  255. case kCC3SemanticViewMatrixInvTran:
  256. case kCC3SemanticProjMatrix:
  257. case kCC3SemanticProjMatrixInv:
  258. case kCC3SemanticProjMatrixInvTran:
  259. case kCC3SemanticViewProjMatrix:
  260. case kCC3SemanticViewProjMatrixInv:
  261. case kCC3SemanticViewProjMatrixInvTran:
  262. case kCC3SemanticCameraLocationGlobal:
  263. case kCC3SemanticCameraFrustum:
  264. case kCC3SemanticCameraFrustumDepth:
  265. case kCC3SemanticViewport:
  266. case kCC3SemanticSceneLightColorAmbient:
  267. case kCC3SemanticLightIsEnabled:
  268. case kCC3SemanticLightPositionGlobal:
  269. case kCC3SemanticLightPositionEyeSpace:
  270. case kCC3SemanticLightInvertedPositionGlobal:
  271. case kCC3SemanticLightInvertedPositionEyeSpace:
  272. case kCC3SemanticLightColorAmbient:
  273. case kCC3SemanticLightColorDiffuse:
  274. case kCC3SemanticLightColorSpecular:
  275. case kCC3SemanticLightAttenuation:
  276. case kCC3SemanticLightSpotDirectionGlobal:
  277. case kCC3SemanticLightSpotDirectionEyeSpace:
  278. case kCC3SemanticLightSpotExponent:
  279. case kCC3SemanticLightSpotCutoffAngle:
  280. case kCC3SemanticLightSpotCutoffAngleCosine:
  281. case kCC3SemanticFogIsEnabled:
  282. case kCC3SemanticFogColor:
  283. case kCC3SemanticFogAttenuationMode:
  284. case kCC3SemanticFogDensity:
  285. case kCC3SemanticFogStartDistance:
  286. case kCC3SemanticFogEndDistance:
  287. case kCC3SemanticFrameTime:
  288. case kCC3SemanticSceneTime:
  289. case kCC3SemanticSceneTimeSine:
  290. case kCC3SemanticSceneTimeCosine:
  291. case kCC3SemanticSceneTimeTangent:
  292. return kCC3GLSLVariableScopeScene;
  293. // Node scope semantics
  294. default:
  295. return kCC3GLSLVariableScopeNode;
  296. }
  297. }
  298. /**
  299. * For semantics that may have more than one target, such as components of lights, or textures,
  300. * the iteration loops in this method are designed to deal with two situations:
  301. * - If the uniform is declared as an array of single types (eg- an array of floats, bools, or
  302. * vec3's), the uniform semantic index will be zero and the uniform size will be larger than one.
  303. * - If the uniform is declared as a scalar (eg- distinct uniforms for each light, etc), the
  304. * uniform size will be one, but the uniform semantic index can be larger than zero.
  305. */
  306. -(BOOL) populateUniform: (CC3GLSLUniform*) uniform withVisitor: (CC3NodeDrawingVisitor*) visitor {
  307. LogTrace(@"%@ drawing %@ retrieving semantic value for %@", self, visitor.currentNode, uniform.fullDescription);
  308. GLenum semantic = uniform.semantic;
  309. GLuint semanticIndex = uniform.semanticIndex;
  310. GLint uniformSize = uniform.size;
  311. CC3Material* mat;
  312. CC3SkinSection* skin;
  313. CC3PointParticleEmitter* emitter;
  314. CC3Matrix4x4 m4x4;
  315. CC3Matrix4x3 m4x3, mRslt4x3, tfmMtx, *pm4x3;
  316. CC3Matrix3x3 m3x3;
  317. CC3Viewport vp;
  318. CCTime sceneTime;
  319. GLuint boneCnt = 0, tuCnt = 0, texCnt = 0;
  320. BOOL isInverted = NO, isPtEmitter = NO;
  321. switch (semantic) {
  322. #pragma mark Setting attribute semantics
  323. // ATTRIBUTE QUALIFIERS --------------
  324. case kCC3SemanticHasVertexNormal:
  325. [uniform setBoolean: visitor.currentMesh.hasVertexNormals];
  326. return YES;
  327. case kCC3SemanticShouldNormalizeVertexNormal:
  328. [uniform setBoolean: (visitor.currentMeshNode.effectiveNormalScalingMethod == kCC3NormalScalingNormalize)];
  329. return YES;
  330. case kCC3SemanticShouldRescaleVertexNormal:
  331. [uniform setBoolean: (visitor.currentMeshNode.effectiveNormalScalingMethod == kCC3NormalScalingRescale)];
  332. return YES;
  333. case kCC3SemanticHasVertexTangent:
  334. [uniform setBoolean: visitor.currentMesh.hasVertexTangents];
  335. return YES;
  336. case kCC3SemanticHasVertexBitangent:
  337. [uniform setBoolean: visitor.currentMesh.hasVertexBitangents];
  338. return YES;
  339. case kCC3SemanticHasVertexColor:
  340. [uniform setBoolean: visitor.currentMesh.hasVertexColors];
  341. return YES;
  342. case kCC3SemanticHasVertexWeight:
  343. [uniform setBoolean: visitor.currentMesh.hasVertexBoneWeights];
  344. return YES;
  345. case kCC3SemanticHasVertexMatrixIndex:
  346. [uniform setBoolean: visitor.currentMesh.hasVertexBoneIndices];
  347. return YES;
  348. case kCC3SemanticHasVertexTextureCoordinate:
  349. [uniform setBoolean: visitor.currentMesh.hasVertexTextureCoordinates];
  350. return YES;
  351. case kCC3SemanticHasVertexPointSize:
  352. [uniform setBoolean: visitor.currentMesh.hasVertexPointSizes];
  353. return YES;
  354. case kCC3SemanticIsDrawingPoints:
  355. [uniform setBoolean: visitor.currentMeshNode.drawingMode == GL_POINTS];
  356. return YES;
  357. case kCC3SemanticShouldDrawFrontFaces:
  358. [uniform setBoolean: !visitor.currentMeshNode.shouldCullFrontFaces];
  359. return YES;
  360. case kCC3SemanticShouldDrawBackFaces:
  361. [uniform setBoolean: !visitor.currentMeshNode.shouldCullBackFaces];
  362. return YES;
  363. #pragma mark Setting environment matrix semantics
  364. // ENVIRONMENT MATRICES --------------
  365. case kCC3SemanticModelLocalMatrix:
  366. // Get local matrix as P(-1).T where T is node transform P(-1) is inv-xfm of parent
  367. [visitor.currentMeshNode.parent.globalTransformMatrixInverted populateCC3Matrix4x3: &m4x3];
  368. [visitor.currentMeshNode.globalTransformMatrix populateCC3Matrix4x3: &tfmMtx];
  369. CC3Matrix4x3Multiply(&mRslt4x3, &m4x3, &tfmMtx);
  370. [uniform setMatrix4x3: &mRslt4x3];
  371. return YES;
  372. case kCC3SemanticModelLocalMatrixInv:
  373. // Get local matrix as P(-1).T where T is node transform P(-1) is inv-xfm of parent
  374. [visitor.currentMeshNode.parent.globalTransformMatrixInverted populateCC3Matrix4x3: &m4x3];
  375. [visitor.currentMeshNode.globalTransformMatrix populateCC3Matrix4x3: &tfmMtx];
  376. CC3Matrix4x3Multiply(&mRslt4x3, &m4x3, &tfmMtx);
  377. // Now invert
  378. CC3Matrix4x3InvertAdjoint(&mRslt4x3);
  379. [uniform setMatrix4x3: &mRslt4x3];
  380. return YES;
  381. case kCC3SemanticModelLocalMatrixInvTran:
  382. // Get local matrix as P(-1).T where T is node transform P(-1) is inv-xfm of parent
  383. [visitor.currentMeshNode.parent.globalTransformMatrixInverted populateCC3Matrix4x3: &m4x3];
  384. [visitor.currentMeshNode.globalTransformMatrix populateCC3Matrix4x3: &tfmMtx];
  385. CC3Matrix4x3Multiply(&mRslt4x3, &m4x3, &tfmMtx);
  386. CC3Matrix3x3PopulateFrom4x3(&m3x3, &mRslt4x3);
  387. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  388. [uniform setMatrix3x3: &m3x3];
  389. return YES;
  390. case kCC3SemanticModelMatrix:
  391. [uniform setMatrix4x3: visitor.modelMatrix];
  392. return YES;
  393. case kCC3SemanticModelMatrixInv:
  394. CC3Matrix4x3PopulateFrom4x3(&m4x3, visitor.modelMatrix);
  395. CC3Matrix4x3InvertAdjoint(&m4x3);
  396. [uniform setMatrix4x3: &m4x3];
  397. return YES;
  398. case kCC3SemanticModelMatrixInvTran:
  399. CC3Matrix3x3PopulateFrom4x3(&m3x3, visitor.modelMatrix);
  400. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  401. [uniform setMatrix3x3: &m3x3];
  402. return YES;
  403. case kCC3SemanticViewMatrix:
  404. [uniform setMatrix4x3: visitor.viewMatrix];
  405. return YES;
  406. case kCC3SemanticViewMatrixInv:
  407. CC3Matrix4x3PopulateFrom4x3(&m4x3, visitor.viewMatrix);
  408. CC3Matrix4x3InvertAdjoint(&m4x3);
  409. [uniform setMatrix4x3: &m4x3];
  410. return YES;
  411. case kCC3SemanticViewMatrixInvTran:
  412. CC3Matrix3x3PopulateFrom4x3(&m3x3, visitor.viewMatrix);
  413. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  414. [uniform setMatrix3x3: &m3x3];
  415. return YES;
  416. case kCC3SemanticModelViewMatrix:
  417. [uniform setMatrix4x3: visitor.modelViewMatrix];
  418. return YES;
  419. case kCC3SemanticModelViewMatrixInv:
  420. CC3Matrix4x3PopulateFrom4x3(&m4x3, visitor.modelViewMatrix);
  421. CC3Matrix4x3InvertAdjoint(&m4x3);
  422. [uniform setMatrix4x3: &m4x3];
  423. return YES;
  424. case kCC3SemanticModelViewMatrixInvTran:
  425. CC3Matrix3x3PopulateFrom4x3(&m3x3, visitor.modelViewMatrix);
  426. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  427. [uniform setMatrix3x3: &m3x3];
  428. return YES;
  429. case kCC3SemanticProjMatrix:
  430. [uniform setMatrix4x4: visitor.projMatrix];
  431. return YES;
  432. case kCC3SemanticProjMatrixInv:
  433. CC3Matrix4x4PopulateFrom4x4(&m4x4, visitor.projMatrix);
  434. CC3Matrix4x4InvertAdjoint(&m4x4);
  435. [uniform setMatrix4x4: &m4x4];
  436. return YES;
  437. case kCC3SemanticProjMatrixInvTran:
  438. CC3Matrix3x3PopulateFrom4x4(&m3x3, visitor.projMatrix);
  439. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  440. [uniform setMatrix3x3: &m3x3];
  441. return YES;
  442. case kCC3SemanticViewProjMatrix:
  443. [uniform setMatrix4x4: visitor.viewProjMatrix];
  444. return YES;
  445. case kCC3SemanticViewProjMatrixInv:
  446. CC3Matrix4x4PopulateFrom4x4(&m4x4, visitor.viewProjMatrix);
  447. CC3Matrix4x4InvertAdjoint(&m4x4);
  448. [uniform setMatrix4x4: &m4x4];
  449. return YES;
  450. case kCC3SemanticViewProjMatrixInvTran:
  451. CC3Matrix3x3PopulateFrom4x4(&m3x3, visitor.viewProjMatrix);
  452. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  453. [uniform setMatrix3x3: &m3x3];
  454. return YES;
  455. case kCC3SemanticModelViewProjMatrix:
  456. [uniform setMatrix4x4: visitor.modelViewProjMatrix];
  457. return YES;
  458. case kCC3SemanticModelViewProjMatrixInv:
  459. CC3Matrix4x4PopulateFrom4x4(&m4x4, visitor.modelViewProjMatrix);
  460. CC3Matrix4x4InvertAdjoint(&m4x4);
  461. [uniform setMatrix4x4: &m4x4];
  462. return YES;
  463. case kCC3SemanticModelViewProjMatrixInvTran:
  464. CC3Matrix3x3PopulateFrom4x4(&m3x3, visitor.modelViewProjMatrix);
  465. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  466. [uniform setMatrix3x3: &m3x3];
  467. return YES;
  468. #pragma mark Setting skinning semantics
  469. // BONE SKINNING ----------------
  470. case kCC3SemanticVertexBoneCount:
  471. [uniform setInteger: visitor.currentMeshNode.vertexBoneCount];
  472. return YES;
  473. case kCC3SemanticBatchBoneCount:
  474. [uniform setInteger: visitor.currentSkinSection.boneCount];
  475. return YES;
  476. // BONE SKINNING MATRICES ----------------
  477. case kCC3SemanticBoneMatricesGlobal:
  478. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  479. boneCnt = visitor.currentSkinSection.boneCount;
  480. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++)
  481. [uniform setMatrix4x3: [visitor globalBoneMatrixAt: boneIdx] at: boneIdx];
  482. return YES;
  483. case kCC3SemanticBoneMatricesInvTranGlobal:
  484. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  485. boneCnt = visitor.currentSkinSection.boneCount;
  486. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  487. CC3Matrix3x3PopulateFrom4x3(&m3x3, [visitor globalBoneMatrixAt: boneIdx]);
  488. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  489. [uniform setMatrix3x3: &m3x3 at: boneIdx];
  490. }
  491. return YES;
  492. case kCC3SemanticBoneMatricesEyeSpace:
  493. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  494. boneCnt = visitor.currentSkinSection.boneCount;
  495. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++)
  496. [uniform setMatrix4x3: [visitor eyeSpaceBoneMatrixAt: boneIdx] at: boneIdx];
  497. return YES;
  498. case kCC3SemanticBoneMatricesInvTranEyeSpace:
  499. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  500. boneCnt = visitor.currentSkinSection.boneCount;
  501. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  502. CC3Matrix3x3PopulateFrom4x3(&m3x3, [visitor eyeSpaceBoneMatrixAt: boneIdx]);
  503. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  504. [uniform setMatrix3x3: &m3x3 at: boneIdx];
  505. }
  506. return YES;
  507. case kCC3SemanticBoneMatricesModelSpace:
  508. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  509. boneCnt = visitor.currentSkinSection.boneCount;
  510. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++)
  511. [uniform setMatrix4x3: [visitor modelSpaceBoneMatrixAt: boneIdx] at: boneIdx];
  512. return YES;
  513. case kCC3SemanticBoneMatricesInvTranModelSpace:
  514. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  515. boneCnt = visitor.currentSkinSection.boneCount;
  516. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  517. CC3Matrix3x3PopulateFrom4x3(&m3x3, [visitor modelSpaceBoneMatrixAt: boneIdx]);
  518. CC3Matrix3x3InvertAdjointTranspose(&m3x3);
  519. [uniform setMatrix3x3: &m3x3 at: boneIdx];
  520. }
  521. return YES;
  522. // BONE SKINNING DISCRETE TRANSFORMS
  523. case kCC3SemanticBoneQuaternionsGlobal:
  524. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  525. boneCnt = visitor.currentSkinSection.boneCount;
  526. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  527. pm4x3 = [visitor globalBoneMatrixAt: boneIdx];
  528. [uniform setVector4: CC3Matrix4x3ExtractQuaternion(pm4x3) at: boneIdx];
  529. }
  530. return YES;
  531. case kCC3SemanticBoneTranslationsGlobal:
  532. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  533. boneCnt = visitor.currentSkinSection.boneCount;
  534. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  535. pm4x3 = [visitor globalBoneMatrixAt: boneIdx];
  536. [uniform setVector: CC3Matrix4x3ExtractTranslation(pm4x3) at: boneIdx];
  537. }
  538. return YES;
  539. case kCC3SemanticBoneScalesGlobal:
  540. case kCC3SemanticBoneScalesEyeSpace: // Same as global because view matrix is not scaled
  541. skin = visitor.currentSkinSection;
  542. boneCnt = skin.boneCount;
  543. CC3AssertBoneUniformForSkinSection(uniform, skin);
  544. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++)
  545. [uniform setVector: CC3VectorScale(visitor.currentMeshNode.globalScale,
  546. [skin boneAt: boneIdx].skeletalScale)];
  547. return YES;
  548. case kCC3SemanticBoneQuaternionsEyeSpace:
  549. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  550. boneCnt = visitor.currentSkinSection.boneCount;
  551. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  552. pm4x3 = [visitor eyeSpaceBoneMatrixAt: boneIdx];
  553. [uniform setVector4: CC3Matrix4x3ExtractQuaternion(pm4x3) at: boneIdx];
  554. }
  555. return YES;
  556. case kCC3SemanticBoneTranslationsEyeSpace:
  557. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  558. boneCnt = visitor.currentSkinSection.boneCount;
  559. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  560. pm4x3 = [visitor eyeSpaceBoneMatrixAt: boneIdx];
  561. [uniform setVector: CC3Matrix4x3ExtractTranslation(pm4x3) at: boneIdx];
  562. }
  563. return YES;
  564. case kCC3SemanticBoneQuaternionsModelSpace:
  565. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  566. boneCnt = visitor.currentSkinSection.boneCount;
  567. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  568. pm4x3 = [visitor modelSpaceBoneMatrixAt: boneIdx];
  569. [uniform setVector4: CC3Matrix4x3ExtractQuaternion(pm4x3) at: boneIdx];
  570. }
  571. return YES;
  572. case kCC3SemanticBoneTranslationsModelSpace:
  573. CC3AssertBoneUniformForSkinSection(uniform, visitor.currentSkinSection);
  574. boneCnt = visitor.currentSkinSection.boneCount;
  575. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++) {
  576. pm4x3 = [visitor modelSpaceBoneMatrixAt: boneIdx];
  577. [uniform setVector: CC3Matrix4x3ExtractTranslation(pm4x3) at: boneIdx];
  578. }
  579. return YES;
  580. case kCC3SemanticBoneScalesModelSpace:
  581. skin = visitor.currentSkinSection;
  582. boneCnt = skin.boneCount;
  583. CC3AssertBoneUniformForSkinSection(uniform, skin);
  584. for (GLuint boneIdx = 0; boneIdx < boneCnt; boneIdx++)
  585. [uniform setVector: [skin boneAt: boneIdx].skeletalScale];
  586. return YES;
  587. #pragma mark Setting camera semantics
  588. // CAMERA -----------------
  589. case kCC3SemanticCameraLocationGlobal:
  590. [uniform setVector: visitor.camera.globalLocation];
  591. return YES;
  592. case kCC3SemanticCameraLocationModelSpace:
  593. // Transform the global camera location to the local model space
  594. [uniform setVector: [visitor.currentMeshNode.globalTransformMatrixInverted
  595. transformLocation: visitor.camera.globalLocation]];
  596. return YES;
  597. case kCC3SemanticCameraFrustum: {
  598. // Applies the field of view angle to the narrower aspect.
  599. vp = visitor.camera.viewport;
  600. GLfloat aspect = (GLfloat) vp.w / (GLfloat) vp.h;
  601. CC3Camera* cam = visitor.camera;
  602. GLfloat fovWidth, fovHeight;
  603. if (aspect >= 1.0f) { // Landscape
  604. fovHeight = CC3DegToRad(cam.effectiveFieldOfView);
  605. fovWidth = fovHeight * aspect;
  606. } else { // Portrait
  607. fovWidth = CC3DegToRad(cam.effectiveFieldOfView);
  608. fovHeight = fovWidth / aspect;
  609. }
  610. [uniform setVector4: CC3Vector4Make(fovWidth, fovHeight,
  611. cam.nearClippingDistance,
  612. cam.farClippingDistance)];
  613. return YES;
  614. }
  615. case kCC3SemanticCameraFrustumDepth: {
  616. CC3Camera* cam = visitor.camera;
  617. [cam.projectionMatrix populateCC3Matrix4x4: &m4x4];
  618. [uniform setVector4: CC3Vector4Make(cam.farClippingDistance,
  619. cam.nearClippingDistance,
  620. m4x4.c3r3, m4x4.c4r3)];
  621. return YES;
  622. }
  623. case kCC3SemanticViewport:
  624. vp = visitor.camera.viewport;
  625. [uniform setIntVector4: CC3IntVector4Make(vp.x, vp.y, vp.w, vp.h)];
  626. return YES;
  627. #pragma mark Setting material semantics
  628. // MATERIALS --------------
  629. case kCC3SemanticColor:
  630. [uniform setColor4F: visitor.currentColor];
  631. return YES;
  632. case kCC3SemanticMaterialColorAmbient:
  633. [uniform setColor4F: visitor.currentMaterial.effectiveAmbientColor];
  634. return YES;
  635. case kCC3SemanticMaterialColorDiffuse:
  636. [uniform setColor4F: visitor.currentMaterial.effectiveDiffuseColor];
  637. return YES;
  638. case kCC3SemanticMaterialColorSpecular:
  639. [uniform setColor4F: visitor.currentMaterial.effectiveSpecularColor];
  640. return YES;
  641. case kCC3SemanticMaterialColorEmission:
  642. [uniform setColor4F: visitor.currentMaterial.effectiveEmissionColor];
  643. return YES;
  644. case kCC3SemanticMaterialOpacity:
  645. [uniform setFloat: visitor.currentMaterial.effectiveDiffuseColor.a];
  646. return YES;
  647. case kCC3SemanticMaterialShininess:
  648. [uniform setFloat: visitor.currentMaterial.shininess];
  649. return YES;
  650. case kCC3SemanticMaterialReflectivity:
  651. [uniform setFloat: visitor.currentMaterial.reflectivity];
  652. return YES;
  653. case kCC3SemanticMinimumDrawnAlpha:
  654. mat = visitor.currentMaterial;
  655. [uniform setFloat: (mat.shouldDrawLowAlpha ? 0.0f : mat.alphaTestReference)];
  656. return YES;
  657. #pragma mark Setting lighting semantics
  658. // LIGHTING --------------
  659. case kCC3SemanticIsUsingLighting:
  660. [uniform setBoolean: visitor.currentNode.shouldUseLighting];
  661. return YES;
  662. case kCC3SemanticSceneLightColorAmbient:
  663. [uniform setColor4F: visitor.scene.ambientLight];
  664. return YES;
  665. case kCC3SemanticLightIsEnabled:
  666. for (GLuint i = 0; i < uniformSize; i++) {
  667. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  668. [uniform setBoolean: light.visible at: i];
  669. }
  670. return YES;
  671. case kCC3SemanticLightInvertedPositionGlobal:
  672. isInverted = YES;
  673. case kCC3SemanticLightPositionGlobal:
  674. for (GLuint i = 0; i < uniformSize; i++) {
  675. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  676. CC3Vector4 ltPos = light.globalHomogeneousPosition;
  677. if (isInverted) ltPos = CC3Vector4HomogeneousNegate(ltPos);
  678. [uniform setVector4: ltPos at: i];
  679. }
  680. return YES;
  681. case kCC3SemanticLightInvertedPositionEyeSpace:
  682. isInverted = YES;
  683. case kCC3SemanticLightPositionEyeSpace:
  684. for (GLuint i = 0; i < uniformSize; i++) {
  685. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  686. CC3Vector4 ltPos = light.globalHomogeneousPosition;
  687. if (isInverted) ltPos = CC3Vector4HomogeneousNegate(ltPos);
  688. // Transform global position/direction to eye space and normalize if direction
  689. ltPos = CC3Matrix4x3TransformCC3Vector4(visitor.viewMatrix, ltPos);
  690. if (light.isDirectionalOnly) ltPos = CC3Vector4Normalize(ltPos);
  691. [uniform setVector4: ltPos at: i];
  692. }
  693. return YES;
  694. case kCC3SemanticLightInvertedPositionModelSpace:
  695. isInverted = YES;
  696. case kCC3SemanticLightPositionModelSpace:
  697. [visitor.currentMeshNode.globalTransformMatrixInverted populateCC3Matrix4x3: &m4x3];
  698. for (GLuint i = 0; i < uniformSize; i++) {
  699. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  700. CC3Vector4 ltPos = light.globalHomogeneousPosition;
  701. if (isInverted) ltPos = CC3Vector4HomogeneousNegate(ltPos);
  702. // Transform global position/direction to model space and normalize if direction
  703. ltPos = CC3Matrix4x3TransformCC3Vector4(&m4x3, ltPos);
  704. if (light.isDirectionalOnly) ltPos = CC3Vector4Normalize(ltPos);
  705. [uniform setVector4: ltPos at: i];
  706. }
  707. return YES;
  708. case kCC3SemanticLightColorAmbient:
  709. for (GLuint i = 0; i < uniformSize; i++) {
  710. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  711. ccColor4F ltColor = light.visible ? light.ambientColor : kCCC4FBlackTransparent;
  712. [uniform setColor4F: ltColor at: i];
  713. }
  714. return YES;
  715. case kCC3SemanticLightColorDiffuse:
  716. for (GLuint i = 0; i < uniformSize; i++) {
  717. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  718. ccColor4F ltColor = light.visible ? light.diffuseColor : kCCC4FBlackTransparent;
  719. [uniform setColor4F: ltColor at: i];
  720. }
  721. return YES;
  722. case kCC3SemanticLightColorSpecular:
  723. for (GLuint i = 0; i < uniformSize; i++) {
  724. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  725. ccColor4F ltColor = light.visible ? light.specularColor : kCCC4FBlackTransparent;
  726. [uniform setColor4F: ltColor at: i];
  727. }
  728. return YES;
  729. case kCC3SemanticLightAttenuation:
  730. for (GLuint i = 0; i < uniformSize; i++) {
  731. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  732. CC3AttenuationCoefficients ac = CC3AttenuationCoefficientsLegalize(light.attenuation);
  733. [uniform setVector: *(CC3Vector*)&ac at: i];
  734. }
  735. return YES;
  736. case kCC3SemanticLightSpotDirectionGlobal:
  737. for (GLuint i = 0; i < uniformSize; i++) {
  738. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  739. [uniform setVector: light.globalForwardDirection at: i];
  740. }
  741. return YES;
  742. case kCC3SemanticLightSpotDirectionEyeSpace:
  743. for (GLuint i = 0; i < uniformSize; i++) {
  744. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  745. CC3Vector spotDir = light.globalForwardDirection;
  746. // Transform global direction to eye space and normalize
  747. spotDir = CC3Matrix4x3TransformDirection(visitor.viewMatrix, spotDir);
  748. [uniform setVector: CC3VectorNormalize(spotDir) at: i];
  749. }
  750. return YES;
  751. case kCC3SemanticLightSpotDirectionModelSpace:
  752. [visitor.currentMeshNode.globalTransformMatrixInverted populateCC3Matrix4x3: &m4x3];
  753. for (GLuint i = 0; i < uniformSize; i++) {
  754. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  755. CC3Vector spotDir = light.globalForwardDirection;
  756. // Transform global direction to model space and normalize
  757. spotDir = CC3Matrix4x3TransformDirection(&m4x3, spotDir);
  758. [uniform setVector: CC3VectorNormalize(spotDir) at: i];
  759. }
  760. return YES;
  761. case kCC3SemanticLightSpotExponent:
  762. for (GLuint i = 0; i < uniformSize; i++) {
  763. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  764. [uniform setFloat: light.spotExponent at: i];
  765. }
  766. return YES;
  767. case kCC3SemanticLightSpotCutoffAngle:
  768. for (GLuint i = 0; i < uniformSize; i++) {
  769. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  770. [uniform setFloat: light.spotCutoffAngle at: i];
  771. }
  772. return YES;
  773. case kCC3SemanticLightSpotCutoffAngleCosine:
  774. for (GLuint i = 0; i < uniformSize; i++) {
  775. CC3Light* light = [visitor lightAt: (semanticIndex + i)];
  776. [uniform setFloat: cosf(CC3DegToRad(light.spotCutoffAngle)) at: i];
  777. }
  778. return YES;
  779. case kCC3SemanticFogIsEnabled:
  780. [uniform setBoolean: visitor.scene.fog.visible];
  781. return YES;
  782. case kCC3SemanticFogColor:
  783. [uniform setColor4F: visitor.scene.fog.diffuseColor];
  784. return YES;
  785. case kCC3SemanticFogAttenuationMode:
  786. [uniform setInteger: visitor.scene.fog.attenuationMode];
  787. return YES;
  788. case kCC3SemanticFogDensity:
  789. [uniform setFloat: visitor.scene.fog.density];
  790. return YES;
  791. case kCC3SemanticFogStartDistance:
  792. [uniform setFloat: visitor.scene.fog.startDistance];
  793. return YES;
  794. case kCC3SemanticFogEndDistance:
  795. [uniform setFloat: visitor.scene.fog.endDistance];
  796. return YES;
  797. #pragma mark Setting texture semantics
  798. // TEXTURES --------------
  799. case kCC3SemanticTextureCount:
  800. // Count all textures of any type
  801. [uniform setInteger: visitor.textureCount];
  802. return YES;
  803. case kCC3SemanticTextureSampler:
  804. // Samplers that can be any type are simply consecutive texture unit indices
  805. // starting at the semanticIndex of the uniform. Typically, semanticIndex > 0
  806. // and uniformSize > 1 are mutually exclusive.
  807. for (GLuint i = 0; i < uniformSize; i++) [uniform setInteger: (semanticIndex + i) at: i];
  808. return YES;
  809. case kCC3SemanticTexture2DCount:
  810. mat = visitor.currentMaterial;
  811. tuCnt = visitor.textureCount;
  812. // Count just the textures whose sampler semantic is of the correct type
  813. for (GLuint tuIdx = 0; tuIdx < tuCnt; tuIdx++)
  814. if ( [mat textureForTextureUnit: tuIdx].samplerSemantic == kCC3SemanticTexture2DSampler ) texCnt++;
  815. [uniform setInteger: texCnt];
  816. return YES;
  817. case kCC3SemanticTextureCubeCount:
  818. mat = visitor.currentMaterial;
  819. tuCnt = visitor.textureCount;
  820. // Count just the textures whose sampler semantic is of the correct type
  821. for (GLuint tuIdx = 0; tuIdx < tuCnt; tuIdx++)
  822. if ( [mat textureForTextureUnit: tuIdx].samplerSemantic == kCC3SemanticTextureCubeSampler ) texCnt++;
  823. [uniform setInteger: texCnt];
  824. return YES;
  825. case kCC3SemanticTexture2DSampler:
  826. // 2D samplers always come first and are consecutive, so we can simply use consecutive
  827. // texture unit indices starting at the semanticIndex of the uniform. Typically,
  828. // semanticIndex > 0 and uniformSize > 1 are mutually exclusive.
  829. for (GLuint i = 0; i < uniformSize; i++) [uniform setInteger: (semanticIndex + i) at: i];
  830. return YES;
  831. case kCC3SemanticTextureCubeSampler:
  832. // Cube samplers always come after 2D samplers, and are consecutive, so we can simply
  833. // use consecutive texture unit indices starting at the semanticIndex of the uniform,
  834. // plus an offset to skip any 2D textures. Typically, semanticIndex > 0 and
  835. // uniformSize > 1 are mutually exclusive.
  836. semanticIndex += visitor.currentShaderProgram.texture2DCount;
  837. for (GLuint i = 0; i < uniformSize; i++) [uniform setInteger: (semanticIndex + i) at: i];
  838. return YES;
  839. // The semantics below mimic OpenGL ES 1.1 configuration functionality for combining texture units.
  840. // In most shaders, these will be left unused in favor of customized the texture combining in code.
  841. case kCC3SemanticTexUnitMode:
  842. for (GLuint i = 0; i < uniformSize; i++) {
  843. CC3TextureUnit* tu = [visitor currentTextureUnitAt: (semanticIndex + i)];
  844. [uniform setInteger: (tu ? tu.textureEnvironmentMode : GL_MODULATE) at: i];
  845. }
  846. return YES;
  847. case kCC3SemanticTexUnitConstantColor:
  848. for (GLuint i = 0; i < uniformSize; i++) {
  849. CC3TextureUnit* tu = [visitor currentTextureUnitAt: (semanticIndex + i)];
  850. [uniform setColor4F: (tu ? tu.constantColor : kCCC4FBlackTransparent) at: i];
  851. }
  852. return YES;
  853. case kCC3SemanticTexUnitCombineRGBFunction:
  854. for (GLuint i = 0; i < uniformSize; i++) {
  855. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  856. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  857. [uniform setInteger: (isCTU ? ctu.combineRGBFunction : GL_MODULATE) at: i];
  858. }
  859. return YES;
  860. case kCC3SemanticTexUnitSource0RGB:
  861. for (GLuint i = 0; i < uniformSize; i++) {
  862. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  863. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  864. [uniform setInteger: (isCTU ? ctu.rgbSource0 : GL_TEXTURE) at: i];
  865. }
  866. return YES;
  867. case kCC3SemanticTexUnitSource1RGB:
  868. for (GLuint i = 0; i < uniformSize; i++) {
  869. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  870. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  871. [uniform setInteger: (isCTU ? ctu.rgbSource1 : GL_PREVIOUS) at: i];
  872. }
  873. return YES;
  874. case kCC3SemanticTexUnitSource2RGB:
  875. for (GLuint i = 0; i < uniformSize; i++) {
  876. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  877. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  878. [uniform setInteger: (isCTU ? ctu.rgbSource2 : GL_CONSTANT) at: i];
  879. }
  880. return YES;
  881. case kCC3SemanticTexUnitOperand0RGB:
  882. for (GLuint i = 0; i < uniformSize; i++) {
  883. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  884. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  885. [uniform setInteger: (isCTU ? ctu.rgbOperand0 : GL_SRC_COLOR) at: i];
  886. }
  887. return YES;
  888. case kCC3SemanticTexUnitOperand1RGB:
  889. for (GLuint i = 0; i < uniformSize; i++) {
  890. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  891. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  892. [uniform setInteger: (isCTU ? ctu.rgbOperand1 : GL_SRC_COLOR) at: i];
  893. }
  894. return YES;
  895. case kCC3SemanticTexUnitOperand2RGB:
  896. for (GLuint i = 0; i < uniformSize; i++) {
  897. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  898. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  899. [uniform setInteger: (isCTU ? ctu.rgbOperand2 : GL_SRC_ALPHA) at: i];
  900. }
  901. return YES;
  902. case kCC3SemanticTexUnitCombineAlphaFunction:
  903. for (GLuint i = 0; i < uniformSize; i++) {
  904. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  905. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  906. [uniform setInteger: (isCTU ? ctu.combineAlphaFunction : GL_MODULATE) at: i];
  907. }
  908. return YES;
  909. case kCC3SemanticTexUnitSource0Alpha:
  910. for (GLuint i = 0; i < uniformSize; i++) {
  911. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  912. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  913. [uniform setInteger: (isCTU ? ctu.alphaSource0 : GL_TEXTURE) at: i];
  914. }
  915. return YES;
  916. case kCC3SemanticTexUnitSource1Alpha:
  917. for (GLuint i = 0; i < uniformSize; i++) {
  918. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  919. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  920. [uniform setInteger: (isCTU ? ctu.alphaSource1 : GL_PREVIOUS) at: i];
  921. }
  922. return YES;
  923. case kCC3SemanticTexUnitSource2Alpha:
  924. for (GLuint i = 0; i < uniformSize; i++) {
  925. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  926. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  927. [uniform setInteger: (isCTU ? ctu.alphaSource2 : GL_CONSTANT) at: i];
  928. }
  929. return YES;
  930. case kCC3SemanticTexUnitOperand0Alpha:
  931. for (GLuint i = 0; i < uniformSize; i++) {
  932. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  933. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  934. [uniform setInteger: (isCTU ? ctu.alphaOperand0 : GL_SRC_ALPHA) at: i];
  935. }
  936. return YES;
  937. case kCC3SemanticTexUnitOperand1Alpha:
  938. for (GLuint i = 0; i < uniformSize; i++) {
  939. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  940. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  941. [uniform setInteger: (isCTU ? ctu.alphaOperand1 : GL_SRC_ALPHA) at: i];
  942. }
  943. return YES;
  944. case kCC3SemanticTexUnitOperand2Alpha:
  945. for (GLuint i = 0; i < uniformSize; i++) {
  946. CC3ConfigurableTextureUnit* ctu = (CC3ConfigurableTextureUnit*)[visitor currentTextureUnitAt: (semanticIndex + i)];
  947. BOOL isCTU = [ctu isKindOfClass: [CC3ConfigurableTextureUnit class]];
  948. [uniform setInteger: (isCTU ? ctu.alphaOperand2 : GL_SRC_ALPHA) at: i];
  949. }
  950. return YES;
  951. #pragma mark Setting model semantics
  952. // MODEL ----------------
  953. case kCC3SemanticCenterOfGeometry:
  954. [uniform setVector: visitor.currentMeshNode.mesh.centerOfGeometry];
  955. return YES;
  956. case kCC3SemanticBoundingRadius:
  957. [uniform setFloat: visitor.currentMeshNode.mesh.radius];
  958. return YES;
  959. case kCC3SemanticBoundingBoxMin:
  960. [uniform setVector: visitor.currentMeshNode.mesh.boundingBox.minimum];
  961. return YES;
  962. case kCC3SemanticBoundingBoxMax:
  963. [uniform setVector: visitor.currentMeshNode.mesh.boundingBox.maximum];
  964. return YES;
  965. case kCC3SemanticBoundingBoxSize:
  966. [uniform setVector: CC3BoxSize(visitor.currentMeshNode.mesh.boundingBox)];
  967. return YES;
  968. case kCC3SemanticAnimationFraction:
  969. [uniform setFloat: [visitor.currentMeshNode animationTimeOnTrack: 0]];
  970. return YES;
  971. #pragma mark Setting particle semantics
  972. // PARTICLES ------------
  973. case kCC3SemanticPointSize:
  974. emitter = (CC3PointParticleEmitter*)visitor.currentNode;
  975. isPtEmitter = [emitter isKindOfClass: [CC3PointParticleEmitter class]];
  976. [uniform setFloat: (isPtEmitter ? emitter.normalizedParticleSize : 0.0f)];
  977. return YES;
  978. case kCC3SemanticPointSizeAttenuation: {
  979. emitter = (CC3PointParticleEmitter*)visitor.currentNode;
  980. isPtEmitter = [emitter isKindOfClass: [CC3PointParticleEmitter class]];
  981. CC3AttenuationCoefficients ac = (isPtEmitter)
  982. ? CC3AttenuationCoefficientsLegalize(emitter.particleSizeAttenuation)
  983. : kCC3AttenuationNone;
  984. [uniform setVector: *(CC3Vector*)&ac];
  985. return YES;
  986. }
  987. case kCC3SemanticPointSizeMinimum:
  988. emitter = (CC3PointParticleEmitter*)visitor.currentNode;
  989. isPtEmitter = [emitter isKindOfClass: [CC3PointParticleEmitter class]];
  990. [uniform setFloat: (isPtEmitter ? emitter.normalizedParticleSizeMinimum : 0.0f)];
  991. return YES;
  992. case kCC3SemanticPointSizeMaximum:
  993. emitter = (CC3PointParticleEmitter*)visitor.currentNode;
  994. isPtEmitter = [emitter isKindOfClass: [CC3PointParticleEmitter class]];
  995. [uniform setFloat: (isPtEmitter ? emitter.normalizedParticleSizeMaximum : 0.0f)];
  996. return YES;
  997. case kCC3SemanticPointSpritesIsEnabled:
  998. [uniform setBoolean: visitor.currentMeshNode.isDrawingPointSprites];
  999. return YES;
  1000. #pragma mark Setting time semantics
  1001. // TIME ------------------
  1002. case kCC3SemanticFrameTime:
  1003. [uniform setFloat: visitor.deltaTime];
  1004. return YES;
  1005. case kCC3SemanticSceneTime:
  1006. sceneTime = visitor.scene.elapsedTimeSinceOpened;
  1007. [uniform setPoint: ccp(sceneTime, fmodf(sceneTime, 1.0))];
  1008. return YES;
  1009. case kCC3SemanticSceneTimeSine:
  1010. sceneTime = visitor.scene.elapsedTimeSinceOpened;
  1011. [uniform setVector4: CC3Vector4Make(sinf(sceneTime),
  1012. sinf(sceneTime / 2.0f),
  1013. sinf(sceneTime / 4.0f),
  1014. sinf(sceneTime / 8.0f))];
  1015. return YES;
  1016. case kCC3SemanticSceneTimeCosine:
  1017. sceneTime = visitor.scene.elapsedTimeSinceOpened;
  1018. [uniform setVector4: CC3Vector4Make(cosf(sceneTime),
  1019. cosf(sceneTime / 2.0f),
  1020. cosf(sceneTime / 4.0f),
  1021. cosf(sceneTime / 8.0f))];
  1022. return YES;
  1023. case kCC3SemanticSceneTimeTangent:
  1024. sceneTime = visitor.scene.elapsedTimeSinceOpened;
  1025. [uniform setVector4: CC3Vector4Make(tanf(sceneTime),
  1026. tanf(sceneTime / 2.0f),
  1027. tanf(sceneTime / 4.0f),
  1028. tanf(sceneTime / 8.0f))];
  1029. return YES;
  1030. #pragma mark Setting miscellaneous semantics
  1031. // MISC ENVIRONMENT ---------
  1032. case kCC3SemanticDrawCountCurrentFrame:
  1033. [uniform setInteger: CC3GLDraws()];
  1034. return YES;
  1035. case kCC3SemanticRandomNumber:
  1036. [uniform setFloat: CC3RandomFloat()];
  1037. return YES;
  1038. default: return NO;
  1039. }
  1040. }
  1041. @end
  1042. #pragma mark -
  1043. #pragma mark CC3ShaderSemanticsByVarName
  1044. @implementation CC3ShaderSemanticsByVarName
  1045. -(void) dealloc {
  1046. [_varConfigsByName release];
  1047. [super dealloc];
  1048. }
  1049. #pragma mark Allocation and initialization
  1050. -(id) init {
  1051. if ( (self = [super init]) ) {
  1052. _varConfigsByName = [NSMutableDictionary new]; // retained
  1053. }
  1054. return self;
  1055. }
  1056. #pragma mark Variable configuration
  1057. /**
  1058. * Uses the variable name property to look up a configuration and sets the semantic
  1059. * and semanticIndex properties of the specified variable from that configuration.
  1060. */
  1061. -(BOOL) configureVariable: (CC3GLSLVariable*) variable {
  1062. CC3GLSLVariableConfiguration* varConfig = [_varConfigsByName objectForKey: variable.name];
  1063. if (varConfig) {
  1064. variable.semantic = varConfig.semantic;
  1065. variable.semanticIndex = varConfig.semanticIndex;
  1066. variable.scope = [self variableScopeForSemantic: varConfig.semantic];
  1067. return YES;
  1068. }
  1069. return NO;
  1070. }
  1071. -(void) addVariableConfiguration: (CC3GLSLVariableConfiguration*) varConfig {
  1072. [_varConfigsByName setObject: varConfig forKey: varConfig.name];
  1073. }
  1074. -(void) mapVarName: (NSString*) name toSemantic: (GLenum) semantic at: (GLuint) semanticIndex {
  1075. CC3GLSLVariableConfiguration* varConfig = [CC3GLSLVariableConfiguration new];
  1076. varConfig.name = name;
  1077. varConfig.semantic = semantic;
  1078. varConfig.semanticIndex = semanticIndex;
  1079. [self addVariableConfiguration: varConfig];
  1080. [varConfig release];
  1081. }
  1082. -(void) mapVarName: (NSString*) name toSemantic: (GLenum) semantic {
  1083. [self mapVarName: name toSemantic: semantic at: 0];
  1084. }
  1085. @end
  1086. #pragma mark -
  1087. #pragma mark CC3ShaderSemanticsByVarName default mappings extension
  1088. @implementation CC3ShaderSemanticsByVarName (DefaultMappings)
  1089. -(void) populateWithDefaultVariableNameMappings {
  1090. // VETEX ATTRIBUTES --------------
  1091. [self mapVarName: @"a_cc3Position" toSemantic: kCC3SemanticVertexLocation]; /**< Vertex location. */
  1092. [self mapVarName: @"a_cc3Normal" toSemantic: kCC3SemanticVertexNormal]; /**< Vertex normal. */
  1093. [self mapVarName: @"a_cc3Tangent" toSemantic: kCC3SemanticVertexTangent]; /**< Vertex tangent. */
  1094. [self mapVarName: @"a_cc3Bitangent" toSemantic: kCC3SemanticVertexBitangent]; /**< Vertex bitangent (aka binormal). */
  1095. [self mapVarName: @"a_cc3Color" toSemantic: kCC3SemanticVertexColor]; /**< Vertex color. */
  1096. [self mapVarName: @"a_cc3BoneWeights" toSemantic: kCC3SemanticVertexBoneWeights]; /**< Vertex skinning bone weights (each an array of length specified by u_cc3VertexBoneCount). */
  1097. [self mapVarName: @"a_cc3BoneIndices" toSemantic: kCC3SemanticVertexBoneIndices]; /**< Vertex skinning bone indices (each an array of length specified by u_cc3VertexBoneCount). */
  1098. [self mapVarName: @"a_cc3PointSize" toSemantic: kCC3SemanticVertexPointSize]; /**< Vertex point size. */
  1099. // If only one texture coordinate attribute is used, the index suffix ("a_cc3TexCoordN") is optional.
  1100. [self mapVarName: @"a_cc3TexCoord" toSemantic: kCC3SemanticVertexTexture]; /**< Vertex texture coordinate for the first texture unit. */
  1101. GLuint maxTexUnits = CC3OpenGL.sharedGL.maxNumberOfTextureUnits;
  1102. for (GLuint tuIdx = 0; tuIdx < maxTexUnits; tuIdx++)
  1103. [self mapVarName: [NSString stringWithFormat: @"a_cc3TexCoord%u", tuIdx] toSemantic: kCC3SemanticVertexTexture at: tuIdx]; /**< Vertex texture coordinate for a texture unit. */
  1104. // VERTEX STATE --------------
  1105. [self mapVarName: @"u_cc3VertexHasNormal" toSemantic: kCC3SemanticHasVertexNormal]; /**< (bool) Whether a vertex normal is available. */
  1106. [self mapVarName: @"u_cc3VertexHasTangent" toSemantic: kCC3SemanticHasVertexTangent]; /**< (bool) Whether a vertex tangent is available. */
  1107. [self mapVarName: @"u_cc3VertexHasBitangent" toSemantic: kCC3SemanticHasVertexBitangent]; /**< (bool) Whether a vertex bitangent is available. */
  1108. [self mapVarName: @"u_cc3VertexHasColor" toSemantic: kCC3SemanticHasVertexColor]; /**< (bool) Whether a vertex color is available. */
  1109. [self mapVarName: @"u_cc3VertexHasWeights" toSemantic: kCC3SemanticHasVertexWeight]; /**< (bool) Whether a vertex weight is available. */
  1110. [self mapVarName: @"u_cc3VertexHasMatrixIndices" toSemantic: kCC3SemanticHasVertexMatrixIndex]; /**< (bool) Whether a vertex matrix index is available. */
  1111. [self mapVarName: @"u_cc3VertexHasTexCoord" toSemantic: kCC3SemanticHasVertexTextureCoordinate]; /**< (bool) Whether a vertex texture coordinate is available. */
  1112. [self mapVarName: @"u_cc3VertexHasPointSize" toSemantic: kCC3SemanticHasVertexPointSize]; /**< (bool) Whether a vertex point size is available. */
  1113. [self mapVarName: @"u_cc3VertexShouldNormalizeNormal" toSemantic: kCC3SemanticShouldNormalizeVertexNormal]; /**< (bool) Whether vertex normals should be normalized. */
  1114. [self mapVarName: @"u_cc3VertexShouldRescaleNormal" toSemantic: kCC3SemanticShouldRescaleVertexNormal]; /**< (bool) Whether vertex normals should be rescaled. */
  1115. [self mapVarName: @"u_cc3VertexShouldDrawFrontFaces" toSemantic: kCC3SemanticShouldDrawFrontFaces]; /**< (bool) Whether the front side of each face is to be drawn. */
  1116. [self mapVarName: @"u_cc3VertexShouldDrawBackFaces" toSemantic: kCC3SemanticShouldDrawBackFaces]; /**< (bool) Whether the back side of each face is to be drawn. */
  1117. // ENVIRONMENT MATRICES --------------
  1118. [self mapVarName: @"u_cc3MatrixModelLocal" toSemantic: kCC3SemanticModelLocalMatrix]; /**< (mat4) Current model-to-parent matrix. */
  1119. [self mapVarName: @"u_cc3MatrixModelLocalInv" toSemantic: kCC3SemanticModelLocalMatrixInv]; /**< (mat4) Inverse of current model-to-parent matrix. */
  1120. [self mapVarName: @"u_cc3MatrixModelLocalInvTran" toSemantic: kCC3SemanticModelLocalMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-parent matrix. */
  1121. [self mapVarName: @"u_cc3MatrixModel" toSemantic: kCC3SemanticModelMatrix]; /**< (mat4) Current model-to-world matrix. */
  1122. [self mapVarName: @"u_cc3MatrixModelInv" toSemantic: kCC3SemanticModelMatrixInv]; /**< (mat4) Inverse of current model-to-world matrix. */
  1123. [self mapVarName: @"u_cc3MatrixModelInvTran" toSemantic: kCC3SemanticModelMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-world matrix. */
  1124. [self mapVarName: @"u_cc3MatrixView" toSemantic: kCC3SemanticViewMatrix]; /**< (mat4) Camera view matrix. */
  1125. [self mapVarName: @"u_cc3MatrixViewInv" toSemantic: kCC3SemanticViewMatrixInv]; /**< (mat4) Inverse of camera view matrix. */
  1126. [self mapVarName: @"u_cc3MatrixViewInvTran" toSemantic: kCC3SemanticViewMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view matrix. */
  1127. [self mapVarName: @"u_cc3MatrixModelView" toSemantic: kCC3SemanticModelViewMatrix]; /**< (mat4) Current model-view matrix. */
  1128. [self mapVarName: @"u_cc3MatrixModelViewInv" toSemantic: kCC3SemanticModelViewMatrixInv]; /**< (mat4) Inverse of current model-view matrix. */
  1129. [self mapVarName: @"u_cc3MatrixModelViewInvTran" toSemantic: kCC3SemanticModelViewMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-view matrix. */
  1130. [self mapVarName: @"u_cc3MatrixProj" toSemantic: kCC3SemanticProjMatrix]; /**< (mat4) Camera projection matrix. */
  1131. [self mapVarName: @"u_cc3MatrixProjInv" toSemantic: kCC3SemanticProjMatrixInv]; /**< (mat4) Inverse of camera projection matrix. */
  1132. [self mapVarName: @"u_cc3MatrixProjInvTran" toSemantic: kCC3SemanticProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera projection matrix. */
  1133. [self mapVarName: @"u_cc3MatrixViewProj" toSemantic: kCC3SemanticViewProjMatrix]; /**< (mat4) Camera view and projection matrix. */
  1134. [self mapVarName: @"u_cc3MatrixViewProjInv" toSemantic: kCC3SemanticViewProjMatrixInv]; /**< (mat4) Inverse of camera view and projection matrix. */
  1135. [self mapVarName: @"u_cc3MatrixViewProjInvTran" toSemantic: kCC3SemanticViewProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view and projection matrix. */
  1136. [self mapVarName: @"u_cc3MatrixModelViewProj" toSemantic: kCC3SemanticModelViewProjMatrix]; /**< (mat4) Current model-view-projection matrix. */
  1137. [self mapVarName: @"u_cc3MatrixModelViewProjInv" toSemantic: kCC3SemanticModelViewProjMatrixInv]; /**< (mat4) Inverse of current model-view-projection matrix. */
  1138. [self mapVarName: @"u_cc3MatrixModelViewProjInvTran" toSemantic: kCC3SemanticModelViewProjMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-view-projection matrix. */
  1139. // BONE SKINNING ----------------
  1140. [self mapVarName: @"u_cc3VertexBoneCount" toSemantic: kCC3SemanticVertexBoneCount]; /**< (int) Number of bones influencing each vertex (ie- number of bone-weights & bone-indices specified on each vertex) */
  1141. [self mapVarName: @"u_cc3BatchBoneCount" toSemantic: kCC3SemanticBatchBoneCount]; /**< (int) Number of bones that are being used by the current skin section. */
  1142. // BONE SKINNING MATRICES ----------------
  1143. [self mapVarName: @"u_cc3BoneMatricesGlobal" toSemantic: kCC3SemanticBoneMatricesGlobal]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in global coordinates (length of array is specified by u_cc3BatchBoneCount). */
  1144. [self mapVarName: @"u_cc3BoneMatricesInvTranGlobal" toSemantic: kCC3SemanticBoneMatricesInvTranGlobal]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in global coordinates (length of array is specified by u_cc3BatchBoneCount). */
  1145. [self mapVarName: @"u_cc3BoneMatricesEyeSpace" toSemantic: kCC3SemanticBoneMatricesEyeSpace]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in eye space (length of array is specified by u_cc3BatchBoneCount). */
  1146. [self mapVarName: @"u_cc3BoneMatricesInvTranEyeSpace" toSemantic: kCC3SemanticBoneMatricesInvTranEyeSpace]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in eye space (length of array is specified by u_cc3BatchBoneCount). */
  1147. [self mapVarName: @"u_cc3BoneMatricesModel" toSemantic: kCC3SemanticBoneMatricesModelSpace]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in model space (length of array is specified by u_cc3BatchBoneCount). */
  1148. [self mapVarName: @"u_cc3BoneMatricesInvTranModel" toSemantic: kCC3SemanticBoneMatricesInvTranModelSpace]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in model space (length of array is specified by u_cc3BatchBoneCount). */
  1149. // BONE SKINNING DISCRETE TRANSFORMS
  1150. [self mapVarName: @"u_cc3BoneQuaternionsGlobal" toSemantic: kCC3SemanticBoneQuaternionsGlobal]; /**< (vec4[]) Array of bone quaternions in the current mesh skin section in global coordinates (length of array is specified by u_cc3BatchBoneCount). */
  1151. [self mapVarName: @"u_cc3BoneTranslationsGlobal" toSemantic: kCC3SemanticBoneTranslationsGlobal]; /**< (vec3[]) Array of bone translations in the current mesh skin section in global coordinates (length of array is specified by u_cc3BatchBoneCount). */
  1152. [self mapVarName: @"u_cc3BoneScalesGlobal" toSemantic: kCC3SemanticBoneScalesGlobal]; /**< (vec3[]) Array of bone scales in the current mesh skin section in global coordinates (length of array is specified by u_cc3BatchBoneCount). */
  1153. [self mapVarName: @"u_cc3BoneQuaternionsEyeSpace" toSemantic: kCC3SemanticBoneQuaternionsEyeSpace]; /**< (vec4[]) Array of bone quaternions in the current mesh skin section in eye space (length of array is specified by u_cc3BatchBoneCount). */
  1154. [self mapVarName: @"u_cc3BoneTranslationsEyeSpace" toSemantic: kCC3SemanticBoneTranslationsEyeSpace]; /**< (vec3[]) Array of bone translations in the current mesh skin section in eye space (length of array is specified by u_cc3BatchBoneCount). */
  1155. [self mapVarName: @"u_cc3BoneScalesEyeSpace" toSemantic: kCC3SemanticBoneScalesEyeSpace]; /**< (vec3[]) Array of bone scales in the current mesh skin section in eye space (length of array is specified by u_cc3BatchBoneCount). */
  1156. [self mapVarName: @"u_cc3BoneQuaternionsModelSpace" toSemantic: kCC3SemanticBoneQuaternionsModelSpace]; /**< (vec4[]) Array of bone quaternions in the current mesh skin section in model space (length of array is specified by u_cc3BatchBoneCount). */
  1157. [self mapVarName: @"u_cc3BoneTranslationsModelSpace" toSemantic: kCC3SemanticBoneTranslationsModelSpace]; /**< (vec3[]) Array of bone translations in the current mesh skin section in model space (length of array is specified by u_cc3BatchBoneCount). */
  1158. [self mapVarName: @"u_cc3BoneScalesModelSpace" toSemantic: kCC3SemanticBoneScalesModelSpace]; /**< (vec3[]) Array of bone scales in the current mesh skin section in model space (length of array is specified by u_cc3BatchBoneCount). */
  1159. // CAMERA -----------------
  1160. [self mapVarName: @"u_cc3CameraPositionGlobal" toSemantic: kCC3SemanticCameraLocationGlobal]; /**< (vec3) Location of the camera in global coordinates. */
  1161. [self mapVarName: @"u_cc3CameraPositionModel" toSemantic: kCC3SemanticCameraLocationModelSpace]; /**< (vec3) Location of the camera in local coordinates of model (not camera). */
  1162. [self mapVarName: @"u_cc3CameraFrustum" toSemantic: kCC3SemanticCameraFrustum]; /**< (vec4) Dimensions of the camera frustum (FOV width (radians), FOV height (radians), near clip, far clip). */
  1163. [self mapVarName: @"u_cc3CameraFrustumDepth" toSemantic: kCC3SemanticCameraFrustumDepth]; /**< (vec4) The depth of the camera frustum (far clip, near clip, -(f+n)/(f-n), -2nf/(f-n)). */
  1164. [self mapVarName: @"u_cc3CameraViewport" toSemantic: kCC3SemanticViewport]; /**< (int4) The viewport rectangle in pixels (x, y, width, height). */
  1165. // MATERIALS --------------
  1166. [self mapVarName: @"u_cc3Color" toSemantic: kCC3SemanticColor]; /**< (vec4) Color when lighting & materials are not in use. */
  1167. [self mapVarName: @"u_cc3MaterialAmbientColor" toSemantic: kCC3SemanticMaterialColorAmbient]; /**< (vec4) Ambient color of the material. */
  1168. [self mapVarName: @"u_cc3MaterialDiffuseColor" toSemantic: kCC3SemanticMaterialColorDiffuse]; /**< (vec4) Diffuse color of the material. */
  1169. [self mapVarName: @"u_cc3MaterialSpecularColor" toSemantic: kCC3SemanticMaterialColorSpecular]; /**< (vec4) Specular color of the material. */
  1170. [self mapVarName: @"u_cc3MaterialEmissionColor" toSemantic: kCC3SemanticMaterialColorEmission]; /**< (vec4) Emission color of the material. */
  1171. [self mapVarName: @"u_cc3MaterialOpacity" toSemantic: kCC3SemanticMaterialOpacity]; /**< (float) Opacity of the material. */
  1172. [self mapVarName: @"u_cc3MaterialShininess" toSemantic: kCC3SemanticMaterialShininess]; /**< (float) Shininess of the material (0 <> 128). */
  1173. [self mapVarName: @"u_cc3MaterialReflectivity" toSemantic: kCC3SemanticMaterialReflectivity]; /**< (float) Reflectivity of the material (0 <> 1). */
  1174. [self mapVarName: @"u_cc3MaterialMinimumDrawnAlpha" toSemantic: kCC3SemanticMinimumDrawnAlpha]; /**< (float) Minimum alpha value to be drawn, otherwise will be rendered fully tranparent. */
  1175. // LIGHTING --------------
  1176. [self mapVarName: @"u_cc3LightIsUsingLighting" toSemantic: kCC3SemanticIsUsingLighting]; /**< (bool) Whether any lighting is enabled. */
  1177. [self mapVarName: @"u_cc3LightSceneAmbientLightColor" toSemantic: kCC3SemanticSceneLightColorAmbient]; /**< (vec4) Ambient light color of the scene. */
  1178. // With multiple lights, each element in the following is an array.
  1179. [self mapVarName: @"u_cc3LightIsLightEnabled" toSemantic: kCC3SemanticLightIsEnabled]; /**< (bool[]) Whether each light is enabled. */
  1180. [self mapVarName: @"u_cc3LightPositionEyeSpace" toSemantic: kCC3SemanticLightPositionEyeSpace]; /**< (vec4[]) Location of each light in eye space. */
  1181. [self mapVarName: @"u_cc3LightPositionGlobal" toSemantic: kCC3SemanticLightPositionGlobal]; /**< (vec4[]) Location of each light in global coordinates. */
  1182. [self mapVarName: @"u_cc3LightPositionModel" toSemantic: kCC3SemanticLightPositionModelSpace]; /**< (vec4[]) Location of each light in local coordinates of model (not light). */
  1183. [self mapVarName: @"u_cc3LightAmbientColor" toSemantic: kCC3SemanticLightColorAmbient]; /**< (vec4[]) Ambient color of each light. */
  1184. [self mapVarName: @"u_cc3LightDiffuseColor" toSemantic: kCC3SemanticLightColorDiffuse]; /**< (vec4[]) Diffuse color of each light. */
  1185. [self mapVarName: @"u_cc3LightSpecularColor" toSemantic: kCC3SemanticLightColorSpecular]; /**< (vec4[]) Specular color of each light. */
  1186. [self mapVarName: @"u_cc3LightAttenuation" toSemantic: kCC3SemanticLightAttenuation]; /**< (vec3[]) Distance attenuation coefficients for each light. */
  1187. [self mapVarName: @"u_cc3LightSpotDirectionEyeSpace" toSemantic: kCC3SemanticLightSpotDirectionEyeSpace]; /**< (vec3[]) Direction of each spotlight in eye space. */
  1188. [self mapVarName: @"u_cc3LightSpotDirectionGlobal" toSemantic: kCC3SemanticLightSpotDirectionGlobal]; /**< (vec3[]) Direction of each spotlight in global coordinates. */
  1189. [self mapVarName: @"u_cc3LightSpotDirectionModel" toSemantic: kCC3SemanticLightSpotDirectionModelSpace]; /**< (vec3[]) Direction of each spotlight in local coordinates of the model (not light). */
  1190. [self mapVarName: @"u_cc3LightSpotExponent" toSemantic: kCC3SemanticLightSpotExponent]; /**< (float[]) Fade-off exponent of each spotlight. */
  1191. [self mapVarName: @"u_cc3LightSpotCutoffAngle" toSemantic: kCC3SemanticLightSpotCutoffAngle]; /**< (float[]) Cutoff angle of each spotlight (degrees). */
  1192. [self mapVarName: @"u_cc3LightSpotCutoffAngleCosine" toSemantic: kCC3SemanticLightSpotCutoffAngleCosine]; /**< (float[]) Cosine of cutoff angle of each spotlight. */
  1193. [self mapVarName: @"u_cc3FogIsEnabled" toSemantic: kCC3SemanticFogIsEnabled]; /**< (bool) Whether scene fogging is enabled. */
  1194. [self mapVarName: @"u_cc3FogColor" toSemantic: kCC3SemanticFogColor]; /**< (vec4) Fog color. */
  1195. [self mapVarName: @"u_cc3FogAttenuationMode" toSemantic: kCC3SemanticFogAttenuationMode]; /**< (int) Fog attenuation mode (one of GL_LINEAR, GL_EXP or GL_EXP2). */
  1196. [self mapVarName: @"u_cc3FogDensity" toSemantic: kCC3SemanticFogDensity]; /**< (float) Fog density. */
  1197. [self mapVarName: @"u_cc3FogStartDistance" toSemantic: kCC3SemanticFogStartDistance]; /**< (float) Distance from camera at which fogging effect starts. */
  1198. [self mapVarName: @"u_cc3FogEndDistance" toSemantic: kCC3SemanticFogEndDistance]; /**< (float) Distance from camera at which fogging effect ends. */
  1199. // TEXTURES --------------
  1200. [self mapVarName: @"u_cc3TextureCount" toSemantic: kCC3SemanticTextureCount]; /**< (int) Number of active textures of any type. */
  1201. [self mapVarName: @"s_cc3Texture" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D/sampler3D) Single texture sampler of any type. */
  1202. [self mapVarName: @"s_cc3Textures" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D[]/sampler3D) Array of texture samplers of any single type. */
  1203. [self mapVarName: @"u_cc3Texture2DCount" toSemantic: kCC3SemanticTexture2DCount]; /**< (int) Number of active textures of all types. */
  1204. [self mapVarName: @"s_cc3Texture2D" toSemantic: kCC3SemanticTexture2DSampler]; /**< (sampler2D) Single 2D texture sampler. */
  1205. [self mapVarName: @"s_cc3Texture2Ds" toSemantic: kCC3SemanticTexture2DSampler]; /**< (sampler2D[]) Array of 2D texture samplers. */
  1206. [self mapVarName: @"u_cc3TextureCubeCount" toSemantic: kCC3SemanticTextureCubeCount]; /**< (int) Number of active textures of all types. */
  1207. [self mapVarName: @"s_cc3TextureCube" toSemantic: kCC3SemanticTextureCubeSampler]; /**< (samplerCube) Single cube texture sampler. */
  1208. [self mapVarName: @"s_cc3TextureCubes" toSemantic: kCC3SemanticTextureCubeSampler]; /**< (samplerCube[]) Array of cube texture samplers. */
  1209. // The semantics below mimic OpenGL ES 1.1 configuration functionality for combining texture units.
  1210. // In most shaders, these will be left unused in favor of customized the texture combining in GLSL code.
  1211. [self mapVarName: @"u_cc3TextureUnitColor" toSemantic: kCC3SemanticTexUnitConstantColor]; /**< (vec4[]) The constant color of each texture unit. */
  1212. [self mapVarName: @"u_cc3TextureUnitMode" toSemantic: kCC3SemanticTexUnitMode]; /**< (int[]) Environment mode of each texture unit. */
  1213. [self mapVarName: @"u_cc3TextureUnitCombineRGBFunction" toSemantic: kCC3SemanticTexUnitCombineRGBFunction]; /**< (int[]) RBG combiner function of each texture unit. */
  1214. [self mapVarName: @"u_cc3TextureUnitRGBSource0" toSemantic: kCC3SemanticTexUnitSource0RGB]; /**< (int[]) The RGB of source 0 of each texture unit. */
  1215. [self mapVarName: @"u_cc3TextureUnitRGBSource1" toSemantic: kCC3SemanticTexUnitSource1RGB]; /**< (int[]) The RGB of source 1 of each texture unit. */
  1216. [self mapVarName: @"u_cc3TextureUnitRGBSource2" toSemantic: kCC3SemanticTexUnitSource2RGB]; /**< (int[]) The RGB of source 2 of each texture unit. */
  1217. [self mapVarName: @"u_cc3TextureUnitRGBOperand0" toSemantic: kCC3SemanticTexUnitOperand0RGB]; /**< (int[]) The RGB combining operand of source 0 of each texture unit. */
  1218. [self mapVarName: @"u_cc3TextureUnitRGBOperand1" toSemantic: kCC3SemanticTexUnitOperand1RGB]; /**< (int[]) The RGB combining operand of source 1 of each texture unit. */
  1219. [self mapVarName: @"u_cc3TextureUnitRGBOperand2" toSemantic: kCC3SemanticTexUnitOperand2RGB]; /**< (int[]) The RGB combining operand of source 2 of each texture unit. */
  1220. [self mapVarName: @"u_cc3TextureUnitCombineAlphaFunction" toSemantic: kCC3SemanticTexUnitCombineAlphaFunction]; /**< (int[]) Alpha combiner function of each texture unit. */
  1221. [self mapVarName: @"u_cc3TextureUnitAlphaSource0" toSemantic: kCC3SemanticTexUnitSource0Alpha]; /**< (int[]) The alpha of source 0 of each texture unit. */
  1222. [self mapVarName: @"u_cc3TextureUnitAlphaSource1" toSemantic: kCC3SemanticTexUnitSource1Alpha]; /**< (int[]) The alpha of source 1 of each texture unit. */
  1223. [self mapVarName: @"u_cc3TextureUnitAlphaSource2" toSemantic: kCC3SemanticTexUnitSource2Alpha]; /**< (int[]) The alpha of source 2 of each texture unit. */
  1224. [self mapVarName: @"u_cc3TextureUnitAlphaOperand0" toSemantic: kCC3SemanticTexUnitOperand0Alpha]; /**< (int[]) The alpha combining operand of source 0 of each texture unit. */
  1225. [self mapVarName: @"u_cc3TextureUnitAlphaOperand1" toSemantic: kCC3SemanticTexUnitOperand1Alpha]; /**< (int[]) The alpha combining operand of source 1 of each texture unit. */
  1226. [self mapVarName: @"u_cc3TextureUnitAlphaOperand2" toSemantic: kCC3SemanticTexUnitOperand2Alpha]; /**< (int[]) The alpha combining operand of source 2 of each texture unit. */
  1227. // MODEL ----------------
  1228. [self mapVarName: @"u_cc3ModelCenterOfGeometry" toSemantic: kCC3SemanticCenterOfGeometry]; /**< (vec3) The center of geometry of the model in the model's local coordinates. */
  1229. [self mapVarName: @"u_cc3ModelBoundingRadius" toSemantic: kCC3SemanticBoundingRadius]; /**< (float) The radius of a sphere, located at the center of geometry, that encompasses all of the vertices, in the model's local coordinates. */
  1230. [self mapVarName: @"u_cc3ModelBoundingBoxMinimum" toSemantic: kCC3SemanticBoundingBoxMin]; /**< (vec3) The maximum corner of the model's bounding box in the model's local coordinates. */
  1231. [self mapVarName: @"u_cc3ModelBoundingBoxMaximum" toSemantic: kCC3SemanticBoundingBoxMax]; /**< (vec3) The dimensions of the model's bounding box in the model's local coordinates. */
  1232. [self mapVarName: @"u_cc3ModelBoundingBoxSize" toSemantic: kCC3SemanticBoundingBoxSize]; /**< (float) The radius of the model's bounding sphere in the model's local coordinates. */
  1233. [self mapVarName: @"u_cc3ModelAnimationFraction" toSemantic: kCC3SemanticAnimationFraction]; /**< (float) Fraction of the model's animation that has been viewed (range 0-1). */
  1234. // PARTICLES ------------
  1235. [self mapVarName: @"u_cc3IsDrawingPoints" toSemantic: kCC3SemanticIsDrawingPoints]; /**< (bool) Whether the vertices are being drawn as points. */
  1236. [self mapVarName: @"u_cc3PointSize" toSemantic: kCC3SemanticPointSize]; /**< (float) Default size of points, if not specified per-vertex in a vertex attribute array. */
  1237. [self mapVarName: @"u_cc3PointSizeAttenuation" toSemantic: kCC3SemanticPointSizeAttenuation]; /**< (vec3) Point size distance attenuation coefficients. */
  1238. [self mapVarName: @"u_cc3PointMinimumSize" toSemantic: kCC3SemanticPointSizeMinimum]; /**< (float) Minimum size points will be allowed to shrink to. */
  1239. [self mapVarName: @"u_cc3PointMaximumSize" toSemantic: kCC3SemanticPointSizeMaximum]; /**< (float) Maximum size points will be allowed to grow to. */
  1240. [self mapVarName: @"u_cc3PointShouldDisplayAsSprites" toSemantic: kCC3SemanticPointSpritesIsEnabled]; /**< (bool) Whether points should be interpeted as textured sprites. */
  1241. // TIME ------------------
  1242. [self mapVarName: @"u_cc3FrameTime" toSemantic: kCC3SemanticFrameTime]; /**< (float) The time in seconds since the last frame. */
  1243. [self mapVarName: @"u_cc3SceneTime" toSemantic: kCC3SemanticSceneTime]; /**< (vec2) The real time, in seconds, since the scene was opened, and the fractional part of that time (T, fmod(T, 1)). */
  1244. [self mapVarName: @"u_cc3SceneTimeSin" toSemantic: kCC3SemanticSceneTimeSine]; /**< (vec4) Sine of the scene time (sin(T), sin(T/2), sin(T/4), sin(T/8)). */
  1245. [self mapVarName: @"u_cc3SceneTimeCos" toSemantic: kCC3SemanticSceneTimeCosine]; /**< (vec4) Cosine of the scene time (cos(T), cos(T/2), cos(T/4), cos(T/8)). */
  1246. [self mapVarName: @"u_cc3SceneTimeTan" toSemantic: kCC3SemanticSceneTimeTangent]; /**< (vec4) Tangent of the scene time (tan(T), tan(T/2), tan(T/4), tan(T/8)). */
  1247. // MISC ENVIRONMENT --------
  1248. [self mapVarName: @"u_cc3DrawCount" toSemantic: kCC3SemanticDrawCountCurrentFrame]; /**< (int) The number of draw calls so far in this frame. */
  1249. [self mapVarName: @"u_cc3Random" toSemantic: kCC3SemanticRandomNumber]; /**< (float) A random number between 0 and 1. */
  1250. // DEPRECATED ------------------
  1251. [self mapVarName: @"u_cc3BonesPerVertex" toSemantic: kCC3SemanticVertexBoneCount]; /**< @deprecated Replaced with u_cc3VertexBoneCount. */
  1252. [self mapVarName: @"u_cc3BoneCount" toSemantic: kCC3SemanticBatchBoneCount]; /**< @deprecated Replaced with u_cc3BatchBoneCount. */
  1253. [self mapVarName: @"u_cc3BoneMatrixCount" toSemantic: kCC3SemanticBatchBoneCount]; /**< @deprecated Replaced with u_cc3BatchBoneCount. */
  1254. [self mapVarName: @"u_cc3AppTime" toSemantic: kCC3SemanticSceneTime]; /**< @deprecated Use u_cc3SceneTime instead. */
  1255. [self mapVarName: @"u_cc3AppTimeSine" toSemantic: kCC3SemanticSceneTimeSine]; /**< @deprecated Use u_cc3SceneTimeSin instead. */
  1256. [self mapVarName: @"u_cc3AppTimeCosine" toSemantic: kCC3SemanticSceneTimeCosine]; /**< @deprecated Use u_cc3SceneTimeCos instead. */
  1257. [self mapVarName: @"u_cc3AppTimeTangent" toSemantic: kCC3SemanticSceneTimeTangent]; /**< @deprecated Use u_cc3SceneTimeTan instead. */
  1258. }
  1259. -(void) populateWithStructuredVariableNameMappings {
  1260. // VETEX ATTRIBUTES --------------
  1261. [self mapVarName: @"a_cc3Position" toSemantic: kCC3SemanticVertexLocation]; /**< Vertex location. */
  1262. [self mapVarName: @"a_cc3Normal" toSemantic: kCC3SemanticVertexNormal]; /**< Vertex normal. */
  1263. [self mapVarName: @"a_cc3Tangent" toSemantic: kCC3SemanticVertexTangent]; /**< Vertex tangent. */
  1264. [self mapVarName: @"a_cc3Bitangent" toSemantic: kCC3SemanticVertexBitangent]; /**< Vertex bitangent (aka binormal). */
  1265. [self mapVarName: @"a_cc3Color" toSemantic: kCC3SemanticVertexColor]; /**< Vertex color. */
  1266. [self mapVarName: @"a_cc3BoneWeights" toSemantic: kCC3SemanticVertexBoneWeights]; /**< Vertex skinning bone weights (each an array of length specified by u_cc3BonesPerVertex). */
  1267. [self mapVarName: @"a_cc3BoneIndices" toSemantic: kCC3SemanticVertexBoneIndices]; /**< Vertex skinning bone indices (each an array of length specified by u_cc3BonesPerVertex). */
  1268. [self mapVarName: @"a_cc3PointSize" toSemantic: kCC3SemanticVertexPointSize]; /**< Vertex point size. */
  1269. // If only one texture coordinate attribute is used, the index suffix ("a_cc3TexCoordN") is optional.
  1270. [self mapVarName: @"a_cc3TexCoord" toSemantic: kCC3SemanticVertexTexture]; /**< Vertex texture coordinate for the first texture unit. */
  1271. GLuint maxTexUnits = CC3OpenGL.sharedGL.maxNumberOfTextureUnits;
  1272. for (GLuint tuIdx = 0; tuIdx < maxTexUnits; tuIdx++)
  1273. [self mapVarName: [NSString stringWithFormat: @"a_cc3TexCoord%u", tuIdx] toSemantic: kCC3SemanticVertexTexture at: tuIdx]; /**< Vertex texture coordinate for a texture unit. */
  1274. // VERTEX STATE --------------
  1275. [self mapVarName: @"u_cc3Vertex.hasVertexNormal" toSemantic: kCC3SemanticHasVertexNormal]; /**< (bool) Whether a vertex normal is available. */
  1276. [self mapVarName: @"u_cc3Vertex.hasVertexTangent" toSemantic: kCC3SemanticHasVertexTangent]; /**< (bool) Whether a vertex tangent is available. */
  1277. [self mapVarName: @"u_cc3Vertex.hasVertexBitangent" toSemantic: kCC3SemanticHasVertexBitangent]; /**< (bool) Whether a vertex bitangent is available. */
  1278. [self mapVarName: @"u_cc3Vertex.hasVertexColor" toSemantic: kCC3SemanticHasVertexColor]; /**< (bool) Whether a vertex color is available. */
  1279. [self mapVarName: @"u_cc3Vertex.hasVertexWeight" toSemantic: kCC3SemanticHasVertexWeight]; /**< (bool) Whether a vertex weight is available. */
  1280. [self mapVarName: @"u_cc3Vertex.hasVertexMatrixIndex" toSemantic: kCC3SemanticHasVertexMatrixIndex]; /**< (bool) Whether a vertex matrix index is available. */
  1281. [self mapVarName: @"u_cc3Vertex.hasVertexTexCoord" toSemantic: kCC3SemanticHasVertexTextureCoordinate]; /**< (bool) Whether a vertex texture coordinate is available. */
  1282. [self mapVarName: @"u_cc3Vertex.hasVertexPointSize" toSemantic: kCC3SemanticHasVertexPointSize]; /**< (bool) Whether a vertex point size is available. */
  1283. [self mapVarName: @"u_cc3Vertex.isDrawingPoints" toSemantic: kCC3SemanticIsDrawingPoints]; /**< (bool) Whether the vertices are being drawn as points. */
  1284. [self mapVarName: @"u_cc3Vertex.shouldNormalizeNormal" toSemantic: kCC3SemanticShouldNormalizeVertexNormal]; /**< (bool) Whether vertex normals should be normalized. */
  1285. [self mapVarName: @"u_cc3Vertex.shouldRescaleNormal" toSemantic: kCC3SemanticShouldRescaleVertexNormal]; /**< (bool) Whether vertex normals should be rescaled. */
  1286. // ENVIRONMENT MATRICES --------------
  1287. [self mapVarName: @"u_cc3Matrices.modelLocal" toSemantic: kCC3SemanticModelLocalMatrix]; /**< (mat4) Current model-to-parent matrix. */
  1288. [self mapVarName: @"u_cc3Matrices.modelLocalInv" toSemantic: kCC3SemanticModelLocalMatrixInv]; /**< (mat4) Inverse of current model-to-parent matrix. */
  1289. [self mapVarName: @"u_cc3Matrices.modelLocalInvTran" toSemantic: kCC3SemanticModelLocalMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-parent matrix. */
  1290. [self mapVarName: @"u_cc3Matrices.model" toSemantic: kCC3SemanticModelMatrix]; /**< (mat4) Current model-to-world matrix. */
  1291. [self mapVarName: @"u_cc3Matrices.modelInv" toSemantic: kCC3SemanticModelMatrixInv]; /**< (mat4) Inverse of current model-to-world matrix. */
  1292. [self mapVarName: @"u_cc3Matrices.modelInvTran" toSemantic: kCC3SemanticModelMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-world matrix. */
  1293. [self mapVarName: @"u_cc3Matrices.view" toSemantic: kCC3SemanticViewMatrix]; /**< (mat4) Camera view matrix. */
  1294. [self mapVarName: @"u_cc3Matrices.viewInv" toSemantic: kCC3SemanticViewMatrixInv]; /**< (mat4) Inverse of camera view matrix. */
  1295. [self mapVarName: @"u_cc3Matrices.viewInvTran" toSemantic: kCC3SemanticViewMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view matrix. */
  1296. [self mapVarName: @"u_cc3Matrices.modelView" toSemantic: kCC3SemanticModelViewMatrix]; /**< (mat4) Current model-view matrix. */
  1297. [self mapVarName: @"u_cc3Matrices.modelViewInv" toSemantic: kCC3SemanticModelViewMatrixInv]; /**< (mat4) Inverse of current model-view matrix. */
  1298. [self mapVarName: @"u_cc3Matrices.modelViewInvTran" toSemantic: kCC3SemanticModelViewMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-view matrix. */
  1299. [self mapVarName: @"u_cc3Matrices.proj" toSemantic: kCC3SemanticProjMatrix]; /**< (mat4) Camera projection matrix. */
  1300. [self mapVarName: @"u_cc3Matrices.projInv" toSemantic: kCC3SemanticProjMatrixInv]; /**< (mat4) Inverse of camera projection matrix. */
  1301. [self mapVarName: @"u_cc3Matrices.projInvTran" toSemantic: kCC3SemanticProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera projection matrix. */
  1302. [self mapVarName: @"u_cc3Matrices.viewProj" toSemantic: kCC3SemanticViewProjMatrix]; /**< (mat4) Camera view and projection matrix. */
  1303. [self mapVarName: @"u_cc3Matrices.viewProjInv" toSemantic: kCC3SemanticViewProjMatrixInv]; /**< (mat4) Inverse of camera view and projection matrix. */
  1304. [self mapVarName: @"u_cc3Matrices.viewProjInvTran" toSemantic: kCC3SemanticViewProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view and projection matrix. */
  1305. [self mapVarName: @"u_cc3Matrices.modelViewProj" toSemantic: kCC3SemanticModelViewProjMatrix]; /**< (mat4) Current model-view-projection matrix. */
  1306. [self mapVarName: @"u_cc3Matrices.modelViewProjInv" toSemantic: kCC3SemanticModelViewProjMatrixInv]; /**< (mat4) Inverse of current model-view-projection matrix. */
  1307. [self mapVarName: @"u_cc3Matrices.modelViewProjInvTran" toSemantic: kCC3SemanticModelViewProjMatrixInvTran];/**< (mat3) Inverse-transpose of current model-view-projection matrix. */
  1308. // SKINNING ----------------
  1309. [self mapVarName: @"u_cc3Bones.bonesPerVertex" toSemantic: kCC3SemanticVertexBoneCount]; /**< (int) Number of bones influencing each vertex (ie- number of weights/matrices specified on each vertex) */
  1310. [self mapVarName: @"u_cc3Bones.matrixCount" toSemantic: kCC3SemanticBatchBoneCount]; /**< (int) Number of matrices in the matrix arrays in this structure. */
  1311. [self mapVarName: @"u_cc3Bones.matricesEyeSpace" toSemantic: kCC3SemanticBoneMatricesEyeSpace]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in eye space. */
  1312. [self mapVarName: @"u_cc3Bones.matricesInvTranEyeSpace" toSemantic: kCC3SemanticBoneMatricesInvTranEyeSpace]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in eye space. */
  1313. [self mapVarName: @"u_cc3Bones.matricesGlobal" toSemantic: kCC3SemanticBoneMatricesGlobal]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in global coordinates. */
  1314. [self mapVarName: @"u_cc3Bones.matricesInvTranGlobal" toSemantic: kCC3SemanticBoneMatricesInvTranGlobal]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in global coordinates. */
  1315. // CAMERA -----------------
  1316. [self mapVarName: @"u_cc3Camera.positionGlobal" toSemantic: kCC3SemanticCameraLocationGlobal]; /**< (vec3) Location of the camera in global coordinates. */
  1317. [self mapVarName: @"u_cc3Camera.positionModel" toSemantic: kCC3SemanticCameraLocationModelSpace]; /**< (vec3) Location of the camera in local coordinates of model (not camera). */
  1318. [self mapVarName: @"u_cc3Camera.frustum" toSemantic: kCC3SemanticCameraFrustum]; /**< (vec4) Dimensions of the camera frustum (FOV width (radians), FOV height (radians), near clip, far clip). */
  1319. [self mapVarName: @"u_cc3Camera.viewport" toSemantic: kCC3SemanticViewport]; /**< (int4) The viewport rectangle in pixels (x, y, width, height). */
  1320. // MATERIALS --------------
  1321. [self mapVarName: @"u_cc3Color" toSemantic: kCC3SemanticColor]; /**< (vec4) Color when lighting & materials are not in use. */
  1322. [self mapVarName: @"u_cc3Material.ambientColor" toSemantic: kCC3SemanticMaterialColorAmbient]; /**< (vec4) Ambient color of the material. */
  1323. [self mapVarName: @"u_cc3Material.diffuseColor" toSemantic: kCC3SemanticMaterialColorDiffuse]; /**< (vec4) Diffuse color of the material. */
  1324. [self mapVarName: @"u_cc3Material.specularColor" toSemantic: kCC3SemanticMaterialColorSpecular]; /**< (vec4) Specular color of the material. */
  1325. [self mapVarName: @"u_cc3Material.emissionColor" toSemantic: kCC3SemanticMaterialColorEmission]; /**< (vec4) Emission color of the material. */
  1326. [self mapVarName: @"u_cc3Material.opacity" toSemantic: kCC3SemanticMaterialOpacity]; /**< (float) Opacity of the material (0.0 - 1.0). */
  1327. [self mapVarName: @"u_cc3Material.shininess" toSemantic: kCC3SemanticMaterialShininess]; /**< (float) Shininess of the material. */
  1328. [self mapVarName: @"u_cc3Material.minimumDrawnAlpha" toSemantic: kCC3SemanticMinimumDrawnAlpha]; /**< (float) Minimum alpha value to be drawn, otherwise will be discarded. */
  1329. // LIGHTING --------------
  1330. // With multiple lights, most of the structure elements is an array.
  1331. [self mapVarName: @"u_cc3Lighting.isUsingLighting" toSemantic: kCC3SemanticIsUsingLighting]; /**< (bool) Whether any lighting is enabled. */
  1332. [self mapVarName: @"u_cc3Lighting.sceneAmbientLightColor" toSemantic: kCC3SemanticSceneLightColorAmbient]; /**< (vec4) Ambient light color of the scene. */
  1333. [self mapVarName: @"u_cc3Lighting.isLightEnabled" toSemantic: kCC3SemanticLightIsEnabled]; /**< (bool[]) Whether each light is enabled. */
  1334. [self mapVarName: @"u_cc3Lighting.positionEyeSpace" toSemantic: kCC3SemanticLightPositionEyeSpace]; /**< (vec4[]) Location of each light in eye space. */
  1335. [self mapVarName: @"u_cc3Lighting.positionGlobal" toSemantic: kCC3SemanticLightPositionGlobal]; /**< (vec4[]) Location of each light in global coordinates. */
  1336. [self mapVarName: @"u_cc3Lighting.positionModel" toSemantic: kCC3SemanticLightPositionModelSpace]; /**< (vec4[]) Location of each light in local coordinates of model (not light). */
  1337. [self mapVarName: @"u_cc3Lighting.ambientColor" toSemantic: kCC3SemanticLightColorAmbient]; /**< (vec4[]) Ambient color of each light. */
  1338. [self mapVarName: @"u_cc3Lighting.diffuseColor" toSemantic: kCC3SemanticLightColorDiffuse]; /**< (vec4[]) Diffuse color of each light. */
  1339. [self mapVarName: @"u_cc3Lighting.specularColor" toSemantic: kCC3SemanticLightColorSpecular]; /**< (vec4[]) Specular color of each light. */
  1340. [self mapVarName: @"u_cc3Lighting.attenuation" toSemantic: kCC3SemanticLightAttenuation]; /**< (vec3[]) Distance attenuation coefficients for each light. */
  1341. [self mapVarName: @"u_cc3Lighting.spotDirectionEyeSpace" toSemantic: kCC3SemanticLightSpotDirectionEyeSpace]; /**< (vec3[]) Direction of each spotlight in eye space. */
  1342. [self mapVarName: @"u_cc3Lighting.spotDirectionGlobal" toSemantic: kCC3SemanticLightSpotDirectionGlobal]; /**< (vec3[]) Direction of each spotlight in global coordinates. */
  1343. [self mapVarName: @"u_cc3Lighting.spotDirectionModel" toSemantic: kCC3SemanticLightSpotDirectionModelSpace]; /**< (vec3[]) Direction of each spotlight in local coordinates of the model (not light). */
  1344. [self mapVarName: @"u_cc3Lighting.spotExponent" toSemantic: kCC3SemanticLightSpotExponent]; /**< (float[]) Fade-off exponent of each spotlight. */
  1345. [self mapVarName: @"u_cc3Lighting.spotCutoffAngle" toSemantic: kCC3SemanticLightSpotCutoffAngle]; /**< (float[]) Cutoff angle of each spotlight (degrees). */
  1346. [self mapVarName: @"u_cc3Lighting.spotCutoffAngleCosine" toSemantic: kCC3SemanticLightSpotCutoffAngleCosine]; /**< (float[]) Cosine of cutoff angle of each spotlight. */
  1347. [self mapVarName: @"u_cc3Fog.isEnabled" toSemantic: kCC3SemanticFogIsEnabled]; /**< (bool) Whether scene fogging is enabled. */
  1348. [self mapVarName: @"u_cc3Fog.color" toSemantic: kCC3SemanticFogColor]; /**< (vec4) Fog color. */
  1349. [self mapVarName: @"u_cc3Fog.attenuationMode" toSemantic: kCC3SemanticFogAttenuationMode]; /**< (int) Fog attenuation mode (one of GL_LINEAR, GL_EXP or GL_EXP2). */
  1350. [self mapVarName: @"u_cc3Fog.density" toSemantic: kCC3SemanticFogDensity]; /**< (float) Fog density. */
  1351. [self mapVarName: @"u_cc3Fog.startDistance" toSemantic: kCC3SemanticFogStartDistance]; /**< (float) Distance from camera at which fogging effect starts. */
  1352. [self mapVarName: @"u_cc3Fog.endDistance" toSemantic: kCC3SemanticFogEndDistance]; /**< (float) Distance from camera at which fogging effect ends. */
  1353. // TEXTURES --------------
  1354. [self mapVarName: @"u_cc3TextureCount" toSemantic: kCC3SemanticTextureCount]; /**< (int) Number of active textures. */
  1355. [self mapVarName: @"s_cc3Texture" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D) Single texture sampler (texture unit 0). */
  1356. [self mapVarName: @"s_cc3Textures" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D[]) Array of texture samplers. */
  1357. // The semantics below mimic OpenGL ES 1.1 configuration functionality for combining texture units.
  1358. // In most shaders, these will be left unused in favor of customized the texture combining in GLSL code.
  1359. [self mapVarName: @"u_cc3TextureUnits.color" toSemantic: kCC3SemanticTexUnitConstantColor]; /**< (vec4[]) The constant color of each texture unit. */
  1360. [self mapVarName: @"u_cc3TextureUnits.mode" toSemantic: kCC3SemanticTexUnitMode]; /**< (int[]) Environment mode of each texture unit. */
  1361. [self mapVarName: @"u_cc3TextureUnits.combineRGBFunction" toSemantic: kCC3SemanticTexUnitCombineRGBFunction]; /**< (int[]) RBG combiner function of each texture unit. */
  1362. [self mapVarName: @"u_cc3TextureUnits.rgbSource0" toSemantic: kCC3SemanticTexUnitSource0RGB]; /**< (int[]) The RGB of source 0 of each texture unit. */
  1363. [self mapVarName: @"u_cc3TextureUnits.rgbSource1" toSemantic: kCC3SemanticTexUnitSource1RGB]; /**< (int[]) The RGB of source 1 of each texture unit. */
  1364. [self mapVarName: @"u_cc3TextureUnits.rgbSource2" toSemantic: kCC3SemanticTexUnitSource2RGB]; /**< (int[]) The RGB of source 2 of each texture unit. */
  1365. [self mapVarName: @"u_cc3TextureUnits.rgbOperand0" toSemantic: kCC3SemanticTexUnitOperand0RGB]; /**< (int[]) The RGB combining operand of source 0 of each texture unit. */
  1366. [self mapVarName: @"u_cc3TextureUnits.rgbOperand1" toSemantic: kCC3SemanticTexUnitOperand1RGB]; /**< (int[]) The RGB combining operand of source 1 of each texture unit. */
  1367. [self mapVarName: @"u_cc3TextureUnits.rgbOperand2" toSemantic: kCC3SemanticTexUnitOperand2RGB]; /**< (int[]) The RGB combining operand of source 2 of each texture unit. */
  1368. [self mapVarName: @"u_cc3TextureUnits.combineAlphaFunction" toSemantic: kCC3SemanticTexUnitCombineAlphaFunction]; /**< (int[]) Alpha combiner function of each texture unit. */
  1369. [self mapVarName: @"u_cc3TextureUnits.alphaSource0" toSemantic: kCC3SemanticTexUnitSource0Alpha]; /**< (int[]) The alpha of source 0 of each texture unit. */
  1370. [self mapVarName: @"u_cc3TextureUnits.alphaSource1" toSemantic: kCC3SemanticTexUnitSource1Alpha]; /**< (int[]) The alpha of source 1 of each texture unit. */
  1371. [self mapVarName: @"u_cc3TextureUnits.alphaSource2" toSemantic: kCC3SemanticTexUnitSource2Alpha]; /**< (int[]) The alpha of source 2 of each texture unit. */
  1372. [self mapVarName: @"u_cc3TextureUnits.alphaOperand0" toSemantic: kCC3SemanticTexUnitOperand0Alpha]; /**< (int[]) The alpha combining operand of source 0 of each texture unit. */
  1373. [self mapVarName: @"u_cc3TextureUnits.alphaOperand1" toSemantic: kCC3SemanticTexUnitOperand1Alpha]; /**< (int[]) The alpha combining operand of source 1 of each texture unit. */
  1374. [self mapVarName: @"u_cc3TextureUnits.alphaOperand2" toSemantic: kCC3SemanticTexUnitOperand2Alpha]; /**< (int[]) The alpha combining operand of source 2 of each texture unit. */
  1375. // MODEL ----------------
  1376. [self mapVarName: @"u_cc3Model.centerOfGeometry" toSemantic: kCC3SemanticCenterOfGeometry]; /**< (vec3) The center of geometry of the model in the model's local coordinates. */
  1377. [self mapVarName: @"u_cc3Model.boundingRadius" toSemantic: kCC3SemanticBoundingRadius]; /**< (vec3) The minimum corner of the model's bounding box in the model's local coordinates. */
  1378. [self mapVarName: @"u_cc3Model.boundingBoxMinimum" toSemantic: kCC3SemanticBoundingBoxMin]; /**< (vec3) The maximum corner of the model's bounding box in the model's local coordinates. */
  1379. [self mapVarName: @"u_cc3Model.boundingBoxMaximum" toSemantic: kCC3SemanticBoundingBoxMax]; /**< (vec3) The dimensions of the model's bounding box in the model's local coordinates. */
  1380. [self mapVarName: @"u_cc3Model.boundingBoxSize" toSemantic: kCC3SemanticBoundingBoxSize]; /**< (float) The radius of the model's bounding sphere in the model's local coordinates. */
  1381. [self mapVarName: @"u_cc3Model.animationFraction" toSemantic: kCC3SemanticAnimationFraction]; /**< (float) Fraction of the model's animation that has been viewed (range 0-1). */
  1382. // PARTICLES ------------
  1383. [self mapVarName: @"u_cc3Points.isDrawingPoints" toSemantic: kCC3SemanticIsDrawingPoints]; /**< (bool) Whether the vertices are being drawn as points (alias for u_cc3IsDrawingPoints). */
  1384. [self mapVarName: @"u_cc3Points.hasVertexPointSize" toSemantic: kCC3SemanticHasVertexPointSize]; /**< (bool) Whether the vertex point size is available (alias for u_cc3HasVertexPointSize). */
  1385. [self mapVarName: @"u_cc3Points.size" toSemantic: kCC3SemanticPointSize]; /**< (float) Default size of points, if not specified per-vertex in a vertex attribute array. */
  1386. [self mapVarName: @"u_cc3Points.sizeAttenuation" toSemantic: kCC3SemanticPointSizeAttenuation]; /**< (vec3) Point size distance attenuation coefficients. */
  1387. [self mapVarName: @"u_cc3Points.minimumSize" toSemantic: kCC3SemanticPointSizeMinimum]; /**< (float) Minimum size points will be allowed to shrink to. */
  1388. [self mapVarName: @"u_cc3Points.maximumSize" toSemantic: kCC3SemanticPointSizeMaximum]; /**< (float) Maximum size points will be allowed to grow to. */
  1389. [self mapVarName: @"u_cc3Points.shouldDisplayAsSprites" toSemantic: kCC3SemanticPointSpritesIsEnabled]; /**< (bool) Whether points should be interpeted as textured sprites. */
  1390. // TIME ------------------
  1391. [self mapVarName: @"u_cc3Time.appTime" toSemantic: kCC3SemanticSceneTime]; /**< @deprecated Use sceneTime instead. */
  1392. [self mapVarName: @"u_cc3Time.appTimeSine" toSemantic: kCC3SemanticSceneTimeSine]; /**< @deprecated Use sceneTimeSin instead. */
  1393. [self mapVarName: @"u_cc3Time.appTimeCosine" toSemantic: kCC3SemanticSceneTimeCosine]; /**< @deprecated Use sceneTimeCos instead. */
  1394. [self mapVarName: @"u_cc3Time.appTimeTangent" toSemantic: kCC3SemanticSceneTimeTangent]; /**< @deprecated Use sceneTimeTan instead. */
  1395. // MISC ENVIRONMENT ---------
  1396. [self mapVarName: @"u_cc3DrawCount" toSemantic: kCC3SemanticDrawCountCurrentFrame]; /**< (int) The number of draw calls so far in this frame. */
  1397. [self mapVarName: @"u_cc3Random" toSemantic: kCC3SemanticRandomNumber]; /**< (float) A random number between 0 and 1. */
  1398. }
  1399. -(void) populateWithLegacyVariableNameMappings {
  1400. // VETEX ATTRIBUTES --------------
  1401. [self mapVarName: @"a_cc3Position" toSemantic: kCC3SemanticVertexLocation]; /**< Vertex location. */
  1402. [self mapVarName: @"a_cc3Normal" toSemantic: kCC3SemanticVertexNormal]; /**< Vertex normal. */
  1403. [self mapVarName: @"a_cc3Tangent" toSemantic: kCC3SemanticVertexTangent]; /**< Vertex tangent. */
  1404. [self mapVarName: @"a_cc3Bitangent" toSemantic: kCC3SemanticVertexBitangent]; /**< Vertex bitangent (aka binormal). */
  1405. [self mapVarName: @"a_cc3Color" toSemantic: kCC3SemanticVertexColor]; /**< Vertex color. */
  1406. [self mapVarName: @"a_cc3BoneWeights" toSemantic: kCC3SemanticVertexBoneWeights]; /**< Vertex skinning bone weights (each an array of length specified by u_cc3BonesPerVertex). */
  1407. [self mapVarName: @"a_cc3BoneIndices" toSemantic: kCC3SemanticVertexBoneIndices]; /**< Vertex skinning bone indices (each an array of length specified by u_cc3BonesPerVertex). */
  1408. [self mapVarName: @"a_cc3PointSize" toSemantic: kCC3SemanticVertexPointSize]; /**< Vertex point size. */
  1409. // If only one texture coordinate attribute is used, the index suffix ("a_cc3TexCoordN") is optional.
  1410. [self mapVarName: @"a_cc3TexCoord" toSemantic: kCC3SemanticVertexTexture]; /**< Vertex texture coordinate for the first texture unit. */
  1411. GLuint maxTexUnits = CC3OpenGL.sharedGL.maxNumberOfTextureUnits;
  1412. for (GLuint tuIdx = 0; tuIdx < maxTexUnits; tuIdx++)
  1413. [self mapVarName: [NSString stringWithFormat: @"a_cc3TexCoord%u", tuIdx] toSemantic: kCC3SemanticVertexTexture at: tuIdx]; /**< Vertex texture coordinate for a texture unit. */
  1414. // ATTRIBUTE QUALIFIERS --------------
  1415. [self mapVarName: @"u_cc3HasVertexNormal" toSemantic: kCC3SemanticHasVertexNormal]; /**< (bool) Whether a vertex normal is available. */
  1416. [self mapVarName: @"u_cc3ShouldNormalizeNormal" toSemantic: kCC3SemanticShouldNormalizeVertexNormal]; /**< (bool) Whether vertex normals should be normalized. */
  1417. [self mapVarName: @"u_cc3ShouldRescaleNormal" toSemantic: kCC3SemanticShouldRescaleVertexNormal]; /**< (bool) Whether vertex normals should be rescaled. */
  1418. [self mapVarName: @"u_cc3HasVertexTangent" toSemantic: kCC3SemanticHasVertexTangent]; /**< (bool) Whether a vertex tangent is available. */
  1419. [self mapVarName: @"u_cc3HasVertexBitangent" toSemantic: kCC3SemanticHasVertexBitangent]; /**< (bool) Whether a vertex bitangent is available. */
  1420. [self mapVarName: @"u_cc3HasVertexColor" toSemantic: kCC3SemanticHasVertexColor]; /**< (bool) Whether a vertex color is available. */
  1421. [self mapVarName: @"u_cc3HasVertexWeight" toSemantic: kCC3SemanticHasVertexWeight]; /**< (bool) Whether a vertex weight is available. */
  1422. [self mapVarName: @"u_cc3HasVertexMatrixIndex" toSemantic: kCC3SemanticHasVertexMatrixIndex]; /**< (bool) Whether a vertex matrix index is available. */
  1423. [self mapVarName: @"u_cc3HasVertexTexCoord" toSemantic: kCC3SemanticHasVertexTextureCoordinate]; /**< (bool) Whether a vertex texture coordinate is available. */
  1424. [self mapVarName: @"u_cc3HasVertexPointSize" toSemantic: kCC3SemanticHasVertexPointSize]; /**< (bool) Whether a vertex point size is available. */
  1425. [self mapVarName: @"u_cc3IsDrawingPoints" toSemantic: kCC3SemanticIsDrawingPoints]; /**< (bool) Whether the vertices are being drawn as points. */
  1426. // ENVIRONMENT MATRICES --------------
  1427. [self mapVarName: @"u_cc3MtxModelLocal" toSemantic: kCC3SemanticModelLocalMatrix]; /**< (mat4) Current model-to-parent matrix. */
  1428. [self mapVarName: @"u_cc3MtxModelLocalInv" toSemantic: kCC3SemanticModelLocalMatrixInv]; /**< (mat4) Inverse of current model-to-parent matrix. */
  1429. [self mapVarName: @"u_cc3MtxModelLocalInvTran" toSemantic: kCC3SemanticModelLocalMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-parent matrix. */
  1430. [self mapVarName: @"u_cc3MtxModel" toSemantic: kCC3SemanticModelMatrix]; /**< (mat4) Current model-to-world matrix. */
  1431. [self mapVarName: @"u_cc3MtxModelInv" toSemantic: kCC3SemanticModelMatrixInv]; /**< (mat4) Inverse of current model-to-world matrix. */
  1432. [self mapVarName: @"u_cc3MtxModelInvTran" toSemantic: kCC3SemanticModelMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-to-world matrix. */
  1433. [self mapVarName: @"u_cc3MtxView" toSemantic: kCC3SemanticViewMatrix]; /**< (mat4) Camera view matrix. */
  1434. [self mapVarName: @"u_cc3MtxViewInv" toSemantic: kCC3SemanticViewMatrixInv]; /**< (mat4) Inverse of camera view matrix. */
  1435. [self mapVarName: @"u_cc3MtxViewInvTran" toSemantic: kCC3SemanticViewMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view matrix. */
  1436. [self mapVarName: @"u_cc3MtxModelView" toSemantic: kCC3SemanticModelViewMatrix]; /**< (mat4) Current model-view matrix. */
  1437. [self mapVarName: @"u_cc3MtxModelViewInv" toSemantic: kCC3SemanticModelViewMatrixInv]; /**< (mat4) Inverse of current model-view matrix. */
  1438. [self mapVarName: @"u_cc3MtxModelViewInvTran" toSemantic: kCC3SemanticModelViewMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-view matrix. */
  1439. [self mapVarName: @"u_cc3MtxProj" toSemantic: kCC3SemanticProjMatrix]; /**< (mat4) Camera projection matrix. */
  1440. [self mapVarName: @"u_cc3MtxProjInv" toSemantic: kCC3SemanticProjMatrixInv]; /**< (mat4) Inverse of camera projection matrix. */
  1441. [self mapVarName: @"u_cc3MtxProjInvTran" toSemantic: kCC3SemanticProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera projection matrix. */
  1442. [self mapVarName: @"u_cc3MtxViewProj" toSemantic: kCC3SemanticViewProjMatrix]; /**< (mat4) Camera view and projection matrix. */
  1443. [self mapVarName: @"u_cc3MtxViewProjInv" toSemantic: kCC3SemanticViewProjMatrixInv]; /**< (mat4) Inverse of camera view and projection matrix. */
  1444. [self mapVarName: @"u_cc3MtxViewProjInvTran" toSemantic: kCC3SemanticViewProjMatrixInvTran]; /**< (mat3) Inverse-transpose of camera view and projection matrix. */
  1445. [self mapVarName: @"u_cc3MtxModelViewProj" toSemantic: kCC3SemanticModelViewProjMatrix]; /**< (mat4) Current model-view-projection matrix. */
  1446. [self mapVarName: @"u_cc3MtxModelViewProjInv" toSemantic: kCC3SemanticModelViewProjMatrixInv]; /**< (mat4) Inverse of current model-view-projection matrix. */
  1447. [self mapVarName: @"u_cc3MtxModelViewProjInvTran" toSemantic: kCC3SemanticModelViewProjMatrixInvTran]; /**< (mat3) Inverse-transpose of current model-view-projection matrix. */
  1448. // CAMERA -----------------
  1449. [self mapVarName: @"u_cc3Camera.positionGlobal" toSemantic: kCC3SemanticCameraLocationGlobal]; /**< (vec3) Location of the camera in global coordinates. */
  1450. [self mapVarName: @"u_cc3Camera.positionModel" toSemantic: kCC3SemanticCameraLocationModelSpace]; /**< (vec3) Location of the camera in local coordinates of model (not camera). */
  1451. [self mapVarName: @"u_cc3Camera.frustum" toSemantic: kCC3SemanticCameraFrustum]; /**< (vec4) Dimensions of the camera frustum (FOV width (radians), FOV height (radians), near clip, far clip). */
  1452. [self mapVarName: @"u_cc3Camera.viewport" toSemantic: kCC3SemanticViewport]; /**< (int4) The viewport rectangle in pixels (x, y, width, height). */
  1453. // MATERIALS --------------
  1454. [self mapVarName: @"u_cc3Color" toSemantic: kCC3SemanticColor]; /**< (vec4) Color when lighting & materials are not in use. */
  1455. [self mapVarName: @"u_cc3Material.ambientColor" toSemantic: kCC3SemanticMaterialColorAmbient]; /**< (vec4) Ambient color of the material. */
  1456. [self mapVarName: @"u_cc3Material.diffuseColor" toSemantic: kCC3SemanticMaterialColorDiffuse]; /**< (vec4) Diffuse color of the material. */
  1457. [self mapVarName: @"u_cc3Material.specularColor" toSemantic: kCC3SemanticMaterialColorSpecular]; /**< (vec4) Specular color of the material. */
  1458. [self mapVarName: @"u_cc3Material.emissionColor" toSemantic: kCC3SemanticMaterialColorEmission]; /**< (vec4) Emission color of the material. */
  1459. [self mapVarName: @"u_cc3Material.opacity" toSemantic: kCC3SemanticMaterialOpacity]; /**< (float) Opacity of the material (0.0 - 1.0). */
  1460. [self mapVarName: @"u_cc3Material.shininess" toSemantic: kCC3SemanticMaterialShininess]; /**< (float) Shininess of the material. */
  1461. [self mapVarName: @"u_cc3Material.minimumDrawnAlpha" toSemantic: kCC3SemanticMinimumDrawnAlpha]; /**< (float) Minimum alpha value to be drawn, otherwise will be discarded. */
  1462. // LIGHTING --------------
  1463. [self mapVarName: @"u_cc3IsUsingLighting" toSemantic: kCC3SemanticIsUsingLighting]; /**< (bool) Whether any lighting is enabled. */
  1464. [self mapVarName: @"u_cc3SceneLightColorAmbient" toSemantic: kCC3SemanticSceneLightColorAmbient]; /**< (vec4) Ambient light color of the scene. */
  1465. // If only one light is used it can be declared as a single variable structure without the index.
  1466. [self mapVarName: @"u_cc3Light.isEnabled" toSemantic: kCC3SemanticLightIsEnabled]; /**< (bool) Whether the first light is enabled. */
  1467. [self mapVarName: @"u_cc3Light.positionEyeSpace" toSemantic: kCC3SemanticLightPositionEyeSpace]; /**< (vec4) Location of the first light in eye space. */
  1468. [self mapVarName: @"u_cc3Light.positionGlobal" toSemantic: kCC3SemanticLightPositionGlobal]; /**< (vec4) Location of the first light in global coordinates. */
  1469. [self mapVarName: @"u_cc3Light.positionModel" toSemantic: kCC3SemanticLightPositionModelSpace]; /**< (vec4) Location of the first light in local coordinates of model (not light). */
  1470. [self mapVarName: @"u_cc3Light.ambientColor" toSemantic: kCC3SemanticLightColorAmbient]; /**< (vec4) Ambient color of the first light. */
  1471. [self mapVarName: @"u_cc3Light.diffuseColor" toSemantic: kCC3SemanticLightColorDiffuse]; /**< (vec4) Diffuse color of the first light. */
  1472. [self mapVarName: @"u_cc3Light.specularColor" toSemantic: kCC3SemanticLightColorSpecular]; /**< (vec4) Specular color of the first light. */
  1473. [self mapVarName: @"u_cc3Light.attenuation" toSemantic: kCC3SemanticLightAttenuation]; /**< (vec3) Distance attenuation coefficients for the first light. */
  1474. [self mapVarName: @"u_cc3Light.spotDirectionEyeSpace" toSemantic: kCC3SemanticLightSpotDirectionEyeSpace]; /**< (vec3) Direction of the first spotlight in eye space. */
  1475. [self mapVarName: @"u_cc3Light.spotDirectionGlobal" toSemantic: kCC3SemanticLightSpotDirectionGlobal]; /**< (vec3) Direction of the first spotlight in global coordinates. */
  1476. [self mapVarName: @"u_cc3Light.spotDirectionModel" toSemantic: kCC3SemanticLightSpotDirectionModelSpace]; /**< (vec3) Direction of the first spotlight in local coordinates of the model (not light). */
  1477. [self mapVarName: @"u_cc3Light.spotExponent" toSemantic: kCC3SemanticLightSpotExponent]; /**< (float) Fade-off exponent of the first spotlight. */
  1478. [self mapVarName: @"u_cc3Light.spotCutoffAngle" toSemantic: kCC3SemanticLightSpotCutoffAngle]; /**< (float) Cutoff angle of the first spotlight (degrees). */
  1479. [self mapVarName: @"u_cc3Light.spotCutoffAngleCosine" toSemantic: kCC3SemanticLightSpotCutoffAngleCosine]; /**< (float) Cosine of cutoff angle of the first spotlight. */
  1480. // Multiple lights are indexed
  1481. for (GLuint ltIdx = 0; ltIdx < 4; ltIdx++) {
  1482. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].isEnabled", ltIdx] toSemantic: kCC3SemanticLightIsEnabled at: ltIdx]; /**< (bool) Whether a light is enabled. */
  1483. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].positionEyeSpace", ltIdx] toSemantic: kCC3SemanticLightPositionEyeSpace at: ltIdx]; /**< (vec4) Homogeneous position (location or direction) of a light in eye space. */
  1484. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].positionGlobal", ltIdx] toSemantic: kCC3SemanticLightPositionGlobal at: ltIdx]; /**< (vec4) Homogeneous position (location or direction) of a light in global coordinates. */
  1485. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].positionModel", ltIdx] toSemantic: kCC3SemanticLightPositionModelSpace at: ltIdx]; /**< (vec4) Homogeneous position (location or direction) of a light in local coordinates of model (not light). */
  1486. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].ambientColor", ltIdx] toSemantic: kCC3SemanticLightColorAmbient at: ltIdx]; /**< (vec4) Ambient color of a light. */
  1487. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].diffuseColor", ltIdx] toSemantic: kCC3SemanticLightColorDiffuse at: ltIdx]; /**< (vec4) Diffuse color of a light. */
  1488. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].specularColor", ltIdx] toSemantic: kCC3SemanticLightColorSpecular at: ltIdx]; /**< (vec4) Specular color of a light. */
  1489. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].attenuation", ltIdx] toSemantic: kCC3SemanticLightAttenuation at: ltIdx]; /**< (vec3) Distance attenuation coefficients for a light. */
  1490. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotDirectionEyeSpace", ltIdx] toSemantic: kCC3SemanticLightSpotDirectionEyeSpace at: ltIdx]; /**< (vec3) Direction of a spotlight in eye space. */
  1491. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotDirectionGlobal", ltIdx] toSemantic: kCC3SemanticLightSpotDirectionGlobal at: ltIdx]; /**< (vec3) Direction of a spotlight in global coordinates. */
  1492. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotDirectionModel", ltIdx] toSemantic: kCC3SemanticLightSpotDirectionModelSpace at: ltIdx]; /**< (vec3) Direction of a spotlight in local coordinates of the model (not light). */
  1493. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotExponent", ltIdx] toSemantic: kCC3SemanticLightSpotExponent at: ltIdx]; /**< (float) Fade-off exponent of a spotlight. */
  1494. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotCutoffAngle", ltIdx] toSemantic: kCC3SemanticLightSpotCutoffAngle at: ltIdx]; /**< (float) Cutoff angle of a spotlight (degrees). */
  1495. [self mapVarName: [NSString stringWithFormat: @"u_cc3Lights[%u].spotCutoffAngleCosine", ltIdx] toSemantic: kCC3SemanticLightSpotCutoffAngleCosine at: ltIdx]; /**< (float) Cosine of cutoff angle of a spotlight. */
  1496. }
  1497. [self mapVarName: @"u_cc3Fog.isEnabled" toSemantic: kCC3SemanticFogIsEnabled]; /**< (bool) Whether scene fogging is enabled. */
  1498. [self mapVarName: @"u_cc3Fog.color" toSemantic: kCC3SemanticFogColor]; /**< (vec4) Fog color. */
  1499. [self mapVarName: @"u_cc3Fog.attenuationMode" toSemantic: kCC3SemanticFogAttenuationMode]; /**< (int) Fog attenuation mode (one of GL_LINEAR, GL_EXP or GL_EXP2). */
  1500. [self mapVarName: @"u_cc3Fog.density" toSemantic: kCC3SemanticFogDensity]; /**< (float) Fog density. */
  1501. [self mapVarName: @"u_cc3Fog.startDistance" toSemantic: kCC3SemanticFogStartDistance]; /**< (float) Distance from camera at which fogging effect starts. */
  1502. [self mapVarName: @"u_cc3Fog.endDistance" toSemantic: kCC3SemanticFogEndDistance]; /**< (float) Distance from camera at which fogging effect ends. */
  1503. // TEXTURES --------------
  1504. [self mapVarName: @"u_cc3TextureCount" toSemantic: kCC3SemanticTextureCount]; /**< (int) Number of active textures. */
  1505. [self mapVarName: @"s_cc3Texture" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D) Texture sampler. */
  1506. [self mapVarName: @"s_cc3Textures" toSemantic: kCC3SemanticTextureSampler]; /**< (sampler2D[]) Array of texture samplers. */
  1507. // The semantics below mimic OpenGL ES 1.1 configuration functionality for combining texture units.
  1508. // In most shaders, these will be left unused in favor of customized the texture combining in code.
  1509. for (GLuint tuIdx = 0; tuIdx < 4; tuIdx++) {
  1510. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].color", tuIdx] toSemantic: kCC3SemanticTexUnitConstantColor at: tuIdx]; /**< (vec4) The constant color of a texture unit. */
  1511. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].mode", tuIdx] toSemantic: kCC3SemanticTexUnitMode at: tuIdx]; /**< (int) Environment mode of a texture unit. */
  1512. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].combineRGBFunction", tuIdx] toSemantic: kCC3SemanticTexUnitCombineRGBFunction at: tuIdx]; /**< (int) RBG combiner function of a texture unit. */
  1513. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbSource0", tuIdx] toSemantic: kCC3SemanticTexUnitSource0RGB at: tuIdx]; /**< (int) The RGB of source 0 of a texture unit. */
  1514. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbSource1", tuIdx] toSemantic: kCC3SemanticTexUnitSource1RGB at: tuIdx]; /**< (int) The RGB of source 1 of a texture unit. */
  1515. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbSource2", tuIdx] toSemantic: kCC3SemanticTexUnitSource2RGB at: tuIdx]; /**< (int) The RGB of source 2 of a texture unit. */
  1516. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbOperand0", tuIdx] toSemantic: kCC3SemanticTexUnitOperand0RGB at: tuIdx]; /**< (int) The RGB combining operand of source 0 of a texture unit. */
  1517. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbOperand1", tuIdx] toSemantic: kCC3SemanticTexUnitOperand1RGB at: tuIdx]; /**< (int) The RGB combining operand of source 1 of a texture unit. */
  1518. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].rgbOperand2", tuIdx] toSemantic: kCC3SemanticTexUnitOperand2RGB at: tuIdx]; /**< (int) The RGB combining operand of source 2 of a texture unit. */
  1519. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].combineAlphaFunction", tuIdx] toSemantic: kCC3SemanticTexUnitCombineAlphaFunction at: tuIdx]; /**< (int) Alpha combiner function of a texture unit. */
  1520. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaSource0", tuIdx] toSemantic: kCC3SemanticTexUnitSource0Alpha at: tuIdx]; /**< (int) The alpha of source 0 of a texture unit. */
  1521. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaSource1", tuIdx] toSemantic: kCC3SemanticTexUnitSource1Alpha at: tuIdx]; /**< (int) The alpha of source 1 of a texture unit. */
  1522. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaSource2", tuIdx] toSemantic: kCC3SemanticTexUnitSource2Alpha at: tuIdx]; /**< (int) The alpha of source 2 of a texture unit. */
  1523. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaOperand0", tuIdx] toSemantic: kCC3SemanticTexUnitOperand0Alpha at: tuIdx]; /**< (int) The alpha combining operand of source 0 of a texture unit. */
  1524. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaOperand1", tuIdx] toSemantic: kCC3SemanticTexUnitOperand1Alpha at: tuIdx]; /**< (int) The alpha combining operand of source 1 of a texture unit. */
  1525. [self mapVarName: [NSString stringWithFormat: @"u_cc3TextureUnits[%u].alphaOperand2", tuIdx] toSemantic: kCC3SemanticTexUnitOperand2Alpha at: tuIdx]; /**< (int) The alpha combining operand of source 2 of a texture unit. */
  1526. }
  1527. // MODEL ----------------
  1528. [self mapVarName: @"u_cc3Model.centerOfGeometry" toSemantic: kCC3SemanticCenterOfGeometry]; /**< (vec3) The center of geometry of the model in the model's local coordinates. */
  1529. [self mapVarName: @"u_cc3Model.boundingRadius" toSemantic: kCC3SemanticBoundingRadius]; /**< (vec3) The minimum corner of the model's bounding box in the model's local coordinates. */
  1530. [self mapVarName: @"u_cc3Model.boundingBoxMinimum" toSemantic: kCC3SemanticBoundingBoxMin]; /**< (vec3) The maximum corner of the model's bounding box in the model's local coordinates. */
  1531. [self mapVarName: @"u_cc3Model.boundingBoxMaximum" toSemantic: kCC3SemanticBoundingBoxMax]; /**< (vec3) The dimensions of the model's bounding box in the model's local coordinates. */
  1532. [self mapVarName: @"u_cc3Model.boundingBoxSize" toSemantic: kCC3SemanticBoundingBoxSize]; /**< (float) The radius of the model's bounding sphere in the model's local coordinates. */
  1533. [self mapVarName: @"u_cc3Model.animationFraction" toSemantic: kCC3SemanticAnimationFraction]; /**< (float) Fraction of the model's animation that has been viewed (range 0-1). */
  1534. // SKINNING ----------------
  1535. [self mapVarName: @"u_cc3BonesPerVertex" toSemantic: kCC3SemanticVertexBoneCount]; /**< (int) Number of bones influencing each vertex (ie- number of weights/matrices specified on each vertex) */
  1536. [self mapVarName: @"u_cc3BoneMatrixCount" toSemantic: kCC3SemanticBatchBoneCount]; /**< (int) Length of the u_cc3BoneMatricesEyeSpace and u_cc3BoneMatricesInvTranEyeSpace arrays. */
  1537. [self mapVarName: @"u_cc3BoneMatricesEyeSpace" toSemantic: kCC3SemanticBoneMatricesEyeSpace]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in eye space. */
  1538. [self mapVarName: @"u_cc3BoneMatricesInvTranEyeSpace" toSemantic: kCC3SemanticBoneMatricesInvTranEyeSpace]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in eye space. */
  1539. [self mapVarName: @"u_cc3BoneMatricesGlobal" toSemantic: kCC3SemanticBoneMatricesGlobal]; /**< (mat4[]) Array of bone matrices in the current mesh skin section in global coordinates. */
  1540. [self mapVarName: @"u_cc3BoneMatricesInvTranGlobal" toSemantic: kCC3SemanticBoneMatricesInvTranGlobal]; /**< (mat3[]) Array of inverse-transposes of the bone matrices in the current mesh skin section in global coordinates. */
  1541. // PARTICLES ------------
  1542. [self mapVarName: @"u_cc3Points.isDrawingPoints" toSemantic: kCC3SemanticIsDrawingPoints]; /**< (bool) Whether the vertices are being drawn as points (alias for u_cc3IsDrawingPoints). */
  1543. [self mapVarName: @"u_cc3Points.hasVertexPointSize" toSemantic: kCC3SemanticHasVertexPointSize]; /**< (bool) Whether the vertex point size is available (alias for u_cc3HasVertexPointSize). */
  1544. [self mapVarName: @"u_cc3Points.size" toSemantic: kCC3SemanticPointSize]; /**< (float) Default size of points, if not specified per-vertex in a vertex attribute array. */
  1545. [self mapVarName: @"u_cc3Points.sizeAttenuation" toSemantic: kCC3SemanticPointSizeAttenuation]; /**< (vec3) Point size distance attenuation coefficients. */
  1546. [self mapVarName: @"u_cc3Points.minimumSize" toSemantic: kCC3SemanticPointSizeMinimum]; /**< (float) Minimum size points will be allowed to shrink to. */
  1547. [self mapVarName: @"u_cc3Points.maximumSize" toSemantic: kCC3SemanticPointSizeMaximum]; /**< (float) Maximum size points will be allowed to grow to. */
  1548. [self mapVarName: @"u_cc3Points.shouldDisplayAsSprites" toSemantic: kCC3SemanticPointSpritesIsEnabled]; /**< (bool) Whether points should be interpeted as textured sprites. */
  1549. // TIME ------------------
  1550. [self mapVarName: @"u_cc3Time.frameTime" toSemantic: kCC3SemanticFrameTime]; /**< (float) The time in seconds since the last frame. */
  1551. [self mapVarName: @"u_cc3Time.appTime" toSemantic: kCC3SemanticSceneTime]; /**< (float) The application time in seconds. */
  1552. [self mapVarName: @"u_cc3Time.appTimeSine" toSemantic: kCC3SemanticSceneTimeSine]; /**< (vec4) The sine of the application time (sin(T), sin(T/2), sin(T/4), sin(T/8)). */
  1553. [self mapVarName: @"u_cc3Time.appTimeCosine" toSemantic: kCC3SemanticSceneTimeCosine]; /**< (vec4) The cosine of the application time (cos(T), cos(T/2), cos(T/4), cos(T/8)). */
  1554. [self mapVarName: @"u_cc3Time.appTimeTangent" toSemantic: kCC3SemanticSceneTimeTangent]; /**< (vec4) The tangent of the application time (tan(T), tan(T/2), tan(T/4), tan(T/8)). */
  1555. // MISC ENVIRONMENT ---------
  1556. [self mapVarName: @"u_cc3DrawCount" toSemantic: kCC3SemanticDrawCountCurrentFrame]; /**< (int) The number of draw calls so far in this frame. */
  1557. [self mapVarName: @"u_cc3Random" toSemantic: kCC3SemanticRandomNumber]; /**< (float) A random number between 0 and 1. */
  1558. }
  1559. @end