forked from bartvdbraak/blender
BGE fix [#35563] Object colour setting for objects and fonts not using colour management like materials
This commit is contained in:
parent
d336ae8992
commit
a07ac7e644
@ -2085,8 +2085,9 @@ static KX_GameObject *gameobject_from_blenderobject(
|
|||||||
|
|
||||||
case OB_FONT:
|
case OB_FONT:
|
||||||
{
|
{
|
||||||
|
bool do_color_management = !(blenderscene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT);
|
||||||
/* font objects have no bounding box */
|
/* 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 */
|
/* add to the list only the visible fonts */
|
||||||
if ((ob->lay & kxscene->GetBlenderScene()->lay) != 0)
|
if ((ob->lay & kxscene->GetBlenderScene()->lay) != 0)
|
||||||
|
@ -76,12 +76,14 @@ static std::vector<STR_String> split_string(STR_String str)
|
|||||||
KX_FontObject::KX_FontObject(void* sgReplicationInfo,
|
KX_FontObject::KX_FontObject(void* sgReplicationInfo,
|
||||||
SG_Callbacks callbacks,
|
SG_Callbacks callbacks,
|
||||||
RAS_IRenderTools* rendertools,
|
RAS_IRenderTools* rendertools,
|
||||||
Object *ob):
|
Object *ob,
|
||||||
|
bool do_color_management):
|
||||||
KX_GameObject(sgReplicationInfo, callbacks),
|
KX_GameObject(sgReplicationInfo, callbacks),
|
||||||
m_object(ob),
|
m_object(ob),
|
||||||
m_dpi(72),
|
m_dpi(72),
|
||||||
m_resolution(1.f),
|
m_resolution(1.f),
|
||||||
m_rendertools(rendertools)
|
m_rendertools(rendertools),
|
||||||
|
m_do_color_management(do_color_management)
|
||||||
{
|
{
|
||||||
Curve *text = static_cast<Curve *> (ob->data);
|
Curve *text = static_cast<Curve *> (ob->data);
|
||||||
m_text = split_string(text->str);
|
m_text = split_string(text->str);
|
||||||
@ -174,6 +176,22 @@ void KX_FontObject::DrawText()
|
|||||||
/* update the animated color */
|
/* update the animated color */
|
||||||
this->GetObjectColor().getValue(m_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 */
|
/* HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly */
|
||||||
const float RES = BGE_FONT_RES * m_resolution;
|
const float RES = BGE_FONT_RES * m_resolution;
|
||||||
|
|
||||||
@ -201,7 +219,7 @@ void KX_FontObject::DrawText()
|
|||||||
mat[13] -= spacing[1];
|
mat[13] -= spacing[1];
|
||||||
mat[14] -= spacing[2];
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ public:
|
|||||||
KX_FontObject(void* sgReplicationInfo,
|
KX_FontObject(void* sgReplicationInfo,
|
||||||
SG_Callbacks callbacks,
|
SG_Callbacks callbacks,
|
||||||
RAS_IRenderTools* rendertools,
|
RAS_IRenderTools* rendertools,
|
||||||
Object *ob);
|
Object *ob,
|
||||||
|
bool do_color_management);
|
||||||
|
|
||||||
virtual ~KX_FontObject();
|
virtual ~KX_FontObject();
|
||||||
|
|
||||||
@ -69,6 +70,8 @@ protected:
|
|||||||
|
|
||||||
class RAS_IRenderTools* m_rendertools; //needed for drawing routine
|
class RAS_IRenderTools* m_rendertools; //needed for drawing routine
|
||||||
|
|
||||||
|
bool m_do_color_management;
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
static PyObject* pyattr_get_text(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
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);
|
static int pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||||
|
Loading…
Reference in New Issue
Block a user