BGE: Fix T43822 Videotexture does not use sky color for off-screen
rendering Make scene background color as default for render-to-texture instead of current blue color (0, 0, 255). It is very useful for mirrors setups. Reviewers: moguri, ben2610, sybren, panzergame, hg1 Reviewed By: panzergame, hg1, moguri Subscribers: mpan3 Differential Revision: https://developer.blender.org/D1287
This commit is contained in:
parent
583fd3af65
commit
dc95ca92ca
Notes:
blender-bot
2023-02-14 10:03:42 +01:00
Referenced by issue #44663, Corrective smooth apply as shape key does not work Referenced by issue #43822, Videotexture does not use sky color for off-screen rendering Referenced by issue #41893, sculpting error with stencil mapping of texture
|
@ -100,6 +100,11 @@ void KX_WorldInfo::setBackColor(float r, float g, float b)
|
|||
}
|
||||
}
|
||||
|
||||
const float *KX_WorldInfo::getBackColor(void) const
|
||||
{
|
||||
return m_backgroundcolor;
|
||||
}
|
||||
|
||||
void KX_WorldInfo::setMistType(short type)
|
||||
{
|
||||
m_misttype = type;
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
void setMistIntensity(float intensity);
|
||||
void setMistColor(float r, float g, float b);
|
||||
void setBackColor(float r, float g, float b);
|
||||
const float *getBackColor() const;
|
||||
void setAmbientColor(float r, float g, float b);
|
||||
void UpdateBackGround();
|
||||
void UpdateWorldSettings();
|
||||
|
|
|
@ -75,8 +75,8 @@ ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera) :
|
|||
m_mirrorHalfWidth(0.f),
|
||||
m_mirrorHalfHeight(0.f)
|
||||
{
|
||||
// initialize background color
|
||||
setBackground(0, 0, 255, 255);
|
||||
// initialize background color to scene background color as default
|
||||
setBackgroundFromScene(m_scene);
|
||||
// retrieve rendering objects
|
||||
m_engine = KX_GetActiveEngine();
|
||||
m_rasterizer = m_engine->GetRasterizer();
|
||||
|
@ -100,6 +100,18 @@ void ImageRender::setBackground (int red, int green, int blue, int alpha)
|
|||
m_background[3] = (alpha < 0) ? 0.f : (alpha > 255) ? 1.f : float(alpha)/255.f;
|
||||
}
|
||||
|
||||
// set background color from scene
|
||||
void ImageRender::setBackgroundFromScene (KX_Scene *scene)
|
||||
{
|
||||
if (scene) {
|
||||
const float *background_color = scene->GetWorldInfo()->getBackColor();
|
||||
setBackground((int) (background_color[0] * 255.0f), (int) (background_color[1] * 255.0f), (int) (background_color[2] * 255.0f), 255);
|
||||
}
|
||||
else {
|
||||
setBackground(0, 0, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// capture image from viewport
|
||||
void ImageRender::calcImage (unsigned int texId, double ts)
|
||||
|
@ -733,7 +745,8 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec
|
|||
m_mirrorX = m_mirrorY.cross(m_mirrorZ);
|
||||
m_render = true;
|
||||
|
||||
setBackground(0, 0, 255, 255);
|
||||
// set mirror background color to scene background color as default
|
||||
setBackgroundFromScene(m_scene);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ protected:
|
|||
void Render();
|
||||
void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam);
|
||||
void RenderFrame(KX_Scene* scene, KX_Camera* cam);
|
||||
void SetBackGround(KX_WorldInfo* wi);
|
||||
void setBackgroundFromScene(KX_Scene *scene);
|
||||
void SetWorldSettings(KX_WorldInfo* wi);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue