When body's background color is set as transparent as below, the actual background is displayed as purple in cobalt.
body {
background-color: transparent;
}
Is there any way to make background to be real transparent? I wish to show other gfx or video layers under cobalt's graphics layer. Thanks!
So comment out the following line from src/cobalt/renderer/backend/egl/graphics_context.cc:GraphicsContextEGL::SecurityClear()
GL_CALL(glClearColor(1.0f, 0.4f, 1.0f, 1.0f));
As an optimization, Cobalt does not clear its framebuffer each frame, however this can indeed cause a problem if you would like to use it as an overlay.
In cobalt/renderer/pipeline.cc, right after the line:
rasterizer::Rasterizer::Options rasterizer_options;
but before the line:
rasterizer_->Submit(results.animated, render_target, rasterizer_options);
If you add:
rasterizer_options.flags = rasterizer::Rasterizer::kSubmitFlags_Clear;
Cobalt will clear each frame to be fully transparent before rendering the contents.
We will look into adding a nicer way to express this desire in the future, but hopefully this helps for now.
Related
I have a Processing.js sketch that must be transparent. I figured out how to set the background to be transparent by default, however, when I draw on the sketch I seemed to have permanently marked the canvas.
Is it possible to clear the canvas and set it back to transparent using Processing.js?
If not, is context.clearRect(params) fast enough/ a suitable solution?
Here are the first two results for googling "Processing.js transparent background":
http://processingjs.org/reference/transparent/
http://processingjs.org/reference/background_/
(Even without google, the reference should be your first stop for questions like this.)
Anyway, yes you can use a transparent background. Just use the /* #pjs transparent="true"; */ directive at the top of your code to enable transparency, and then pass an alpha value into the background() function.
I am trying to implement webgl for my game. The problem is I use multiple canvases, and my webgl enabled canvas is semi-transparent over my terrain canvas (which is drawn once and just moves with the player). Here is a picture:
I've searched for the past 2 hours on google and can't find anything that has helped.
I have tried:
getContext("experimental-webgl",{alpha: false});
This just hides the terrain completely (now all black), but my webgl drawn objects have the correct color.
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, false);
Neither of these did anything noticeable.
gl.clearColor(0, 0, 0, 0)
Didn't affect the outcome, still looks like the screenshot above.
Everything else here: http://games.greggman.com/game/webgl-and-alpha/
Nothing seems to work. Why is what is drawn on the canvas semi transparent? There is no CSS affecting the canvas element.
Figured it out! I am using WebGL-2D, which is a javascript file that adds the context2D API to webGL. So if I call drawImage, it actually handles that with webgl. In the getContext definition I had to change:
gl.colorMask(1,1,1,0);
to
gl.colorMask(1,1,1,1);
The colorMask() method specifies whether red, green, blue, and alpha can or cannot be written into the frame buffer.
I have no idea why it was 0 before.
I was on the way of making a picasa like photo viewer and later an image editor.i used JFrame and alpha channel to set background transparent.but while moving or zooming in/out ,as i had to draw it on different location and clear the previous image i used clearRect and faced the problem.
the oracle documentation says it clears the rect and restores the background color.
on some trials the clearRect clears the area to background color.But while continuous events like mouse-dragging its turning the color of cleared area to black and causing this:
`
thnx
.i used JFrame and alpha channel to set background transparent.
Don't use alpha for complete transparency. Instead just use:
panel.setOpaque( false );
If you are using semi transparency then check out Backgrounds With Transparency. It will explain the problems with transparent background and provide a couple of solutions.
The basic problem is that transparency breaks the painting contract with Swing components because the background is not cleared entirely before child components are painted.
Created a simple scene with a cube in it. Able to see the color of the containing element, (body), in the background.
Added an FXAA shader and the antialiasing works well. However the background is now black, so can no longer see the color of the background container.
Added the following code:
var target = new THREE.WebGLRenderTarget(512, 512);
var composer = new THREE.EffectComposer( renderer, target );
in order to set the effect composer render target format to THREE.RGBAFormat, rather than the default THREE.RGBFormat.
This makes the background work properly, but then there are black and white edges around the cube and the antialiasing does not look very good.
Repeated the above but used the Sepia shader instead of the FXAA shader. This works correctly. The cube looks sepia and the background containing element color is correct.
Are there any workarounds to allow antialiasing and transparent background?
Thanks for any help
I read your issue and there seems to be a good source that can solve or at least lead you down the right path. Go check out: https://github.com/mrdoob/three.js/issues/2125
Hope this helps.
Check my answer in https://stackoverflow.com/a/21056080/2482976
The FXAA needed to be updated to handle the transparent background
I've the same image as SplashScreenImage and as background, the effect is nice but at the start, after the loading, my image slides a bit on the top..
It's pretty visible (and disturbing) as effect, because the image is the same..
I'm using the ApplicationBar (all visible), don't know if it's a problem.
I've setted the background image as "Uniform to fill" (tried all btw) in my LayoutRoot, I've a Pivot control.
The problem is really the ApplicationBar, if you set it opacity to something like "0.99" you problem should go away.
But the best result may be just by having a second image, with 480x728 (the ApplicationBar is 72px height, so 800 - 72 = 728)