Skip to content

Commit cfe9693

Browse files
committed
REVIEWED: Formatting #4739
1 parent bddb5df commit cfe9693

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/rmodels.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -5347,28 +5347,29 @@ static Model LoadGLTF(const char *fileName)
53475347
Image imMetallicRoughness = LoadImageFromCgltfImage(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture->image, texPath);
53485348
if (imMetallicRoughness.data != NULL)
53495349
{
5350-
Image imMetallic, imRoughness;
5350+
Image imMetallic = { 0 };
5351+
Image imRoughness = { 0 };
53515352

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);
53545355

53555356
imMetallic.width = imRoughness.width = imMetallicRoughness.width;
53565357
imMetallic.height = imRoughness.height = imMetallicRoughness.height;
53575358

53585359
imMetallic.format = imRoughness.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
53595360
imMetallic.mipmaps = imRoughness.mipmaps = 1;
53605361

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+
{
53635366
Color color = GetImageColor(imMetallicRoughness, x, y);
53645367

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
53705370
}
53715371
}
5372+
53725373
model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTextureFromImage(imRoughness);
53735374
model.materials[j].maps[MATERIAL_MAP_METALNESS].texture = LoadTextureFromImage(imMetallic);
53745375

0 commit comments

Comments
 (0)