コード例 #1
0
//
// Runtime / rendering
//
bool ProcessedShaderMaterial::setupPass( SceneRenderState *state, const SceneData &sgData, U32 pass )
{
   PROFILE_SCOPE( ProcessedShaderMaterial_SetupPass );

   // Make sure we have the pass
   if(pass >= mPasses.size())
   {
      // If we were rendering instanced data tell
      // the device to reset that vb stream.
      if ( mInstancingState )
         GFX->setVertexBuffer( NULL, 1 );

      return false;
   }

   _setRenderState( state, sgData, pass );

   // Set shaders
   ShaderRenderPassData* rpd = _getRPD(pass);
   if( rpd->shader )
   {
      GFX->setShader( rpd->shader );
      GFX->setShaderConstBuffer(_getShaderConstBuffer(pass));      
      _setShaderConstants(state, sgData, pass);      

      // If we're instancing then do the initial step to get
      // set the vb pointer to the const buffer.
      if ( mInstancingState )
         stepInstance();
   }
   else
   {
      GFX->disableShaders();
      GFX->setShaderConstBuffer(NULL);
   } 

   // Set our textures
   setTextureStages( state, sgData, pass );
   _setTextureTransforms(pass);

   return true;
}
コード例 #2
0
bool ProcessedCustomMaterial::setupPass( SceneRenderState *state, const SceneData& sgData, U32 pass )
{
   PROFILE_SCOPE( ProcessedCustomMaterial_SetupPass );

   // Make sure we have a pass.
   if ( pass >= mPasses.size() )
      return false;

   ShaderRenderPassData* rpd = _getRPD( pass );
   U32 currState = _getRenderStateIndex( state, sgData );
   GFX->setStateBlock(rpd->mRenderStates[currState]);      

   // activate shader
   if ( rpd->shader )
      GFX->setShader( rpd->shader );
   else
      GFX->disableShaders();

   // Set our textures   
   setTextureStages( state, sgData, pass );   
   
   GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
   GFX->setShaderConstBuffer(shaderConsts);
   
   // Set our shader constants.
   _setTextureTransforms(pass);
   _setShaderConstants(state, sgData, pass);

   LightManager* lm = state ? LIGHTMGR : NULL;
   if (lm)
      lm->setLightInfo(this, NULL, sgData, state, pass, shaderConsts);

   shaderConsts->setSafe(rpd->shaderHandles.mAccumTimeSC, MATMGR->getTotalTime());   

   return true;
}