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

Rendering is broken for raw texture creation #98

Closed
tcaf opened this issue Apr 5, 2016 · 5 comments
Closed

Rendering is broken for raw texture creation #98

tcaf opened this issue Apr 5, 2016 · 5 comments

Comments

@tcaf
Copy link

tcaf commented Apr 5, 2016

Using openfl 2.6.1 and lime 2.9.1, osx/cpp target, with babylonhx-openfl setup,

Texture being used:
Image of sample

Code to generate material:

var bmp:BitmapData = Assets.getBitmapData('sample.jpg');
var tex:RawTexture = RawTexture.CreateRGBATexture(bmp.image.data, bmp.width, bmp.height, scene);
var materialMesh = new StandardMaterial("sample", scene); 
materialMesh.diffuseTexture = tex; 

gives black texture,

Image of sample

if I disable mipmap, at least I get the texture but yellows seem blue:
Image of sample

I tried several different raw texture calls (rgb, rgba, alpa etc) all gives weird results. I don't use any openfl functionality (no addchild or draw). Regular Texture renders fine. But raw texture fails so...

@tcaf
Copy link
Author

tcaf commented Apr 5, 2016

Seems like an openfl issue, switched to lime asset loading and it just got fixed:

import lime.Assets in LMAssets;
...
var bmp = LMAssets.getImage('sample.jpg');
var tex:RawTexture = RawTexture.CreateRGBATexture(bmp.data, bmp.width, bmp.height, scene);

It would be cool if rawtexture would do the same with regular texture while loading bitmapdata so no need to hack around.

@vujadin
Copy link
Owner

vujadin commented Apr 6, 2016

Blue texture is openfl issue as every once in a while they change internal format of image. Its not RGB/RGBA by default anymore so you have to set it before using it:
bmp.image.format = PixelFormat.RGBA32;

Regarding mipmaps, it is bhx problem and its inherited from original (bjs) code (mipmap flag is not passed properly). I'll fix this in next update (later today or tomorrow)

@tcaf
Copy link
Author

tcaf commented Apr 6, 2016

That is helpful, thank you, I will use the PixelFormat for convenience. I understand the problem should stay in openfl side. Maybe there can be another static function in raw texture (CreateBGRA if order is different for e.g.) I guess we can keep this issue until mipmap implementation is recovered.

@vujadin
Copy link
Owner

vujadin commented Apr 6, 2016

This should be fixed now. You can use Tools.LoadImage() to get correct image data, it will always return image in RGBA format (creating mipmaps is also fixed):

var bmp:Image = null;
com.babylonhx.tools.Tools.LoadImage("assets/tex.jpg", function(img:Image) { bmp = img; });
var tex = RawTexture.CreateRGBATexture(bmp.data, bmp.width, bmp.height, scene, true/false);

@tcaf
Copy link
Author

tcaf commented Apr 6, 2016

Mipmap flag is working now, thank you.

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

No branches or pull requests

2 participants