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; }