+1 vote

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?

in Engine by (31 points)

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.

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.

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 - https://ibb.co/bgjKT9D

Unity screenshot crystals look normal - https://ibb.co/vqQctWM

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.

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.

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

1 Answer

+1 vote

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.

by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.