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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user