gree / lwf

LWF - Lightweight SWF
http://gree.github.com/lwf/
zlib License
627 stars 167 forks source link

webgl background transparency #133

Open Daemon456 opened 9 years ago

Daemon456 commented 9 years ago

Canvas output has a transparent background, webgl output has a black background. Ideally webgl output background would be transparent.

splhack commented 9 years ago

Have you tried to set setBackgroundColor parameter? The default value is 0x000000ff (= R:0,G:0,B:0,A:255). setBackgroundColor: 0 may work.

Daemon456 commented 9 years ago

Thanks for the suggestion. I tried 0, and it is still black. I also tried the default: 0x000000FF, but that actually changed the background to blue.

splhack commented 9 years ago

hmm, so I recommend you to use developer console for checking WebGLRendererFactory.prototype.setBackgroundColor function doing right thing or not.

Daemon456 commented 9 years ago

in WebGLRendererFactory.prototype.setBackgroundColor I set the background color array to this: this.backGroundColor = [0, 0, 0, 0];

and in WebGLRendererFactory.prototype.setClearColor I set clearColor to this: gl.clearColor(0, 0, 0, 0);

The background is still black.

splhack commented 9 years ago

How about changing alpha:false to alpha:true in this line? https://github.com/gree/lwf/blob/740f76571edb19ccab87a308f403fd4acbc58bc5/coffee/js_debug/lwf.js#L10625

alpha: true,
Daemon456 commented 9 years ago

Doesn't change anything.

KojiNakamaru commented 9 years ago

I guess you are testing your content on LWFS. Currently various WebGL implementations seem to have some issues for transparent canvases:

http://stackoverflow.com/questions/11554654/webgl-blendfunc-bug-or-misunderstanding http://www.html5gamedevs.com/topic/9098-strange-webgl-results-on-ios8/

so that LWFS set the canvas's background to be black and opaque:

https://github.com/gree/lwfs/blob/6ad09ca406ff841190153d529190f6d7fe78cc2a/tmpl/js/test-html5.js#L533-L534

You should be able to get a transparent canvas by adjusting these code (and with alpha: true), but it may cause troubles in blending.