1
Support / Region on texture that sprite is extracted from.
« on: January 13, 2014, 10:40:36 am »
Hi!
I'm trying to write a shader based on normal sprite shader, but with addition of another texture to use its alpha to cut out the sprite.
I think it would be quite easy if we know where on texture has the sprite been extracted from. Using a simple math formula in shader, we can calculate uvs on alpha texture using uvs on main texture. But I have 2 questions :
a) Do all sprites have a rectangular extract region on atlas? If not, is there any easy way to get some equivalent?
b) How can I get that region in my sprite class? Since I don't want to keep a reference to collectionData in sprite just to pass its region to the shader.
I'm trying to write a shader based on normal sprite shader, but with addition of another texture to use its alpha to cut out the sprite.
I think it would be quite easy if we know where on texture has the sprite been extracted from. Using a simple math formula in shader, we can calculate uvs on alpha texture using uvs on main texture. But I have 2 questions :
a) Do all sprites have a rectangular extract region on atlas? If not, is there any easy way to get some equivalent?
b) How can I get that region in my sprite class? Since I don't want to keep a reference to collectionData in sprite just to pass its region to the shader.