Example #1
0
void VBlobShadowShader::UpdateShadow(const VBlobShadow *pShadow)
{
  if (m_iShadowTexSampler>=0)
  {
    VStateGroupTexture *pStateGroupTexture = GetStateGroupTexture(VSS_PixelShader, m_iShadowTexSampler);
    if (pStateGroupTexture != NULL)
      pStateGroupTexture->m_spCustomTex = pShadow->GetShadowTexture();
  }

  // update the uv projection planes
  const float fSizeX = pShadow->m_ShadowBox.getSizeX();
  const float fSizeY = pShadow->m_ShadowBox.getSizeY();

  hkvPlane planeU; 
  planeU.m_vNormal = hkvVec3(1.f/fSizeX, 0, 0);  
  planeU.m_fNegDist = -planeU.m_vNormal.dot (pShadow->m_ShadowBox.m_vMin);

  hkvPlane planeV; 
  planeV.m_vNormal = hkvVec3(0, 1.f/fSizeY, 0);  
  planeV.m_fNegDist = -planeV.m_vNormal.dot (pShadow->m_ShadowBox.m_vMin);

  GetConstantBuffer(VSS_VertexShader)->SetSingleRegisterF(m_iRegPlaneU, &planeU.m_vNormal.x);
  GetConstantBuffer(VSS_VertexShader)->SetSingleRegisterF(m_iRegPlaneV, &planeV.m_vNormal.x);

  // shadow color
  GetConstantBuffer(VSS_PixelShader)->SetSingleRegisterF(m_iRegColor, pShadow->m_vBlendColor.data);

  m_bModified = true;
}
Example #2
0
 /// \brief
 ///  For shadowmap lights only:  sets the shadowmap texture that will be used to modulate the light's framebuffer contribution.
 inline void SetShadowTexture(VTextureObject *pTex)
 {
   if (m_iSamplerShadowTexture>=0)
   {
     VStateGroupTexture *pStateGroupTexture = GetStateGroupTexture(VSS_PixelShader, m_iSamplerShadowTexture);
     if (pStateGroupTexture != NULL)
       pStateGroupTexture->m_spCustomTex = pTex;
   }
 }