Jump to content

[SOLVED] alpha channel data is not correct


photo

Recommended Posts

Posted

Hi,
We are developing a project based on Unigine about video application. 

OS:            windows x64 chinese
Graphics Card: Nvidia GTX 770\GTX 780
VS Version:    Visual Studio 2010
Unigine SDK:   Unigine 2014-0707
Render API :   DXSDK_Jun10

In our project, we must get buffer of DX11 RenderViewTarget with RGBA format, and we focus on the Alpha channel data very much.
So we set BackgroundColor as Vec4(0,1,0,0)   [RED,GREEN,BLUE,ALPHA], Unigine should clear viewport with this color. In the pure Widget/GDI Scene, 
we get pixel color of blank region as Vec4(0,1,0,0), all is OK. But, In the 3D Animation Scene, we get pixel color of blank region as Vec4(0,
1,0,1). The ALPHA is not right!

Please tell us how we can get the right ALPHA channel data in the 3D Animation Scene.

Thanks and waiting for ur reply.

Ian

Posted

Hello, Ian!

 

Am I understand you correctly that when the engine clears framebuffer (before actual frame rendering) with transparent green color everything is ok and after it finishes rendering it's putting wrong alpha on a whole frame, right?

 

Could you please give us more details about how you're relying on alpha channel data?

Posted

Hi Unclebob,

 

For our case, we want to do the video mixing, so we want to do the video mix with two video stream. The foreground video stream is from the engine, the other one could be an external video stream from a camera or so used as background.  

 

So we are relying on the alpha channel data.

 

I tried the alpha data, it works before open any 3d scene. '

For example. in the samples' menu screen (only a widget with a background), we set the backgroundcolor vec4(0, 1, 0, 0),  the alpha channel works.  The samples' menu will be mixed on top pf the background video.

After we opened a 3d scene, alpha channel seems do not work. 

 

Regards,

Ian

  • 2 weeks later...
Posted

Thanks for the reply, silent.

 

It fixed the issue.

 

BTW, for our case, we want to overlay the engine's video on top of another input video.  We tried with the provided fix, and it works for the most cases.

 

For some particular case, like the glass material which it has alpha value between 0 and 1, if we set the scene's background as black and transparent, the glass will blend with the black, then mix with the background video.

 

Is there any way that we can force the glass do not blend with black, and use its alpha value to mix with the background video directly?

 

Regards,

Ian

  • 2 weeks later...
Posted

Hi Ian,

 

Try to use WidgetSpriteVideo widget to play your video as a background. That way you'll achieve proper results with transparent objects.

 

If that's not possible in your case then I recommend to render each frame twice: first time with transparent background (imagine this as a mask for blending) and second time with your background video. By doing so, you'll have mask and frame image so you'll be able to do blending outside the engine.

  • 2 years later...
Posted

@silent, the same issue/problem we encountered again in the new release. fragment_composite is no longer there.

Please help, we will do the video mixing in the newer version, and upgrading our application. But encounter the same issue.

Posted

Hi Ian,

 

I'm afraid we need to check the small test sample with that issue so we can debug it on our side. Could you please provide a small test scene for reproduction?

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Hi Silent,

It will be difficult to provide a test sample. We have hardware video IO SDI card, and our source code related to this, to set up the full environment.

 

Basically, what we did is video mix. overlay the engine 3d scene (foreground) with an external video feed as background.

What we did before is, when we opened a 3d scene, we set the backgroundcolor vec4(0, 1, 0, 0),  the alpha channel works.

In the new version, it no longer works.

 

In the previous post in this thread, we described the issue, and at that time, "fragment_composite.shader" fix works well for us. And unigine bring that into the update later on.

In the new version, the alpha channel issue comes up again.

Posted

Hi Silent,

 

We just tried again. When the engine only open GUI, the alpha channel is right. The blank area in the background will be transparent,. and we can get the alpha channel and overlay on the external video feed.

 

After we open a 3d scene, the blank area's alpha channel is no longer transparent. Which is the same case as the very beginning of this thread.

Back in Unigine 1.0, we found this issue. It was fixed by the provided "fragment_composite.shader" in the reply and the fix has been merged to the following update.

 

In the new versions, the issue comes up again.

Because our use case is not that common for other uses, we built a video application on top of the unigine core, and highly depends on alpha channel when we are doing broadcaster level augmented reality.

The issue is very important to us. Please help us to resolve this issue.

 

Thanks,

Ian

Posted

Hi Ian,

 

Render pipeline is very different now and old shader just give us no idea right now.

 

What we really interested in:

  1. Sample .world file with all the settings configured (Environment lut texutres, common rendering settings and post-processig) + blank cpp file;
  2. Small C++ or whatsoever application with main loop and only functions required that are doing render to texture and saving that texture (so we can check what is going on).

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted
Hi ,

 

We change the shader shaders/screen_space/fragment/composite.frag, we change the OUT_COLOR at the bottom of the shader file, replace the red data to alpha data,

 

OUT_COLOR.r = OUT_COLOR.a;

 

After change the shader, the background of 3D scene change to red.

 

This simple test prove the alpha isn't zero, but it is 255.

 

You can use this way to test the alpha.

 

Thanks!

Posted

Hi,

 

Have you found the problem that I presented before?

 

We are time bound of this.

 

Thanks

Posted

Hi zhengwenxin,

 

Not yet. We are still investigating. Could you please provide a small test scene (basically, just .world + .cpp file with actual rendering settings) that you are using and specify (at least on a screenshot) where should be a correct alpha?

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Hi,

 

The attachment is the shader and the screenshot  that I changed.

 

The background should be transparent, but now it isn't. This prove the alpha data is not zero.

 

Thanks!

composite.frag

post-1676-0-01072500-1491468784_thumb.png

Posted

Hi,

 

It's a long time that we commit this question, but you didn't give us a useful feedback.

 

We are really need this , so please speed some time to solve this.

 

Thanks,

Posted

Hi Ian,

 

Sorry for the late reply.

Could you please check that you have enabled 16bit color (Rendering -> Buffers -> Color 16F)? Also you can disable Environment (Rendering -> Features -> Environment).

The next step will be to modify Environment color: Rendering Settings (Alt + R) -> Common -> Background Color (set it to black and Alpha to 0 via sliders).

 

If that doesn't help, I'm afraid we will need more time for debugging.

 

Please, don't use your modified composite shader to verify the wrong alpha channel - it can be wrong.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Hi,

 

I am very sorry  it does not work that  the way you give us.

 

The problem  is still exist, so please solve this quickly.

 

Thanks,

Posted

Hi Silent,

 

We tested using the real camera and full setup instead of the modified composite shader.

It does not work.

 

Please help us to fix this issue asap.

 

Thank you very much,

Ian

Posted

Hi Ian,

We've found the root cause of such issue. Could you please try to do the following:

  1. Enable 16bit color format for the final image (Rendering -> Buffers -> Color 16F);

  2. Disable Environment (Rendering -> Features -> Environment);

  3. Modify Environment color: Rendering Settings (Alt + R) -> Common -> Background Color (set it to black and Alpha to 0 via sliders);

  4. Disable DOF (if enabled): Rendering -> Camera Effects -> DOF;

  5. Set Exposure mode to static: Rendering Settings (Alt + R) -> Camera Effects -> Exposure -> Mode: Static (adjust Exposure level to get more brighter picture).

In that case we have correct alpha channel in final texture. DOF and Adaptive exposure are causing alpha channel artifacts. If DOF and Adaptive exposure is critial for your current project, please tell us SDK version where should we fix that. Otherwise we will fix it only in 2.5 SDK update.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...