From 57281c6a5e07f5b362fb36284c8b14829c9dcd69 Mon Sep 17 00:00:00 2001 From: yvt Date: Fri, 1 Nov 2013 00:55:19 +0900 Subject: [PATCH] Desaturate effect --- Sources/Client/Client.cpp | 10 ++++++++-- Sources/Client/SceneDefinition.h | 2 ++ Sources/Draw/GLColorCorrectionFilter.cpp | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/Client/Client.cpp b/Sources/Client/Client.cpp index 03c359f3c..c9732e927 100644 --- a/Sources/Client/Client.cpp +++ b/Sources/Client/Client.cpp @@ -1610,8 +1610,14 @@ namespace spades { if(wTime < lastHurtTime + .15f && wTime >= lastHurtTime){ float per = 1.f - (wTime - lastHurtTime) / .15f; - per *= .5f + player->GetHealth() / 100.f * .3f; - def.blurVignette += per * 5.f; + per *= .5f - player->GetHealth() / 100.f * .3f; + def.blurVignette += per * 6.f; + } + if(wTime < lastHurtTime + .2f && + wTime >= lastHurtTime){ + float per = 1.f - (wTime - lastHurtTime) / .2f; + per *= .5f - player->GetHealth() / 100.f * .3f; + def.saturation *= std::max(0.f, 1.f - per * 4.f); } } diff --git a/Sources/Client/SceneDefinition.h b/Sources/Client/SceneDefinition.h index e10918e6b..fe7ffeaea 100644 --- a/Sources/Client/SceneDefinition.h +++ b/Sources/Client/SceneDefinition.h @@ -39,12 +39,14 @@ namespace spades { bool denyCameraBlur; float blurVignette; + float saturation; SceneDefinition() { depthOfFieldNearRange = 0.f; denyCameraBlur = true; time = 0; blurVignette = 0.f; + saturation = 1.f; } }; } diff --git a/Sources/Draw/GLColorCorrectionFilter.cpp b/Sources/Draw/GLColorCorrectionFilter.cpp index c81a089ab..a5c95662b 100644 --- a/Sources/Draw/GLColorCorrectionFilter.cpp +++ b/Sources/Draw/GLColorCorrectionFilter.cpp @@ -62,13 +62,14 @@ namespace spades { lens->Use(); + const client::SceneDefinition& def = renderer->GetSceneDef(); if(r_bloom) { // make image sharper - saturation.SetValue(.85f); + saturation.SetValue(.85f * def.saturation); enhancement.SetValue(0.7f); }else{ - saturation.SetValue(1.f); + saturation.SetValue(1.f * def.saturation); enhancement.SetValue(0.3f); }