Godot: Importing GLTF files with correct shading

Created on 25 Aug 2020  路  11Comments  路  Source: godotengine/godot

I'm trying to export a simple plane with a set of PBR textures from blender 2.8 to godot (v3.2.2-stable, on ubuntu 18.04), here how's shown in blender

and here how's show in godot

I'm ok with a little difference, after all every program is different, but this is unnaceptable.

I know it's not the exporter, because another viewers of gltf files load it correctly, like this on the web

I even tried the same test HDR background for illumination, and doesn't seem to make a lot of difference, this is the shaders that I'm using in blender

the texture set is this one:
https://cc0textures.com/view?id=Tiles058

has color, normals, metallic, roughness, like it should.

This may be a bug, because the glb file exported is correct, or the error would be visible in other gltf viewers, and it's not.

Steps to reproduce:
Download the texture set, make the same material in blender 2.8 as shown in the picture above, export to gltf and import as a new scene in godot

Minimal reproduction project:
qewrqwer.zip

discussion import

All 11 comments

Godot has no way to import Blender shaders (our PBR differs from Blender's PBR enough that 1:1 translation isn't possible). Also Godot uses a different channel for normal maps than Blender.

so godot doesn't follow the gltf standard? because in another gltf applications it works just fine.
Even if it's just that, what's the solution? How do I modify the shaders, or the files, so godot can read them?

There is no such thing as GLTF standard when it comes to shaders. Every engine (Unity/UE4/Godot/Blender) has its own shaders with their own quirks (e.g. how strong clearcoat is or what it means to have roughness 1). The things that are standard are the meshes and the textures, everything else depends on the engine.

Notice that the sky color is making the result very different.

Edited. I think the normal map is incorrect.

Godot requires the normal map to use the X+, Y- and Z+ coordinates. In other words, if you've imported a material made to be used with another engine, you may have to convert the normal map so its Y axis is flipped. Otherwise, the normal map direction may appear to be inverted on the Y axis.

https://docs.godotengine.org/en/stable/tutorials/3d/spatial_material.html

Notice that the sky color is making the result very different.

Edited. I think the normal map is incorrect.

Godot requires the normal map to use the X+, Y- and Z+ coordinates. In other words, if you've imported a material made to be used with another engine, you may have to convert the normal map so its Y axis is flipped. Otherwise, the normal map direction may appear to be inverted on the Y axis.

https://docs.godotengine.org/en/stable/tutorials/3d/spatial_material.html

So how to invert the Y axis? On godot? Do I need another software? Do I change something in blender?

So how to invert the Y axis? On godot? Do I need another software? Do I change something in blender?

Godot doesn't have an import flag to invert the normal map's green channel yet. (This will be added by https://github.com/godotengine/godot/pull/39202 once it's merged.)

You need to either modify the normal map in Blender somehow, or use third-party software to flip the normal map's green channel only. This can be done in GIMP with the help of the Colors > Components > Decompose... and Colors > Components > Compose... actions.

There is no such thing as GLTF standard when it comes to shaders. Every engine (Unity/UE4/Godot/Blender) has its own shaders with their own quirks (e.g. how strong clearcoat is or what it means to have roughness 1). The things that are standard are the meshes and the textures, everything else depends on the engine.

That's not completely true, altough the rendering is up to the application, the specification (that exists!) says clearly that GLTF follows a right handed coordinates system (+X,+Y,+Z) so godot does not follow the specification when importing it

https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#coordinate-system-and-units

While I do have to use some workaround now, I would think is best to follow the standards and change the behaviour.

One proposal is to take the green channel and if it's related to a gltf2 normal texture, it would be uncompressed, negated, rewritten and exported again.

@fire We can enable the Invert Green Channel import flag automatically for normal maps that come from glTF scenes (see my above PR).

Hi!

The shading seem fine to me, but not the environment reflection. It seem to reflect on UV space and not in world space | screenspace... I could be wrong...
Also, the hardness channel value seem really low, as this material is a mirror. (Value=0) What is the current value in Godot?

Your web GLTF viewer use another environment texture as Blender (Look like a black and white gradient). But the reflection mapping seem correct considering the image.

By the way, the PBR shading model is all based on the Disney Whitepapers. (Blender, Godot, Unreal, etc.) so it should _almost_ be identical.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nunodonato picture nunodonato  路  3Comments

Spooner picture Spooner  路  3Comments

testman42 picture testman42  路  3Comments

RayKoopa picture RayKoopa  路  3Comments

RebelliousX picture RebelliousX  路  3Comments