W810 compositing mode alpha bug

 FW: http://developer.sonyericsson.com/thread.jspa?threadID=39278&tstart=0

boinged

Posts: 96
Registered: 4/1/04
 W810 compositing mode alpha bug
Posted: Apr 18, 2007 4:43 AM
 
 Click to reply to this thread Reply

I've just experienced a very strange issue on this device where ALPHA and MODULATE compositing mode blendings are reverting to REPLACE when another compositing mode is used with the REPLACE mode.

Here's a test summary.

I have a simple quad mesh with a 24-alpha texture applied to it. The texture is loaded as an Image to get around the Loader bug.
midpImg = Image.createImage("/tex.png");
image2d = new Image2D(Image2D.RGBA, midpImg);
texture = new Texture2D(image2d);
texture.setBlending(Texture2D.FUNC_REPLACE);
compositingMode.setBlending(CompositingMode.ALPHA);


Another similar mesh has a non-transparent texture, loaded exactly the same way, the only difference being:
compositingMode2.setBlending(CompositingMode.REPLACE);


1) When I draw just the alpha mesh, it looks as expected - with the background showing through the transparent parts of the texture.

2) When I draw the solid mesh before the alpha mesh, the transparent parts become black which is the transparent colour value. The background colour is different - so it's not the background I'm seeing.

3) When I now stop drawing the solid mesh, the alpha mesh is still drawn non-transparent.

Even creating the transparent mesh on the fly during each render frame results in the same issue.

As a further test I changed the first mesh to use CompositingMode.MODULATE, to try and pin down the issue. The same problem occurs - 1) it's ok, 2) it reverts to REPLACE, 3) it gets permanently stuck in REPLACE mode.

These tests were done with a background colour clear only. Each compositing mode additionally has:
compositingMode.setDepthTestEnable(false);
compositingMode.setDepthWriteEnable(false);


Setting all compositing modes to use ALPHA blending works but slows the framerate down to an unacceptable level.

Has anyone seen anything like this or thinks they can explain what is going wrong?
Are there any workarounds besides my one?

SonyEricsson: I've not tried any other Java Platform 5 devices but is it a known issue of these?

bjourne

Posts: 8
Registered: 3/6/07
 Re: W810 compositing mode alpha bug
Posted: Jun 15, 2007 6:25 AM   in response to: boinged
 
 Click to reply to this thread Reply

I'm not able to reproduce your problem. Does it make any difference what textures you are using or how you load them? Could you post a full code example, that demonstrates the bug?

boinged

Posts: 96
Registered: 4/1/04
 Re: W810 compositing mode alpha bug
Posted: Jun 15, 2007 1:39 PM   in response to: bjourne
 
 Click to reply to this thread Reply

I'll see if I can put some test code together. This kind of test app is starting to look useful with the amount of weird bugs I get :) I suspect there are underlying bugs in the device's software renderer that only become apparent when you have certain combinations of textures/appearances/compositing modes/polygon modes etc.

The textures are indexed but I also have an RGBA image for a different texture and this has the same problem. They're not being loaded with Loader.load().

It's very strange: W710, K800 are fine. K610, W810 are broken.

boinged

Posts: 96
Registered: 4/1/04
 Re: W810 compositing mode alpha bug
Posted: Jun 19, 2007 12:28 PM   in response to: boinged
 
 Click to reply to this thread Reply

I've managed to solve this but there seems to be a bug with this firmware (R1AA049) as I don't need the workaround for a different K610 device I tried.

In my sample code I paint a quad with an opaque texture, then one with a transparent texture.

If depth writing is turned off for the opaque quad then the 2nd quad doesn't appear transparent unless FUNC_MODULATE is used for the blending mode

This is irrespective of whether a depth buffer is even used!

Can anyone explain why this would happen? Maybe then I can find a better workaround because I'd rather not use modulate unless I have to.

	private static final void initTest1()
{
try
{
CompositingMode solidCompositing = new CompositingMode();
solidCompositing.setBlending(CompositingMode.REPLACE);
solidCompositing.setColorWriteEnable(true);
solidCompositing.setAlphaWriteEnable(false);
solidCompositing.setDepthTestEnable(false);
// solidCompositing.setDepthWriteEnable(false);

CompositingMode transparentCompositing = new CompositingMode();
transparentCompositing.setBlending(CompositingMode.ALPHA);
transparentCompositing.setColorWriteEnable(true);
transparentCompositing.setAlphaWriteEnable(false);
transparentCompositing.setDepthTestEnable(false);
// transparentCompositing.setDepthWriteEnable(false);

Texture2D solidTexture = null, transparentTexture = null;
Appearance solidAppearance = new Appearance(), transparentAppearance = new Appearance();

solidTexture = loadTexture("solid", Texture2D.FUNC_REPLACE);
solidAppearance.setTexture(0, solidTexture);
solidAppearance.setCompositingMode(solidCompositing);
solidMesh = createQuad(solidAppearance, 100, 100);

transparentTexture = loadTexture("transparent", Texture2D.FUNC_REPLACE);
transparentAppearance.setTexture(0, transparentTexture);
transparentAppearance.setCompositingMode(transparentCompositing);
transparentMesh = createQuad(transparentAppearance, 50, 50);
}
catch(Exception e)
{
e.printStackTrace();
}

bg.setDepthClearEnable(false);
bg.setColorClearEnable(false);
}

private static final Texture2D loadTexture(String filename, int mode)
{
Texture2D tex = null;

try
{
tex = new Texture2D(new Image2D(Image2D.RGBA, Image.createImage("/"+filename+".png")));
tex.setBlending(mode);
}
catch(Exception e)
{
e.printStackTrace();
}

return tex;
}
public void paint(Graphics g)
{
g.setColor(0xff0000);
g.fillRect(0, 0, getWidth(), getHeight());

try
{
g3d.bindTarget(g);
g3d.clear(bg);
g3d.render(solidMesh, null);
g3d.render(transparentMesh, null);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
g3d.releaseTarget();
}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值