示例#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;
}
示例#2
0
////////////////////////////////////////////////////////////////////////////////////////////////
// overridden function to extract the shader registers from the compiled version
void VBlobShadowShader::PostCompileFunction(VShaderEffectResource *pSourceFX,VShaderPassResource *pSourceShader)
{
  VCompiledShaderPass::PostCompileFunction(pSourceFX, pSourceShader);

  m_iRegPlaneU = GetConstantBuffer(VSS_VertexShader)->GetRegisterByName("TexRefPlaneU");
  m_iRegPlaneV = GetConstantBuffer(VSS_VertexShader)->GetRegisterByName("TexRefPlaneV");
  VASSERT(m_iRegPlaneU>=0 && m_iRegPlaneV>=0);

  m_iRegColor = GetConstantBuffer(VSS_PixelShader)->GetRegisterByName("ShadowColor");

  VASSERT(m_iRegColor>=0);

  m_iShadowTexSampler   = GetSamplerIndexByName(VSS_PixelShader, "ShadowTexture");
  m_iGradientTexSampler = GetSamplerIndexByName(VSS_PixelShader, "NormalGradient");
}
示例#3
0
void CEffectPixelShader::SetConstantBuffer(unsigned int IdBuffer, void *ConstantBuffer)
{
	ID3D11DeviceContext *l_DeviceContext = UABEngine.GetRenderManager()->GetDeviceContext();
	ID3D11Buffer *l_ConstantBuffer = GetConstantBuffer(IdBuffer);
	l_DeviceContext->UpdateSubresource(l_ConstantBuffer, 0, NULL,
		ConstantBuffer, 0, 0);
	l_DeviceContext->PSSetConstantBuffers(IdBuffer, 1, &l_ConstantBuffer);
}
void CEffectGeometryShader::SetConstantBuffer(unsigned int IdBuffer, void
										   *ConstantBuffer)
{
	ID3D11DeviceContext *l_DeviceContext = CEngine::GetSingleton().getContextManager()->GetDeviceContext();
	ID3D11Buffer *l_ConstantBuffer = GetConstantBuffer(IdBuffer);
	if (l_ConstantBuffer)
	{
		l_DeviceContext->UpdateSubresource(l_ConstantBuffer, 0, NULL,
										   ConstantBuffer, 0, 0);
		l_DeviceContext->GSSetConstantBuffers(IdBuffer, 1, &l_ConstantBuffer);
	}
}