KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.14k stars 1.14k forks source link

Converting Metallic Roughness and Albedo to traditional DiffSpecNorm? #2330

Open VinnyVicious opened 1 year ago

VinnyVicious commented 1 year ago

I'm working on loading gltf models on an older engine that does not support PBR rendering, and I've been struggling on how to use the following texture maps:

https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet/glTF

I undestand that Diffuse could be the result of Albedo + AO with a "burn" blend mode, but what about metalRoughness? How can that be used as a traditional grayscale specular map?

javagl commented 1 year ago

There is an appendix in an (archived!) extension that might be helpful. It points to some utility functions that are supposed to do this conversion. (I won't be able to help any further, but maybe the implementors or PBR experts will chime in here).

bghgary commented 1 year ago

I don't know what DiffSpecNorm means, but the appendix that @javagl pointed to is for a different PBR model with specular/glossiness maps. Since you say this older engine doesn't support PBR rendering, it will likely not translate well. That said, if you translate baseColor/metallic+roughness into diffuse/specular+glossiness as written in the code from the appendix, it will at least be closer to a traditional model (e.g., BlinnPhong).

Here is a live version of the appendix for Babylon.js: https://bghgary.github.io/glTF/convert-between-workflows-bjs/

VinnyVicious commented 1 year ago

Sorry for the lack of detail. By DiffSpecNormal, I mean the traditional old-gen workflow, popular in UDK, Unreal Engine 2, Unity 2, id Tech 4 and others:

image

bghgary commented 1 year ago

Sorry, without documentation on what lighting model this uses, I don't know if it's clearer :-/

VinnyVicious commented 1 year ago

I believe would be this one: https://docs.unrealengine.com/udk/Three/MaterialBasics.html#Enhanced%20Specular

echadwick-artist commented 9 months ago

This article might be helpful. https://marmoset.co/posts/pbr-texture-conversion/#metaltospec

However as bhgary indicated, pre-PBR lighting models are likely not easy to convert to.

As I recall there was often an avoidance of performing lighting calculations in linear color space, which led artists to overcompensate with blue specular textures, to achieve neutral specular response on skin tones.

There was also no standardization for lighting values, leading to ad-hoc texture values based on specific lighting conditions.