processedMaterial.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "materials/processedMaterial.h"
  24. #include "materials/sceneData.h"
  25. #include "materials/materialParameters.h"
  26. #include "materials/matTextureTarget.h"
  27. #include "materials/materialFeatureTypes.h"
  28. #include "materials/materialManager.h"
  29. #include "scene/sceneRenderState.h"
  30. #include "gfx/gfxPrimitiveBuffer.h"
  31. #include "gfx/gfxTextureManager.h"
  32. #include "gfx/sim/cubemapData.h"
  33. RenderPassData::RenderPassData()
  34. {
  35. reset();
  36. }
  37. void RenderPassData::reset()
  38. {
  39. for( U32 i = 0; i < Material::MAX_TEX_PER_PASS; ++ i )
  40. {
  41. destructInPlace( &mTexSlot[ i ] );
  42. mSamplerNames[ i ].clear();
  43. }
  44. dMemset( &mTexSlot, 0, sizeof(mTexSlot) );
  45. dMemset( &mTexType, 0, sizeof(mTexType) );
  46. mCubeMap = NULL;
  47. mNumTex = mNumTexReg = mStageNum = 0;
  48. mGlow = false;
  49. mBlendOp = Material::None;
  50. mFeatureData.clear();
  51. for (U32 i = 0; i < STATE_MAX; i++)
  52. mRenderStates[i] = NULL;
  53. }
  54. String RenderPassData::describeSelf() const
  55. {
  56. String desc;
  57. // Now write all the textures.
  58. String texName;
  59. for ( U32 i=0; i < Material::MAX_TEX_PER_PASS; i++ )
  60. {
  61. if ( mTexType[i] == Material::TexTarget )
  62. texName = ( mTexSlot[i].texTarget ) ? mTexSlot[i].texTarget->getName() : "null_texTarget";
  63. else if ( mTexType[i] == Material::Cube && mCubeMap )
  64. texName = mCubeMap->getPath();
  65. else if ( mTexSlot[i].texObject )
  66. texName = mTexSlot[i].texObject->getPath();
  67. else
  68. continue;
  69. desc += String::ToString( "TexSlot %d: %d, %s\n", i, mTexType[i], texName.c_str() );
  70. }
  71. // Write out the first render state which is the
  72. // basis for all the other states and shoud be
  73. // enough to define the pass uniquely.
  74. desc += mRenderStates[0]->getDesc().describeSelf();
  75. return desc;
  76. }
  77. ProcessedMaterial::ProcessedMaterial()
  78. : mMaterial( NULL ),
  79. mCurrentParams( NULL ),
  80. mHasSetStageData( false ),
  81. mHasGlow( false ),
  82. mHasAccumulation( false ),
  83. mMaxStages( 0 ),
  84. mVertexFormat( NULL ),
  85. mUserObject( NULL )
  86. {
  87. VECTOR_SET_ASSOCIATION( mPasses );
  88. }
  89. ProcessedMaterial::~ProcessedMaterial()
  90. {
  91. T3D::for_each( mPasses.begin(), mPasses.end(), T3D::delete_pointer() );
  92. }
  93. void ProcessedMaterial::_setBlendState(Material::BlendOp blendOp, GFXStateBlockDesc& desc )
  94. {
  95. switch( blendOp )
  96. {
  97. case Material::Add:
  98. {
  99. desc.blendSrc = GFXBlendOne;
  100. desc.blendDest = GFXBlendOne;
  101. break;
  102. }
  103. case Material::AddAlpha:
  104. {
  105. desc.blendSrc = GFXBlendSrcAlpha;
  106. desc.blendDest = GFXBlendOne;
  107. break;
  108. }
  109. case Material::Mul:
  110. {
  111. desc.blendSrc = GFXBlendDestColor;
  112. desc.blendDest = GFXBlendInvSrcAlpha;
  113. break;
  114. }
  115. case Material::PreMul:
  116. {
  117. desc.blendSrc = GFXBlendOne;
  118. desc.blendDest = GFXBlendInvSrcAlpha;
  119. break;
  120. }
  121. case Material::LerpAlpha:
  122. {
  123. desc.blendSrc = GFXBlendSrcAlpha;
  124. desc.blendDest = GFXBlendInvSrcAlpha;
  125. break;
  126. }
  127. case Material::Sub:
  128. {
  129. desc.blendOp = GFXBlendOpSubtract;
  130. desc.blendSrc = GFXBlendOne;
  131. desc.blendDest = GFXBlendOne;
  132. break;
  133. }
  134. case Material::PreMult:
  135. {
  136. desc.blendSrc = GFXBlendOne;
  137. desc.blendDest = GFXBlendInvSrcAlpha;
  138. break;
  139. }
  140. default:
  141. {
  142. // default to LerpAlpha
  143. desc.blendSrc = GFXBlendSrcAlpha;
  144. desc.blendDest = GFXBlendInvSrcAlpha;
  145. break;
  146. }
  147. }
  148. }
  149. void ProcessedMaterial::setBuffers(GFXVertexBufferHandleBase* vertBuffer, GFXPrimitiveBufferHandle* primBuffer)
  150. {
  151. GFX->setVertexBuffer( *vertBuffer );
  152. GFX->setPrimitiveBuffer( *primBuffer );
  153. }
  154. bool ProcessedMaterial::stepInstance()
  155. {
  156. AssertFatal( false, "ProcessedMaterial::stepInstance() - This type of material doesn't support instancing!" );
  157. return false;
  158. }
  159. String ProcessedMaterial::_getTexturePath(const String& filename)
  160. {
  161. // if '/', then path is specified, use it.
  162. if( filename.find('/') != String::NPos )
  163. {
  164. return filename;
  165. }
  166. // otherwise, construct path
  167. return mMaterial->getPath() + filename;
  168. }
  169. GFXTexHandle ProcessedMaterial::_createTexture( const char* filename, GFXTextureProfile *profile)
  170. {
  171. return GFXTexHandle( _getTexturePath(filename), profile, avar("%s() - NA (line %d)", __FUNCTION__, __LINE__) );
  172. }
  173. GFXTexHandle ProcessedMaterial::_createCompositeTexture(const char *filenameR, const char *filenameG, const char *filenameB, const char *filenameA, U32 inputKey[4], GFXTextureProfile *profile)
  174. {
  175. return GFXTexHandle(_getTexturePath(filenameR), _getTexturePath(filenameG), _getTexturePath(filenameB), _getTexturePath(filenameA), inputKey, profile, avar("%s() - NA (line %d)", __FUNCTION__, __LINE__));
  176. }
  177. void ProcessedMaterial::addStateBlockDesc(const GFXStateBlockDesc& sb)
  178. {
  179. mUserDefined = sb;
  180. }
  181. void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect)
  182. {
  183. // Translucency
  184. stateTranslucent.blendDefined = true;
  185. stateTranslucent.blendEnable = mMaterial->mTranslucentBlendOp != Material::None;
  186. _setBlendState(mMaterial->mTranslucentBlendOp, stateTranslucent);
  187. stateTranslucent.zDefined = true;
  188. stateTranslucent.zWriteEnable = mMaterial->mTranslucentZWrite;
  189. stateTranslucent.alphaDefined = true;
  190. stateTranslucent.alphaTestEnable = mMaterial->mAlphaTest;
  191. stateTranslucent.alphaTestRef = mMaterial->mAlphaRef;
  192. stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual;
  193. stateTranslucent.samplersDefined = true;
  194. stateTranslucent.samplers[0].textureColorOp = GFXTOPModulate;
  195. stateTranslucent.samplers[0].alphaOp = GFXTOPModulate;
  196. stateTranslucent.samplers[0].alphaArg1 = GFXTATexture;
  197. stateTranslucent.samplers[0].alphaArg2 = GFXTADiffuse;
  198. // Glow
  199. stateGlow.zDefined = true;
  200. stateGlow.zWriteEnable = false;
  201. // Reflect
  202. stateReflect.cullDefined = true;
  203. stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW;
  204. }
  205. void ProcessedMaterial::_initRenderPassDataStateBlocks()
  206. {
  207. for (U32 pass = 0; pass < mPasses.size(); pass++)
  208. _initRenderStateStateBlocks( mPasses[pass] );
  209. }
  210. void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc &result )
  211. {
  212. if ( rpd->mBlendOp != Material::None )
  213. {
  214. result.blendDefined = true;
  215. result.blendEnable = true;
  216. _setBlendState( rpd->mBlendOp, result );
  217. }
  218. if (mMaterial && mMaterial->isDoubleSided())
  219. {
  220. result.cullDefined = true;
  221. result.cullMode = GFXCullNone;
  222. }
  223. if(mMaterial && mMaterial->mAlphaTest)
  224. {
  225. result.alphaDefined = true;
  226. result.alphaTestEnable = mMaterial->mAlphaTest;
  227. result.alphaTestRef = mMaterial->mAlphaRef;
  228. result.alphaTestFunc = GFXCmpGreaterEqual;
  229. }
  230. result.samplersDefined = true;
  231. NamedTexTarget *texTarget;
  232. U32 maxAnisotropy = 1;
  233. if (mMaterial && mMaterial->mUseAnisotropic[ rpd->mStageNum ] )
  234. maxAnisotropy = MATMGR->getDefaultAnisotropy();
  235. for( U32 i=0; i < rpd->mNumTex; i++ )
  236. {
  237. U32 currTexFlag = rpd->mTexType[i];
  238. switch( currTexFlag )
  239. {
  240. default:
  241. {
  242. result.samplers[i].textureColorOp = GFXTOPModulate;
  243. result.samplers[i].addressModeU = GFXAddressWrap;
  244. result.samplers[i].addressModeV = GFXAddressWrap;
  245. if ( maxAnisotropy > 1 )
  246. {
  247. result.samplers[i].minFilter = GFXTextureFilterAnisotropic;
  248. result.samplers[i].magFilter = GFXTextureFilterAnisotropic;
  249. result.samplers[i].maxAnisotropy = maxAnisotropy;
  250. }
  251. else
  252. {
  253. result.samplers[i].minFilter = GFXTextureFilterLinear;
  254. result.samplers[i].magFilter = GFXTextureFilterLinear;
  255. }
  256. break;
  257. }
  258. case Material::Cube:
  259. case Material::SGCube:
  260. case Material::NormalizeCube:
  261. {
  262. result.samplers[i].addressModeU = GFXAddressClamp;
  263. result.samplers[i].addressModeV = GFXAddressClamp;
  264. result.samplers[i].addressModeW = GFXAddressClamp;
  265. result.samplers[i].minFilter = GFXTextureFilterLinear;
  266. result.samplers[i].magFilter = GFXTextureFilterLinear;
  267. break;
  268. }
  269. case Material::TexTarget:
  270. {
  271. texTarget = mPasses[0]->mTexSlot[i].texTarget;
  272. if ( texTarget )
  273. texTarget->setupSamplerState( &result.samplers[i] );
  274. break;
  275. }
  276. }
  277. }
  278. // The deferred will take care of writing to the
  279. // zbuffer, so we don't have to by default.
  280. if ( MATMGR->getDeferredEnabled() &&
  281. !mFeatures.hasFeature(MFT_ForwardShading))
  282. result.setZReadWrite( result.zEnable, false );
  283. result.addDesc(mUserDefined);
  284. }
  285. /// Creates the default state blocks for a list of render states
  286. void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
  287. {
  288. GFXStateBlockDesc stateTranslucent;
  289. GFXStateBlockDesc stateGlow;
  290. GFXStateBlockDesc stateReflect;
  291. GFXStateBlockDesc statePass;
  292. _initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect );
  293. _initPassStateBlock( rpd, statePass );
  294. // Ok, we've got our templates set up, let's combine them together based on state and
  295. // create our state blocks.
  296. for (U32 i = 0; i < RenderPassData::STATE_MAX; i++)
  297. {
  298. GFXStateBlockDesc stateFinal;
  299. if (i & RenderPassData::STATE_REFLECT)
  300. stateFinal.addDesc(stateReflect);
  301. if (i & RenderPassData::STATE_TRANSLUCENT)
  302. stateFinal.addDesc(stateTranslucent);
  303. if (i & RenderPassData::STATE_GLOW)
  304. stateFinal.addDesc(stateGlow);
  305. stateFinal.addDesc(statePass);
  306. if (i & RenderPassData::STATE_WIREFRAME)
  307. stateFinal.fillMode = GFXFillWireframe;
  308. GFXStateBlockRef sb = GFX->createStateBlock(stateFinal);
  309. rpd->mRenderStates[i] = sb;
  310. }
  311. }
  312. U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState,
  313. const SceneData &sgData )
  314. {
  315. // Based on what the state of the world is, get our render state block
  316. U32 currState = 0;
  317. // NOTE: We should only use per-material or per-pass hints to
  318. // change the render state. This is importaint because we
  319. // only change the state blocks between material passes.
  320. //
  321. // For example sgData.visibility would be bad to use
  322. // in here without changing how RenderMeshMgr works.
  323. if ( sgData.binType == SceneData::GlowBin )
  324. currState |= RenderPassData::STATE_GLOW;
  325. if ( sceneState && sceneState->isReflectPass() )
  326. currState |= RenderPassData::STATE_REFLECT;
  327. if ( sgData.binType != SceneData::DeferredBin &&
  328. mMaterial->isTranslucent() )
  329. currState |= RenderPassData::STATE_TRANSLUCENT;
  330. if ( sgData.wireframe )
  331. currState |= RenderPassData::STATE_WIREFRAME;
  332. return currState;
  333. }
  334. void ProcessedMaterial::_setRenderState( const SceneRenderState *state,
  335. const SceneData& sgData,
  336. U32 pass )
  337. {
  338. // Make sure we have the pass
  339. if ( pass >= mPasses.size() )
  340. return;
  341. U32 currState = _getRenderStateIndex( state, sgData );
  342. GFX->setStateBlock(mPasses[pass]->mRenderStates[currState]);
  343. }
  344. void ProcessedMaterial::_setStageData()
  345. {
  346. // Only do this once
  347. if (mHasSetStageData)
  348. return;
  349. mHasSetStageData = true;
  350. U32 i;
  351. // Load up all the textures for every possible stage
  352. for (i = 0; i < Material::MAX_STAGES; i++)
  353. {
  354. // DiffuseMap
  355. if (mMaterial->mDiffuseMapFilename[i].isNotEmpty())
  356. {
  357. mStages[i].setTex(MFT_DiffuseMap, _createTexture(mMaterial->mDiffuseMapFilename[i], &GFXStaticTextureSRGBProfile));
  358. if (!mStages[i].getTex(MFT_DiffuseMap))
  359. {
  360. //If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass. So we'll
  361. //pass on the error rather than spamming the console
  362. if (!mMaterial->mDiffuseMapFilename[i].startsWith("#"))
  363. mMaterial->logError("Failed to load diffuse map %s for stage %i", _getTexturePath(mMaterial->mDiffuseMapFilename[i]).c_str(), i);
  364. // Load a debug texture to make it clear to the user
  365. // that the texture for this stage was missing.
  366. mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
  367. }
  368. }
  369. else if (mMaterial->mDiffuseMapAsset[i] && !mMaterial->mDiffuseMapAsset[i].isNull())
  370. {
  371. mStages[i].setTex(MFT_DiffuseMap, mMaterial->mDiffuseMapAsset[i]->getImage());
  372. if (!mStages[i].getTex(MFT_DiffuseMap))
  373. {
  374. // Load a debug texture to make it clear to the user
  375. // that the texture for this stage was missing.
  376. mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
  377. }
  378. }
  379. // OverlayMap
  380. if (mMaterial->mOverlayMapFilename[i].isNotEmpty())
  381. {
  382. mStages[i].setTex(MFT_OverlayMap, _createTexture(mMaterial->mOverlayMapFilename[i], &GFXStaticTextureSRGBProfile));
  383. if (!mStages[i].getTex(MFT_OverlayMap))
  384. mMaterial->logError("Failed to load overlay map %s for stage %i", _getTexturePath(mMaterial->mOverlayMapFilename[i]).c_str(), i);
  385. }
  386. // LightMap
  387. if (mMaterial->mLightMapFilename[i].isNotEmpty())
  388. {
  389. mStages[i].setTex(MFT_LightMap, _createTexture(mMaterial->mLightMapFilename[i], &GFXStaticTextureSRGBProfile));
  390. if (!mStages[i].getTex(MFT_LightMap))
  391. mMaterial->logError("Failed to load light map %s for stage %i", _getTexturePath(mMaterial->mLightMapFilename[i]).c_str(), i);
  392. }
  393. // ToneMap
  394. if (mMaterial->mToneMapFilename[i].isNotEmpty())
  395. {
  396. mStages[i].setTex(MFT_ToneMap, _createTexture(mMaterial->mToneMapFilename[i], &GFXStaticTextureProfile));
  397. if (!mStages[i].getTex(MFT_ToneMap))
  398. mMaterial->logError("Failed to load tone map %s for stage %i", _getTexturePath(mMaterial->mToneMapFilename[i]).c_str(), i);
  399. }
  400. // DetailMap
  401. if (mMaterial->mDetailMapFilename[i].isNotEmpty())
  402. {
  403. mStages[i].setTex(MFT_DetailMap, _createTexture(mMaterial->mDetailMapFilename[i], &GFXStaticTextureProfile));
  404. if (!mStages[i].getTex(MFT_DetailMap))
  405. mMaterial->logError("Failed to load detail map %s for stage %i", _getTexturePath(mMaterial->mDetailMapFilename[i]).c_str(), i);
  406. }
  407. // NormalMap
  408. if (mMaterial->mNormalMapFilename[i].isNotEmpty())
  409. {
  410. mStages[i].setTex(MFT_NormalMap, _createTexture(mMaterial->mNormalMapFilename[i], &GFXNormalMapProfile));
  411. if (!mStages[i].getTex(MFT_NormalMap))
  412. mMaterial->logError("Failed to load normal map %s for stage %i", _getTexturePath(mMaterial->mNormalMapFilename[i]).c_str(), i);
  413. }
  414. // Detail Normal Map
  415. if (mMaterial->mDetailNormalMapFilename[i].isNotEmpty())
  416. {
  417. mStages[i].setTex(MFT_DetailNormalMap, _createTexture(mMaterial->mDetailNormalMapFilename[i], &GFXNormalMapProfile));
  418. if (!mStages[i].getTex(MFT_DetailNormalMap))
  419. mMaterial->logError("Failed to load normal map %s for stage %i", _getTexturePath(mMaterial->mDetailNormalMapFilename[i]).c_str(), i);
  420. }
  421. GFXTextureProfile* profile = &GFXStaticTextureProfile;
  422. if (mMaterial->mIsSRGb[i])
  423. profile = &GFXStaticTextureSRGBProfile;
  424. // PBRConfig
  425. if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty())
  426. {
  427. mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile));
  428. if (!mStages[i].getTex(MFT_PBRConfigMap))
  429. mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
  430. }
  431. else
  432. {
  433. if (mMaterial->mRoughMapFilename[i].isNotEmpty() && mMaterial->mMetalMapFilename[i].isNotEmpty())
  434. {
  435. U32 inputKey[4];
  436. inputKey[0] = mMaterial->mSmoothnessChan[i];
  437. inputKey[1] = mMaterial->mAOChan[i];
  438. inputKey[2] = mMaterial->mMetalChan[i];
  439. inputKey[3] = 0;
  440. mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
  441. mMaterial->mMetalMapFilename[i], "",
  442. inputKey, profile));
  443. if (!mStages[i].getTex(MFT_PBRConfigMap))
  444. mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
  445. }
  446. }
  447. if (mMaterial->mGlowMapFilename[i].isNotEmpty())
  448. {
  449. mStages[i].setTex(MFT_GlowMap, _createTexture(mMaterial->mGlowMapFilename[i], &GFXStaticTextureProfile));
  450. if (!mStages[i].getTex(MFT_GlowMap))
  451. mMaterial->logError("Failed to load glow map %s for stage %i", _getTexturePath(mMaterial->mGlowMapFilename[i]).c_str(), i);
  452. }
  453. }
  454. mMaterial->mCubemapData = dynamic_cast<CubemapData*>(Sim::findObject(mMaterial->mCubemapName));
  455. if (!mMaterial->mCubemapData)
  456. mMaterial->mCubemapData = NULL;
  457. // If we have a cubemap put it on stage 0 (cubemaps only supported on stage 0)
  458. if (mMaterial->mCubemapData)
  459. {
  460. mMaterial->mCubemapData->createMap();
  461. mStages[0].setCubemap(mMaterial->mCubemapData->mCubemap);
  462. if (!mStages[0].getCubemap())
  463. mMaterial->logError("Failed to load cubemap");
  464. }
  465. }