def _create_metallic_roughness_map(self, metal_map, rough_map): metal = QImage(metal_map) rough = QImage(rough_map) metal_pixel = QColor() metal = metal.convertToFormat(QImage.Format_RGB32) rough = rough.convertToFormat(QImage.Format_RGB32) metal_uchar_ptr = metal.bits() rough_uchar_ptr = rough.bits() if (not metal.width() == rough.width() or not metal.height() == rough.height()): raise RuntimeError( "Error processing material: {}. Metallic map and roughness map must have same dimensions." .format(self.maya_node)) width = metal.width() height = metal.height() i = 0 for y in range(height): for x in range(width): metal_color = struct.unpack('I', metal_uchar_ptr[i:i + 4])[0] rough_color = struct.unpack('I', rough_uchar_ptr[i:i + 4])[0] metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color)) metal_uchar_ptr[i:i + 4] = struct.pack('I', metal_pixel.rgb()) i += 4 output = ExportSettings.out_dir + "/" + self.name + "_metalRough.jpg" return output, metal
def _create_metallic_roughness_map(self, metal_map, rough_map): metal = QImage(metal_map) rough = QImage(rough_map) metal_pixel = QColor() metal = metal.convertToFormat(QImage.Format_RGB32); rough = rough.convertToFormat(QImage.Format_RGB32); metal_uchar_ptr = metal.bits() rough_uchar_ptr = rough.bits() if (not metal.width() == rough.width() or not metal.height() == rough.height()): raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node)) width = metal.width(); height = metal.height(); i = 0 for y in range(height): for x in range(width): metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0] rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0] metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color)) metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb()) i+=4 output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg" return output, metal
def getpixel(self, xy): color = self.img.pixel(xy[0], xy[1]) return (qRed(color), qGreen(color), qBlue(color))