Hey there,
I’m trying to render to a texture that has it’s background color set to (0, 0, 0, 0).
My code looks like this:
RenderTexture = MakeShared<Texture2D>(parent.GetContext());
RenderTexture->SetSize(500, 500, Graphics::GetRGBAFormat(), TEXTURE_RENDERTARGET);
RenderTexture->SetFilterMode(FILTER_BILINEAR);
RenderMaterial = MakeShared<Material>(parent.GetContext());
RenderMaterial->SetTechnique(0, cache->GetResource<Technique>("Techniques/DiffUnlitAlpha.xml"));
RenderMaterial->SetTexture(TU_DIFFUSE, RenderTexture);
RenderMaterial->SetCullMode(CullMode::CULL_NONE);
OrthoScene = MakeShared<Scene>(parent.GetContext());
//setup a scene with an orthographic camera here
auto *surface = RenderTexture->GetRenderSurface();
auto vp = MakeShared<Viewport>(parent.GetContext(), OrthoScene, camera);
surface->SetViewport(0, vp);
auto *rp = vp->GetRenderPath();
for(unsigned i = 0; i < rp->GetNumCommands(); i++)
{
RenderPathCommand *cmd = rp->GetCommand(i);
if(cmd->type_ == RenderCommandType::CMD_CLEAR)
{
cmd->useFogColor_ = false;
cmd->clearColor_ = Color(0, 0, 0, 0);
}
}
auto *quad = SceneNode->CreateComponent<CustomGeometry>();
quad->SetMaterial(RenderMaterial);
//setup quad here
I’ve been able to set the background color to a custom value by modifying clearColor_, but setting the alpha value has no effect.
Am I missing something?
Thanks!