-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[BUG] Pixel draw imprecision on android. #2000
Comments
Is it the same problem as #1963 ? ps2. The mask size should be fixed in 1.6.2. |
Hmm i dont think so, because im testing on Android. That issue is for iOS. |
Not just iOS, that issue maybe happens on every platform. |
I see. I tried changing ccShader_PositionTextureColor_noMVP.vert and ccShader_PositionTextureColor_noMVP.frag with highp, into \build\jsb-default\frameworks\cocos2d-x\cocos\renderer but it didnt work. :( These lines: https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/renderer/ccShader_PositionTextureColor.vert#L33 no changes :( |
I also tried replacing every ocurrence of lowp and mediump with highp, and no changes too :( |
Please, try this |
ok, I tried changing: return (_winSizeInPoints.height / 1.1566f); on build\jsb-default\frameworks\cocos2d-x\cocos\base\CCDirector.cpp file. It recompiled: but didnt work :( any tips on where I can start to debug it? I was thinking about going to CCTexture2D.cpp drawAtPoint and drawInRect and start logging from there and backwards. |
this is the log: 09-26 09:46:27.251: I/art(17938): Late-enabling -Xcheck:jni |
took me two days but i finnaly started to make progress.. it seems that Scale9SpriteV2 is the "sprite panacea" of cocos creator. so the mistake should be somewhere between the sacred silence: void Scale9SpriteV2::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) and sleep. I will continue my research |
VERT: 0 _ 2.000000, 16.000000, 0.000000 VERT: 1 _ 2.000000, 0.000000, 0.000000 VERT: 2 _ 15.000000, 16.000000, 0.000000 VERT: 3 _ 15.000000, 0.000000, 0.000000 |
Ok I think I found the issue. it seems that CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL is the problem. its saying:
but its actually enabled by default. also, "99%" is a very wild guess. as you can see in this case of a 16x16 pixel, you pick up just 96.875% |
0.031250, mostly known as half of 1/16. |
ps1. https://www.youtube.com/watch?v=tAP4tH_2iE8 itsa gooda engine |
Whew. To my surprise, after clearing up the mess and just letting the CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL on 0, i found out that it started showing artifacts on screen... aw shucks.. back to the lab again |
Okay, I am very sorry for that. I knew there was a problem of FIX_ARTIFACTS_BY_STRECHING_TEXEL, but we did fix it in Creator. I couldn’t believe the problem still affects NATIVE platfom by default... FIX_ARTIFACTS_BY_STRECHING_TEXEL is bull shit and should be disabled by default. But if you are using TiledMap, you still need it, there's no good way to workaround... |
No problem, we are together in this. I saw this link: https://www.makeschool.com/docs/#!/cocos2d/1.4/tilemaps/troubleshooting-tilemaps // Objective-C // Swift can't we do something similar in cocos creator? I know it probrably reduces performance at some point, but maybe its a good solution. Maybe a new config. |
Tomorrow im gonna try to round the transformation matrixes on every node on every draw and see what happens |
So .. i found out that the: float Director::getZEye(void) const plus changing all shaders lowp and mediump ocurrences to highp did the trick. (I dont know if the shader changes is really necessary.) Seems to be working now. |
Did a test with action moveBy and it still produce artifact if the tiled map stay in non integer pixels. So it seems that: 1 . return (_winSizeInPoints.height / 1.154700538379252f);//(2 * tanf(M_PI/6)) fix cc.Class({
}); Does the trick both on web and android. |
quick question: is therr a reason to use 3d projection as default for cocos creator? it seems that the eye stuff is just for 3d |
it seems that using 2d projection as default or using the 3d precision fix + disabling texel bullshit + rounding the tmx nodes on the C++ itself would be a good permanent solution. |
No... it just for historical reasons. Thanks for help! |
no problem :) should I make a pull request? I work at a software house, we have tons of android and ios devices there, I could test the solution and make sure it works everywhere. |
Sure, it will be greatly appreciated! |
3d precision synced: cocos/engine-native#865 |
so, after assessing the problem, I think thats more complicated than I expected There are 3 types of TMX Maps This would actually demand a full month test, I think its more than I can bite :( So for now, I will humbly post this Script here, that solves the TMX moving issue for me:
The idea is to put a brother node and use that node as the TMX node actual position. And always copy the rounded-to-canvas-pixel position on update. This, combined with: return (_winSizeInPoints.height / 1.154700538379252f);//(2 * tanf(M_PI/6)) fix Should solve the issue for at least a part of the situations. ps. another thing i noticed is that the dt on the update has a quite low precision. Like 0.016 or 0.018, instead of using more decimal places. |
Never mind, thanks for help~ |
I see, then I think im gonna close the issue. by the way, you guys will disable the CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL on next release right? even though disabling it ma cause artifacts on tmx maps, with it is turned on it the tile look bad anyway (I never posted a screen of how bad it look, but it does, and most since tiles are low pixel) |
Yes, we will. CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL should be disabled on next release |
Hello!
Im having trouble with pixel perfect on Android.
The pixels size are varying. It seems that it happening around the borders.
You can also see that on a web build the pixels size are rendering properly.
Specs:
Zenfone 2, Android 5.0, 1920x1080
Cocos Creator 1.6.1 Windows
Mode: Portrait
Sample Project
ps2. On the extra info, this happens too with tiled maps. Also, weirdly enough, "mask" component is working properly on android, but on web its offseting by 1 pixel (reducing 1 pixel on width and height makes the desired rect size).
The text was updated successfully, but these errors were encountered: