diff options
author | Thomas Szepe <HG1_public@gmx.net> | 2015-03-24 01:56:46 +0300 |
---|---|---|
committer | Thomas Szepe <HG1_public@gmx.net> | 2015-03-24 01:56:46 +0300 |
commit | ce40fb9ab2616abefb79b12c3972e550b1df4660 (patch) | |
tree | c6fc667d6728c4e409cea4d6ad4908d06d12284d /source/gameengine/Converter | |
parent | 931c3e654404bbff05f1bcce9487fc6e91392300 (diff) |
BGE: World color management fix
This patch will fix the color management for the mist and global ambient color.
It will remove the old "Color Management" switch in the BGE "Render > Shading" panel and will use the "Display Device" setting in the "Scene > Color Management" panel instead.
Reviewers: moguri, brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D154
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Converter/BlenderWorldInfo.cpp | 40 | ||||
-rw-r--r-- | source/gameengine/Converter/BlenderWorldInfo.h | 4 |
3 files changed, 33 insertions, 13 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 6e3a321bfdf..3e7e104ed46 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1651,7 +1651,7 @@ static KX_GameObject *gameobject_from_blenderobject( case OB_FONT: { - bool do_color_management = !(blenderscene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT); + bool do_color_management = BKE_scene_check_color_management_enabled(blenderscene); /* font objects have no bounding box */ gameobj = new KX_FontObject(kxscene,KX_Scene::m_callbacks, rendertools, ob, do_color_management); diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index 40293d7479b..6daecccf15c 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -54,21 +54,16 @@ BlenderWorldInfo::BlenderWorldInfo(Scene *blenderscene, World *blenderworld) { if (blenderworld) { + m_do_color_management = BKE_scene_check_color_management_enabled(blenderscene); m_hasworld = true; m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); m_misttype = blenderworld->mistype; m_miststart = blenderworld->miststa; m_mistdistance = blenderworld->mistdist; m_mistintensity = blenderworld->misi; - copy_v3_v3(m_mistcolor, &blenderworld->horr); - copy_v3_v3(m_backgroundcolor, &blenderworld->horr); - copy_v3_v3(m_ambientcolor, &blenderworld->ambr); - - if (BKE_scene_check_color_management_enabled(blenderscene)) { - linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); - linearrgb_to_srgb_v3_v3(m_backgroundcolor, m_backgroundcolor); - linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor); - } + setMistColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); + setBackColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); + setAmbientColor(blenderworld->ambr, blenderworld->ambg, blenderworld->ambb); } else { m_hasworld = false; @@ -159,6 +154,13 @@ void BlenderWorldInfo::setBackColor(float r, float g, float b) m_backgroundcolor[0] = r; m_backgroundcolor[1] = g; m_backgroundcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_backgroundcolor, m_backgroundcolor); + } + else { + copy_v3_v3(m_con_backgroundcolor, m_backgroundcolor); + } } void BlenderWorldInfo::setMistType(short type) @@ -190,6 +192,13 @@ void BlenderWorldInfo::setMistColor(float r, float g, float b) m_mistcolor[0] = r; m_mistcolor[1] = g; m_mistcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_mistcolor, m_mistcolor); + } + else { + copy_v3_v3(m_con_mistcolor, m_mistcolor); + } } void BlenderWorldInfo::setAmbientColor(float r, float g, float b) @@ -197,6 +206,13 @@ void BlenderWorldInfo::setAmbientColor(float r, float g, float b) m_ambientcolor[0] = r; m_ambientcolor[1] = g; m_ambientcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_ambientcolor, m_ambientcolor); + } + else { + copy_v3_v3(m_con_ambientcolor, m_ambientcolor); + } } void BlenderWorldInfo::UpdateBackGround() @@ -205,7 +221,7 @@ void BlenderWorldInfo::UpdateBackGround() RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) { - m_rasterizer->SetBackColor(m_backgroundcolor); + m_rasterizer->SetBackColor(m_con_backgroundcolor); GPU_horizon_update_color(m_backgroundcolor); } } @@ -217,11 +233,11 @@ void BlenderWorldInfo::UpdateWorldSettings() RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) { - m_rasterizer->SetAmbientColor(m_ambientcolor); + m_rasterizer->SetAmbientColor(m_con_ambientcolor); GPU_ambient_update_color(m_ambientcolor); if (m_hasmist) { - m_rasterizer->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_mistcolor); + m_rasterizer->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_con_mistcolor); GPU_mist_update_values(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_mistcolor); m_rasterizer->EnableFog(true); GPU_mist_update_enable(true); diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index 395e8f723aa..5c1cbd28104 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -51,11 +51,15 @@ class BlenderWorldInfo : public KX_WorldInfo float m_mistcolor[3]; float m_backgroundcolor[3]; float m_ambientcolor[3]; + float m_con_mistcolor[3]; + float m_con_backgroundcolor[3]; + float m_con_ambientcolor[3]; public: BlenderWorldInfo(Scene *blenderscene, World *blenderworld); ~BlenderWorldInfo(); + bool m_do_color_management; bool hasWorld(); bool hasMist(); short getMistType(); |