Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using sprite as normalmap change sprite import options #33709

Closed
qarmin opened this issue Nov 18, 2019 · 11 comments
Closed

Using sprite as normalmap change sprite import options #33709

qarmin opened this issue Nov 18, 2019 · 11 comments

Comments

@qarmin
Copy link
Contributor

qarmin commented Nov 18, 2019

Godot version:
3.2 beta 1
OS/device including version:
Ubuntu 19.10
Issue description:
It is really strange, that using sprite as normalmap in spatialmaterial, change import settings in icon.png.import from

[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

to:

[remap]

importer="texture"
type="StreamTexture"
path.s3tc="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex"
path.etc2="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex", "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.stex" ]

Steps to reproduce:
jfile

Minimal reproduction project:
Tanks.zip

@Calinou
Copy link
Member

Calinou commented Nov 18, 2019

Normal maps make use of RGTC compression to save memory and improve quality, so Godot is likely turning on VRAM compression automatically if you set a texture to be used as normal map.

@aaronfranke
Copy link
Member

This is the same issue as the very first bug report I opened for Godot: #15920

@KoBeWi
Copy link
Member

KoBeWi commented Nov 24, 2019

This does not happen if you have "Detect 3D" import setting disabled. So it's likely intended.

@aaronfranke
Copy link
Member

Is there possibly a way to detect that the texture is being used for albedo, and un-set the normal mapping compression? I found some docs here that suggest albedo textures use SRGB, perhaps SRGB being enabled should disable RGTC.

I tried adding singleton->make_flags[path] &= ~MAKE_NORMAL_FLAG; after line 48 of resource_importer_texture.cpp and it doesn't seem to make a difference.

@golddotasksquestions
Copy link

golddotasksquestions commented Dec 3, 2019

So it's likely intended.

What exactly is the intention here to change the icon settings and autoreimport? Especially in 2D that seems very counter productive. See my issue.
Shouldn't there be a pop up giving me a choice or at the very least informing me what is happening, if we really want to force this import setting change onto people?

@rakkarage
Copy link
Contributor

Here is another simple replication of this issue:
I had some other TileMap issues but was having trouble with changing import settings.
I found this post searching and solved my problem by changing sprites import settings from auto-detect to 2d?

https://github.com/rakkarage/NewTileMapTest

  1. Open project works fine.
  2. Change setting of doodad.png back to default auto-detect and reimport.
  3. Open banner1.tres (shader material that uses that png in a shader) get errors and it changes import settings.
  4. Now with the changed settings looks weird in TileSet editor.

If you change import settings back to 2d and do this all over it works fine?
If you remove the hint_albedo from the shader and do this all over it works fine?
I am not even sure what hint_albedo is for, it seemed to not work in 3 without it? Now it does not work with it? It is not needed? Maybe causing this problem?

But this does not seem intended? Auto detect should auto detect?
I should not have to change all my sprites in all my projects to 2D to ward against changes?
Or maybe I should remove all my hint_albedo?
Thanks.

Before:

[remap]

importer="texture"
type="StreamTexture2D"
uid="uid://gwkob421rs7s"
path="res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Doodad.png"
dest_files=["res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.stex"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=0

After:

[remap]

importer="texture"
type="StreamTexture2D"
uid="uid://gwkob421rs7s"
path.s3tc="res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.s3tc.stex"
path.etc2="res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.etc2.stex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}

[deps]

source_file="res://Doodad.png"
dest_files=["res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.s3tc.stex", "res://.godot/imported/Doodad.png-c1a5ceea497e429d040ae291cdf297c5.etc2.stex"]

[params]

compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=0

@Calinou
Copy link
Member

Calinou commented Feb 21, 2022

As I said above, the fact that import options are automatically changed for normal maps is expected. What shouldn't happen is VRAM compression being forced for small textures (<= 256×256 by default), but this is something that needs to be implemented separately. I attempted this a while ago, but it was rejected as it needs to be done in a cleaner, user-adjustable manner.

@rakkarage
Copy link
Contributor

rakkarage commented Feb 21, 2022

my code does not use Normal Maps... just a sprite and a shader yet the import options are changed, excuse my ignorance

@Calinou
Copy link
Member

Calinou commented Feb 21, 2022

I am not even sure what hint_albedo is for, it seemed to not work in 3 without it? Now it does not work with it? It is not needed? Maybe causing this problem?

hint_albedo should generally only be used in 3D shaders. It hints that sRGB -> linear conversion should be performed by the shader. This is not needed in 2D as all rendering occurs in sRGB there.

hint_albedo will also enable VRAM compression automatically when you specify a texture in the inspector, as high-resolution textures in 3D should generally use it to save on memory.

@rakkarage
Copy link
Contributor

Using filter_linear or filter_nearest (maybe anything) (sampler2D being passed into shader with a hint) also seem to cause this unwanted and unneeded change of import settings causing the TileMap and TileSet to display wrong in this example.
Screenshot-32.png
It does seem seem to work fine with no hints but need filter_nearest to fix this other problem...
Which is originally from here:
#57679
Don't mean to bud in here but seems like same problem and just trying to help by providing more info.
Thanks.

@Calinou
Copy link
Member

Calinou commented Jun 20, 2022

This is now made clear by #61497 (#62004 in 3.x), closing.

#62023 also disables VRAM compression for small textures automatically, so icon.png will no longer use VRAM compression when used in 3D. It's eligible for a 3.x backport, but it requires some testing so it'll have to wait for 3.6.
Edit: The above was reverted by #62245 due to design issues.

@Calinou Calinou closed this as completed Jun 20, 2022
@Calinou Calinou added this to the 3.5 milestone Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants