bool DirectxEngine::UpdateShader(const MeshData& mesh, const IScene& scene, bool alphaBlend, float timer) { const int index = mesh.ShaderID(); if (index != NO_INDEX) { auto& shader = m_data->shaders[index]; if(index != m_data->selectedShader) { SetSelectedShader(index); SendLights(scene.Lights()); shader->UpdateConstantMatrix("viewProjection", m_data->viewProjection); shader->UpdateConstantFloat("cameraPosition", &m_data->cameraPosition.x, 3); shader->UpdateConstantFloat("depthNear", &scene.Post().DepthNear(), 1); shader->UpdateConstantFloat("depthFar", &scene.Post().DepthFar(), 1); if (index == WATER_SHADER) { shader->UpdateConstantFloat("timer", &timer, 1); } } SendTextures(mesh.TextureIDs()); SetRenderState(mesh.BackfaceCull(), m_data->isWireframe); EnableAlphaBlending(alphaBlend, false); return true; } return false; }
void DirectxEngine::Render(const IScene& scene, float timer) { RenderSceneMap(scene, timer); RenderPreEffects(scene.Post()); RenderBlur(scene.Post()); RenderPostProcessing(scene.Post()); m_data->swapchain->Present(0, 0); }
bool DirectxEngine::UpdateShader(const Emitter& emitter, const IScene& scene) { const int index = emitter.ShaderID(); if (index != NO_INDEX) { auto& shader = m_data->shaders[index]; if (index != m_data->selectedShader) { SetSelectedShader(index); shader->UpdateConstantFloat("depthNear", &scene.Post().DepthNear(), 1); shader->UpdateConstantFloat("depthFar", &scene.Post().DepthFar(), 1); } shader->UpdateConstantFloat("tint", &emitter.Tint().r, 4); SetRenderState(false, m_data->isWireframe); EnableAlphaBlending(true, false); return true; } return false; }