VParticleWallmarkGroup::VParticleWallmarkGroup(int iCount, VTextureObject *pTexture, VIS_TransparencyType eBlending, bool bApplyDeferredLighting)
{
  m_iCacheCount = hkvMath::Min(iCount,MAX_WALLMARK_CACHE_SIZE);
  for (int i=0;i<m_iCacheCount;i++)
    m_iCacheIndex[i] = m_iCacheCount-1-i;

  m_bApplyDeferredLighting = bApplyDeferredLighting;
  m_bHasFreeParticles = true;
  m_bBBoxValid = true;

  SetParticleStride(sizeof(VParticleWallmark),0);
  Init( 0, iCount);
  SetTextureObject(pTexture);
  SetTransparencyType(eBlending);
  SetUseNormals(true);
  SetUseDistortion(true);
  SetParticleCenter(0.5f,0.5f); // centered

  if (m_bApplyDeferredLighting)
  {
#ifdef HK_DEBUG
    VType *pDeferredType = Vision::GetTypeManager()->GetType("VDeferredRenderingSystem");
    VASSERT_MSG(pDeferredType!=NULL && Vision::Renderer.IsRendererNodeOfType(pDeferredType),"bApplyDeferredLighting=true may only be passed when a deferred renderer is set");
#endif
    VShaderEffectLib *pLib = Vision::GetApplication()->GetShaderProvider()->LoadDefaultParticleShaderLib();
    VCompiledTechnique *pTech = Vision::Shaders.CreateTechnique("DeferredLitParticles",NULL,NULL,EFFECTCREATEFLAG_NONE, pLib);
    SetRenderOrder(VRH_PRE_OCCLUSION_TESTS);  // rendered as part of g-buffer geometry
    this->SetTechnique(pTech);
  } else
  {
    SetRenderOrder(VRH_DECALS);  // wallmarks must be rendered before other particles
  }
    
  SetObjectFlag(VObjectFlag_AutoDispose);
}
 ShaderParamTextureCubeMap::ShaderParamTextureCubeMap(const std::string &name) :
    ShaderParamTexture(name)
 {
    SetShared(true); // we want to share Textures by default
    SetTextureObject(*(new osg::TextureCubeMap()));
 }