The pixel size of an material can be retrieved with the Coordinate Index 3 of the TexCoord node in the material editor.