瀏覽代碼

[rmodels] Separate GLTF roughness and metallic channels on load

pull/4739/head
Nikolas 2 月之前
父節點
當前提交
68a29230cb
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: E95F679E3CDD9784
共有 1 個檔案被更改,包括 27 行新增1 行删除
  1. +27
    -1
      src/rmodels.c

+ 27
- 1
src/rmodels.c 查看文件

@ -5347,7 +5347,33 @@ static Model LoadGLTF(const char *fileName)
Image imMetallicRoughness = LoadImageFromCgltfImage(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture->image, texPath);
if (imMetallicRoughness.data != NULL)
{
model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTextureFromImage(imMetallicRoughness);
Image imMetallic, imRoughness;
imMetallic.data = RL_MALLOC(imMetallicRoughness.width * imMetallicRoughness.height);
imRoughness.data = RL_MALLOC(imMetallicRoughness.width * imMetallicRoughness.height);
imMetallic.width = imRoughness.width = imMetallicRoughness.width;
imMetallic.height = imRoughness.height = imMetallicRoughness.height;
imMetallic.format = imRoughness.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
imMetallic.mipmaps = imRoughness.mipmaps = 1;
for (int x = 0; x < imRoughness.width; x++) {
for (int y = 0; y < imRoughness.height; y++) {
Color color = GetImageColor(imMetallicRoughness, x, y);
Color roughness = (Color) {color.g};
Color metallic = (Color) {color.b};
((unsigned char *)imRoughness.data)[y*imRoughness.width + x] = color.g;
((unsigned char *)imMetallic.data)[y*imMetallic.width + x] = color.b;
}
}
model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTextureFromImage(imRoughness);
model.materials[j].maps[MATERIAL_MAP_METALNESS].texture = LoadTextureFromImage(imMetallic);
UnloadImage(imRoughness);
UnloadImage(imMetallic);
UnloadImage(imMetallicRoughness);
}

||||||
x
 
000:0
Loading…
取消
儲存