Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stokes <kupomail@gmail.com>2013-07-20 02:54:02 +0400
committerDaniel Stokes <kupomail@gmail.com>2013-07-20 02:54:02 +0400
commita07ac7e6449cf3fde937b28580365ca20c415adc (patch)
treef7fe98da2f0efadd957536a5bd0b164735064333 /source/gameengine/Ketsji/KX_FontObject.cpp
parentd336ae8992435a000e5dfe8d6d24a0cf13a5c40a (diff)
BGE fix [#35563] Object colour setting for objects and fonts not using colour management like materials
Diffstat (limited to 'source/gameengine/Ketsji/KX_FontObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp24
1 files changed, 21 insertions, 3 deletions
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);
}
}