iT2D 1.4.1 - SourceRect malfunction - RESOLVED
by Anton Belov · in iTorque 2D · 04/01/2011 (4:30 am) · 11 replies
Build: 1.4.1 Release
Platform: Windows 7
Target: Editor, In game
Issue: Setting Source Rect for static sprite doesn't properly render it. Works good if all the provided coords are divided by 2.
Steps to repeat:
1. Start new project
2. Add any image map to project (for example a 512x512 image)
3. Drop image map as static sprite
4. Set it to use Source Rect and set the rect to "0 0 512 512"
5. It will displayed that image is in top left quarter of sprite.
6. Set the rect to "0 0 256 256"
7. The sprite now draws normally but with left and top black line.
8. Set to "1 1 256 256" and it draws ok with no borders.
Suggestion: Have checked the sprite drawing, it appears good and works with halfed coords. Maybe some texture matrix with 0.5 scale is pushed?
Platform: Windows 7
Target: Editor, In game
Issue: Setting Source Rect for static sprite doesn't properly render it. Works good if all the provided coords are divided by 2.
Steps to repeat:
1. Start new project
2. Add any image map to project (for example a 512x512 image)
3. Drop image map as static sprite
4. Set it to use Source Rect and set the rect to "0 0 512 512"
5. It will displayed that image is in top left quarter of sprite.
6. Set the rect to "0 0 256 256"
7. The sprite now draws normally but with left and top black line.
8. Set to "1 1 256 256" and it draws ok with no borders.
Suggestion: Have checked the sprite drawing, it appears good and works with halfed coords. Maybe some texture matrix with 0.5 scale is pushed?
#2
Also, when I use sourceRect I got it to work by using half the width and height I actually wanted to use.... On client's computer it looks like shit. Doesn't show up right.
That was on PC version. I will be trying on iPad today.
04/01/2011 (8:10 am)
Mine does the same thing.Also, when I use sourceRect I got it to work by using half the width and height I actually wanted to use.... On client's computer it looks like shit. Doesn't show up right.
That was on PC version. I will be trying on iPad today.
#3
04/01/2011 (9:12 am)
Reformatted.
#4
04/03/2011 (8:30 pm)
@Anton - Thanks for reformatting. Logged as ITGB-149
#5
04/07/2011 (8:57 am)
@Anton - Any difference when deploying to an iOS device? Also, is there any chance you can send me your sprite sheet so I can test on my machine? You can send it to michaelp@garagegames.com
#6
04/07/2011 (10:00 pm)
@Michael - Haven't tried uploading to iOS. I just picked a random sprite of 1024x1024 into empty project.
#7
When the non SourceRect render is used it grabs coords from frames (or 0 frame) but when using SourceRect it grabs sizes from sourceBitmap (see t2dStaticSprite::setSourceTextCoords).
But when the images loads there are many packing things going on, like padding the texture with filterPad, pack in TexturePages.
So loading a 1024x1024 images, it gets padded to 1026x1026, then packed into 2048x2048 texture. So coords need to be halfed to draw normally.
I can fix that in sources, but need an updated editor too.
04/12/2011 (2:16 am)
@Michael - I hace checked the sources and found where the bug grows from.When the non SourceRect render is used it grabs coords from frames (or 0 frame) but when using SourceRect it grabs sizes from sourceBitmap (see t2dStaticSprite::setSourceTextCoords).
But when the images loads there are many packing things going on, like padding the texture with filterPad, pack in TexturePages.
So loading a 1024x1024 images, it gets padded to 1026x1026, then packed into 2048x2048 texture. So coords need to be halfed to draw normally.
I can fix that in sources, but need an updated editor too.
#8
04/12/2011 (5:46 am)
You can resolve this issue by removing the "filter pad" option ;)
#9
04/12/2011 (5:53 am)
@Chili - nope, if I try to use the, for example, 200x100 image, it gets fitted to 256x256 and SourceRect of "0 0 200 100" still draws the full 256x256 image, not the corresponding portion of it.
#10
Yes, that could be a workaround for iPhone, since all textures are pre-packed to POT textures before import to editor.
04/12/2011 (5:56 am)
@Chili - removing "filter pad" will only make sense if working with POT textures.Yes, that could be a workaround for iPhone, since all textures are pre-packed to POT textures before import to editor.
#11
09/14/2011 (10:32 am)
Fixed in 1.5.
Employee Michael Perry
ZombieShortbus