You see, I'm developing an app that is meant to be directly captured by live streaming software (OBS, XSplit, etc.) to overlay 3D characters and effects on top of a live stream broadcast with sites like Twitch. The main feature here is that the rendering is done on RTT with a background color of 0,0,0,0 (fully transparent), so individual objects in the world can be rendered on top of the user's broadcasts without covering everything up with a background.
It's been working great, but I've finally decided to work in some particle effects with blending. I've got a simple green blob particle effect using additive blending, but there's a problem - if the particles aren't being rendered in front of something else, the black boxes around them aren't being ignored in the blending like they should. If the effect is in front of something, it looks perfectly fine.
Here's an example video:
[youtube]rVOXbdUYdhk[/youtube]
As you can see, the particles look nice and smooth while in front of the mask, but they look ugly once they reach the background.
I'm creating my RTT in Mogre 1.7.1 like this:
Code: Select all
// RTT and viewport
rttTexPtr = TextureManager.Singleton.CreateManual(StringHelp.MakeUniqueString("RttTex"), ResourceGroupManager.AUTODETECT_RESOURCE_GROUP_NAME, Mogre.TextureType.TEX_TYPE_2D, 1280, 720, 0, PixelFormat.PF_A8B8G8R8, (int)Mogre.TextureUsage.TU_RENDERTARGET, null, false, 4);
rttTex = rttTexPtr.GetBuffer().GetRenderTarget();
mViewport = rttTex.AddViewport(mCamera);
mViewport.SetClearEveryFrame(true);
mViewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 0.0f);
Code: Select all
material Particles/Flare
{
technique
{
pass
{
lighting off
scene_blend add
depth_write off
texture_unit
{
texture flare.png
}
}
}
}
Code: Select all
particle_system Test
{
material Particles/Flare
particle_width 6
particle_height 6
cull_each false
quota 100
billboard_type point
emitter Ellipsoid
{
angle 30
emission_rate 15
time_to_live_min 8
time_to_live_max 10
direction 0 1 0
velocity 1.0
colour 0 1 0
width 5
height 5
depth 5
}
affector ColourFader
{
alpha -0.2
}
}
One thing I tried was to use scene_blend alpha_blend in the material instead, using a transparent flare png. That solved the problem of looking strange while not in front of anything, but introduced a new problem where any objects behind the particles had their alpha set to the particles' alpha, thus cutting holes in them.
Any tips?