Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Texture uploads from BitmapData, and a TextFormat type issue. #622

Merged
merged 2 commits into from
Apr 24, 2015

Conversation

Type1J
Copy link
Contributor

@Type1J Type1J commented Apr 24, 2015

This fixes

away3d/away3d-core-openfl#40
openfl/lime#409

, and many problems that I've been having with blending when rendering to textures. BitmapData is assumed to be premultiplied with alpha, and because OpenFL doesn't, this makes sure that that happens.

One improvement would be to check the lime Image for it's premultipled property, but the Image is private, so maybe that should be exposed on BitmapData, or @:access-ed.

The kerning property is correct in OpenFL 3.x, but legacy/lime-hybrid gives me type errors, so I fixed that as well.

This patch fixes a ton for me, so please merge it.

jgranick added a commit that referenced this pull request Apr 24, 2015
Fixing Texture uploads from BitmapData, and a TextFormat type issue.
@jgranick jgranick merged commit 24d675b into openfl:master Apr 24, 2015
@jgranick
Copy link
Member

Thanks!

I do not have a good test case for Stage3D content, so I'm sort of making this change, but I realized that OpenFL legacy will NOT use premultiplied alpha, so we need to be careful not to mulitply in that sense.

I also made a tweak that (I think) will improve performance, because the image.premultiplied = true operation goes through a C++ method to quickly hit all the pixels, which (in Neko especially) performs faster

https://github.com/openfl/openfl/blob/master/openfl/display3D/textures/Texture.hx#L53-L82

Please take a look and see if this still works for you. I already committed the above

@Type1J
Copy link
Contributor Author

Type1J commented Apr 24, 2015

I'm pretty sure that the change you listed would work. If it's faster, then maybe that should be the way to go. I'd still like the uploadFromUInt8Array() function in this pull, though, since that's about as fast as you could make it.

@jgranick
Copy link
Member

I already pulled, this was just a tweak to it 😄

@Type1J
Copy link
Contributor Author

Type1J commented Apr 24, 2015

Awesome! Thanks!

@Type1J
Copy link
Contributor Author

Type1J commented Apr 24, 2015

Hmm... It looks like that's not working. The blends reverted after the new changes. I'll look into it, and I'll make another pull request when I get it fixed.

@Type1J
Copy link
Contributor Author

Type1J commented Apr 24, 2015

Found it. I was using lime-hybrid because I'm rendering TextFields to textures. 3.0 didn't do that correctly last time I checked, but maybe we should just make the jump and fix the TextFields, since everything else seems to work better in 3.0.

@Type1J
Copy link
Contributor Author

Type1J commented Apr 24, 2015

Actually, there's quite a few things that need to be fixed because there are different blend issues as well.

After thinking about it, anytime a texture is uploaded from a BitmapTexture, it's assumed to be premultiplied, so the default for legacy should probably be to do the premultiply here.

@Type1J
Copy link
Contributor Author

Type1J commented Apr 25, 2015

Also, this is probably a good project to test quickly:

https://github.com/dimumurray/AlphaTest

It's from away3d/away3d-core-openfl#40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants