// |----------------------------------------------------------------------------| // | SunRender | // |----------------------------------------------------------------------------| bool GraphicsClass::SunRender(ModelClass& to_render, D3DXMATRIX scale, D3DXMATRIX translate, D3DXMATRIX rotate) { D3DXMATRIX scaleMatrix, translationMatrix, rotationMatrix; bool result = true; // Modify the world matrix as needed. D3DXMatrixIdentity(&worldMatrix); worldMatrix = scale * rotate * translate; // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. to_render.Render(m_D3D->GetDeviceContext()); // Render the model using the light shader. result = m_LightShader->Render(m_D3D->GetDeviceContext(), to_render.GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Light->GetPosition(), D3DXVECTOR4(0.99f,0.99f,0.99f,1.0f), m_Light->GetDiffuseColor(), m_Camera->GetPosition(), m_Light->GetSpecularColor(), m_Light->GetSpecularPower(), to_render.GetTexture()); return result; }
bool TerrainShaderClass::RenderShadowsDeferred(ID3D11DeviceContext* pDeviceContext, ObjectClass* pObject, CameraClass* pCamera, PointLightClass* pLights, ID3D11ShaderResourceView* pShadowmap, UINT indexCount, UINT indexStart) { bool result; unsigned int bufferNumber; // Set the position of the constant buffer in the vertex shader. bufferNumber = 0; result = SetShadowConstantBufferParamters(pDeviceContext, pObject, pCamera, pLights); if (!result) { return false; } ModelClass* pModel = pObject->GetModel(); pDeviceContext->PSSetShaderResources(0, 1, &pShadowmap); TextureClass* pTexture = pModel->GetDetailMap(); ID3D11ShaderResourceView** tex = pTexture->GetShaderResourceView(); // Set shader texture resource in the pixel shader. pDeviceContext->PSSetShaderResources(1, 1, tex); pTexture = pModel->GetNormalMap(); tex = pTexture->GetShaderResourceView(); // Set shader texture resource in the pixel shader. pDeviceContext->PSSetShaderResources(2, 1, tex); pTexture = pModel->GetTexture(); tex = pTexture->GetShaderResourceView(); // Set shader texture resource in the pixel shader. pDeviceContext->PSSetShaderResources(3, pTexture->GetTextureCount(), tex); pDeviceContext->PSSetSamplers(1, 1, &mPointSampleState); // Now render the prepared buffers with the shader. pDeviceContext->PSSetSamplers(0, 1, &mSampleState); // Set the vertex input layout. pDeviceContext->IASetInputLayout(mLayout); // Set the vertex and pixel shaders that will be used to render this triangle. pDeviceContext->VSSetShader(mShadowDeferredVS, nullptr, 0); pDeviceContext->HSSetShader(mHullShader, nullptr, 0); pDeviceContext->DSSetShader(mDomainShader, nullptr, 0); pDeviceContext->GSSetShader(mShadowDeferredGS, nullptr, 0); pDeviceContext->PSSetShader(mShadowDeferredPS, nullptr, 0); // Render mesh stored in active buffers pDeviceContext->DrawIndexed(indexCount, indexStart, 0); return true; }