@@ -5347,28 +5347,29 @@ static Model LoadGLTF(const char *fileName)
5347
5347
Image imMetallicRoughness = LoadImageFromCgltfImage (data -> materials [i ].pbr_metallic_roughness .metallic_roughness_texture .texture -> image , texPath );
5348
5348
if (imMetallicRoughness .data != NULL )
5349
5349
{
5350
- Image imMetallic , imRoughness ;
5350
+ Image imMetallic = { 0 };
5351
+ Image imRoughness = { 0 };
5351
5352
5352
- imMetallic .data = RL_MALLOC (imMetallicRoughness .width * imMetallicRoughness .height );
5353
- imRoughness .data = RL_MALLOC (imMetallicRoughness .width * imMetallicRoughness .height );
5353
+ imMetallic .data = RL_MALLOC (imMetallicRoughness .width * imMetallicRoughness .height );
5354
+ imRoughness .data = RL_MALLOC (imMetallicRoughness .width * imMetallicRoughness .height );
5354
5355
5355
5356
imMetallic .width = imRoughness .width = imMetallicRoughness .width ;
5356
5357
imMetallic .height = imRoughness .height = imMetallicRoughness .height ;
5357
5358
5358
5359
imMetallic .format = imRoughness .format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE ;
5359
5360
imMetallic .mipmaps = imRoughness .mipmaps = 1 ;
5360
5361
5361
- for (int x = 0 ; x < imRoughness .width ; x ++ ) {
5362
- for (int y = 0 ; y < imRoughness .height ; y ++ ) {
5362
+ for (int x = 0 ; x < imRoughness .width ; x ++ )
5363
+ {
5364
+ for (int y = 0 ; y < imRoughness .height ; y ++ )
5365
+ {
5363
5366
Color color = GetImageColor (imMetallicRoughness , x , y );
5364
5367
5365
- Color roughness = (Color ) {color .g };
5366
- Color metallic = (Color ) {color .b };
5367
-
5368
- ((unsigned char * )imRoughness .data )[y * imRoughness .width + x ] = color .g ;
5369
- ((unsigned char * )imMetallic .data )[y * imMetallic .width + x ] = color .b ;
5368
+ ((unsigned char * )imRoughness .data )[y * imRoughness .width + x ] = color .g ; // Roughness color channel
5369
+ ((unsigned char * )imMetallic .data )[y * imMetallic .width + x ] = color .b ; // Metallic color channel
5370
5370
}
5371
5371
}
5372
+
5372
5373
model .materials [j ].maps [MATERIAL_MAP_ROUGHNESS ].texture = LoadTextureFromImage (imRoughness );
5373
5374
model .materials [j ].maps [MATERIAL_MAP_METALNESS ].texture = LoadTextureFromImage (imMetallic );
5374
5375
0 commit comments