Importing Kenney 3D model the colours are 'wrong'

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Moo

Noob question: when I import some of Kenney’s excellent 3D models as DAE or GLTF objects, the colours are wrong - they appear darker than they should be.

When I import them into Unity they appear correct. Been googling lots the last few days but can’t find a simple answer. I’m setting a light source in the scene etc. but still the models appear darker, more washed-out as it were.

Please can someone point me in the right direction what I’m doing wrong?

more washed-out as it were.

Do you mean the environment is affecting the colour too much or are the UVs messing up?

Edit - Was Unity using the scene lighting or the default editor lighting? Unity doesn’t have a sky contribution property like Godot either since it uses the GI and material settings to get similar results, so turning the sky contribution way down with a directional light in the scene would make it look more like Unity.

Magso | 2020-02-23 10:30

I’ve used kenneys objects (imported from wavefront obj) in some test project. The colors seem to be correct.

That model does not use textures but color definitions in the material.

My guess ist that the lighting setup does not match your expectations.

You might want to add (if not already) a worldenvironment to your scene. Via that you can control the ambient light (preferrably set to white). You can also fiddle with the energy of the directional and also the ambient light.

There’s also the opportunity to adjust the general contrast/brightness and configure other color corrections via the worldenvironment node. But that should not be required in this case.

Finally, you can check if HDR is enabled in the projects rendering preferences.

wombatstampede | 2020-02-23 13:21

Thanks Magso and WombatStampede for the useful feedback. I’ve taken two screenshots - one of a godot mockup and another of unity - to show what I mean.

I’m beginning to think it’s a lighting setting from what you’ve both said, rather than a model import issue.

Godot screenshot crystals are washed-out - godot-models-and-light hosted at ImgBB — ImgBB

Unity screenshot crystals look normal - unity-models-and-light hosted at ImgBB — ImgBB

Moo | 2020-02-24 09:07

It is mostly the default environment settings in Godot that’s causing that. Another thing is have you assigned any materials yet? If the materials are imported with only a specified albedo texture, Godot automatically sets quite a reflective material as opposed to unity’s standard diffuse.

Magso | 2020-02-24 10:18

I checked kenneys “crystal” model on different import formats and I can (partly) acknowledge your findings.

I am not completely sure how and when material colors (albedo) are changed while importing but this happens.

My guess is that this is caused somehow by the mapping from material names to material files. So it only seems to happen when material storage is set to (material) files (instead of buit-in) on import. Maybe there’s a second “fainted” version of the crystal material somewhere in the model that overwrites the proper color.

But using shared materials (in files) is preferrable IMHO. It is easier to later adjust settings for all models sharing the same material/color and it also saves GPU resources.

I propose that you make sure that “Keep on Reimport” in the Material Import settings is checked (that is default IIRC). Then open the improper material files and adjust them to your likings. Also make sure to backup your project often in case materials still get overwritten on imports (where ‘keep’ wasn’t selected).

So in short words:
Either select Material built-in storage on import or edit/adjust the materials later.

wombatstampede | 2020-02-24 10:31

Thank you again Magso and WombatStampede I’ll investigate the import settings and the environment settings too. Really appreciate your helpful pointers about where to look

Moo | 2020-02-24 11:02

:bust_in_silhouette: Reply From: smudgecat123

Hi, I realize I’m very late to this conversation but I stumbled upon the same issue and have found a workaround.

The issue is to do with gamma correction. Either it’s being applied twice when it should only be applied once, or it’s not being applied at all (I’m not sure exactly which way around causes ‘washed-out’ colours vs overly dark colours).

Regardless, in this instance, the RGB values can be corrected manually by taking each component in the 0-255 range, dividing by 255, taking the result to the power (^2.2) and multiplying by 255.
I wrote a GDScript script to correct all the materials in a given folder using this method:

tool
extends Node

#https://medium.com/@Jacob_Bell/programmers-guide-to-gamma-correction-4c1d3a1724fb
#this script fixes gamma issues when importing Godot scenes

export var path : String
export var reverse : bool = false
export var fix : bool = false setget run_fix

func run_fix(v):
    var dir = Directory.new()
    if dir.open(path) == OK:
	    dir.list_dir_begin()
	    var file_name = dir.get_next()
	    while file_name != "":
		    if !dir.current_is_dir() and file_name.ends_with(".material"):
			    var fullPath : String = "res://" + path + "/" + file_name
			    var mat : SpatialMaterial = load(fullPath)
			    var color : Color = mat.albedo_color
			    color = gamma_correction(color, reverse)
			    mat.albedo_color = color
			    ResourceSaver.save(fullPath, mat)
		    file_name = dir.get_next()
    else:
	    print("An error occurred when trying to access the path.")
	
func gamma_correction(color : Color, reverse : bool) -> Color:
    var p : float = 1/(2.2) if reverse else 2.2
    color.r = pow(color.r,p)
    color.g = pow(color.g,p)
    color.b = pow(color.b,p)
    return color

Simply add a Node to your scene, attach this script, then set the path to the directory of material files you wish to fix and toggle the “Fix” button. Checking “Reverse” will reverse the process which should fix issues if the colours are too dark instead.