diff options
author | Daniel Stokes <kupomail@gmail.com> | 2013-07-20 02:54:02 +0400 |
---|---|---|
committer | Daniel Stokes <kupomail@gmail.com> | 2013-07-20 02:54:02 +0400 |
commit | a07ac7e6449cf3fde937b28580365ca20c415adc (patch) | |
tree | f7fe98da2f0efadd957536a5bd0b164735064333 | |
parent | d336ae8992435a000e5dfe8d6d24a0cf13a5c40a (diff) |
BGE fix [#35563] Object colour setting for objects and fonts not using colour management like materials
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_FontObject.cpp | 24 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_FontObject.h | 5 |
3 files changed, 27 insertions, 5 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 4890db193eb..99613f8bd99 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2085,8 +2085,9 @@ static KX_GameObject *gameobject_from_blenderobject( case OB_FONT: { + bool do_color_management = !(blenderscene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT); /* font objects have no bounding box */ - gameobj = new KX_FontObject(kxscene,KX_Scene::m_callbacks, rendertools, ob); + gameobj = new KX_FontObject(kxscene,KX_Scene::m_callbacks, rendertools, ob, do_color_management); /* add to the list only the visible fonts */ if ((ob->lay & kxscene->GetBlenderScene()->lay) != 0) diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 95798900ccc..162c1f8d294 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -76,12 +76,14 @@ static std::vector<STR_String> split_string(STR_String str) KX_FontObject::KX_FontObject(void* sgReplicationInfo, SG_Callbacks callbacks, RAS_IRenderTools* rendertools, - Object *ob): + Object *ob, + bool do_color_management): KX_GameObject(sgReplicationInfo, callbacks), m_object(ob), m_dpi(72), m_resolution(1.f), - m_rendertools(rendertools) + m_rendertools(rendertools), + m_do_color_management(do_color_management) { Curve *text = static_cast<Curve *> (ob->data); m_text = split_string(text->str); @@ -174,6 +176,22 @@ void KX_FontObject::DrawText() /* update the animated color */ this->GetObjectColor().getValue(m_color); + /* Font Objects don't use the glsl shader, this color management code is copied from gpu_shader_material.glsl */ + float color[4]; + for (int i = 0; i < 3; i++) { + if (m_do_color_management) { + float c = m_color[i]; + if(c < 0.0031308) + c = (c < 0.0) ? 0.0: c * 12.92; + else + c = 1.055 * pow(c, 1.0/2.4) - 0.055; + color[i] = c; + } + else + color[i] = m_color[i]; + } + color[3] = m_color[3]; + /* HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly */ const float RES = BGE_FONT_RES * m_resolution; @@ -201,7 +219,7 @@ void KX_FontObject::DrawText() mat[13] -= spacing[1]; mat[14] -= spacing[2]; } - m_rendertools->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, m_color, mat, aspect); + m_rendertools->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect); } } diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index ac22de6fb6f..3d8c1d99dcc 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -42,7 +42,8 @@ public: KX_FontObject(void* sgReplicationInfo, SG_Callbacks callbacks, RAS_IRenderTools* rendertools, - Object *ob); + Object *ob, + bool do_color_management); virtual ~KX_FontObject(); @@ -69,6 +70,8 @@ protected: class RAS_IRenderTools* m_rendertools; //needed for drawing routine + bool m_do_color_management; + #ifdef WITH_PYTHON static PyObject* pyattr_get_text(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); |