#Materials and texture assets turn black

1 messages · Page 1 of 1 (latest)

broken pasture
#

Every time I open Unity (6000.1.10f) though it is not limited to this version. My materials and textures are completely broken.

The normals are dark blue (all of them), the albedo textures are all jet black and show up that way in scene even if lit there is no light reflection when i put smoothness to max.

Yet the thumbnail previews in asset folder are correct as you can see in the screenshot but the inspector preview is not correct.

To fix it I have to right click my texture assets and click reimport.

But this happens every time I close and re-open my unity project. I deleted the library folder and it still does it. It did it on other versions of Unity too.

I'm using URP and deferred+ though don't think that's relevant here.

I have no idea how to debug this to find the cause. Is any one familiar with this or may have an idea of what to investigate?

snow aspen
#

Does this happen with textures that don't have mip maps?

broken pasture
#

oh didn't get pinged, sorry i will turn off mipmap and see if it works. some textures don't seem to break

#

sadly turning off mipmaps did not fix it, yet my uv texture still works

snow aspen
#

These textures are not procedurally generated or something, right?

broken pasture
#

nope just assets in the asset folder

#

it seems to be asset related to the textures because reimporting them fixes it and its not all texture assets its just some of them

#

ok i seem to have found the cause but not understanding why

#

i need to have read/write enabled on them?

#

but i dont know why

#

that was the only difference between the uv texture and the sand textures

#

that confirms it, its to do with read/write but i dont understand it

snow aspen
#

Just a wild guess but could it be texture streaming related?🤔

broken pasture
#

i am not very knowledged on what that is or how to look into it

#

one thing i do in a scriptable object is generate a 2d texture array with it, but, the code isn't running when i open unity so i dont see how it relates to that

snow aspen
snow aspen
broken pasture
#

not directly i used get/set pixels in editor then saved the texture 2d arrays as assets

#

so it should be unrelated

snow aspen
#

I see

broken pasture
#

the issue is directly coming from if the texture has read/write disabled

#

then its black

snow aspen
#

Any warnings/errors in the console?

#

This definitely doesn't sound normal.

#

Maybe it's a bug in you unity version? Didn't you have something outrageous like 2023 or something?

broken pasture
#

nope even deleting them i get no errors

#

does it matter that the textures were jpg and not png

#

doubtful but im out of ideas lol

snow aspen
#

If you are Indeed on the alpha/beta version, I'd try upgrading and testing in unity 6.

broken pasture
#

im not alpha/beta just unity 6.1 latest release

so i just did another test.. i deleted the material and textures related to the problem

#

imported new ones i found online and created a new material

#

it still breaks

#

the fact its a new material and new texture assets means nothing is referencing them for sure

snow aspen
#

Does it happen in a new empty project?

broken pasture
#

they still need read/write enabled to show in the scene

#

no just this project

#

could this be related some how?

snow aspen
#

Okay. Must be some project setting then🤔

snow aspen
broken pasture
#

not sure what they are

snow aspen
#

These process the asset on it's reimport.

broken pasture
#

let me uninstall polybrush - not sure what the shader graph one is though

snow aspen
#

Try uninstalling the polybrush package for a test.

#

Shader graph should be fine. Though, maybe check if updates are available

broken pasture
#

that didnt fix it either - let me try one more thing

#

ok when i open the project. it shows the textures for about 1 second then it breaks

snow aspen
#

Could it be that your script is running at that time?

broken pasture
#

ill remove all scripts from the scene heirachy and test it that way

snow aspen
#

Or even test in a new scene

broken pasture
#

ok ill try a new scene aswell

#

removing all the scripts still breaks it

snow aspen
#

Do you have any code that runs in initialize on load? Or on SOs.

broken pasture
#

ok something odd - i made a new empty scene and there was a blue triangle in the scene for half a second then disappeared

#

yeah im thinking something is running automatically some where

#

i dont know how to profile for that though

snow aspen
broken pasture
#

it was a triangle at origin

#

i notice that is happening a lot when shaders compile lately

#

default urp scene before, and then when i reopened the project

#

so it must be editor or scriptable objects at this point

#

i dont know a way to monitor which scripts run right at the start because i wont have time to even open a profiler

snow aspen
# broken pasture i dont know a way to monitor which scripts run right at the start because i wont...

Start by breaking down what it could be.
The biggest possible culprit is your own code that runs on initialization/validation/load or editor scripts.
If you don't have any of these, the next likely culprit is third party packages that include code. Especially those that add or modify editor functionality.
Next, check the official packages in the project. Something that might be dealing with textures could be a culprit. See if you have any outdated packages.
Lastly and least likely is some core editor functionality. This could be affected by project/editor settings.

broken pasture
#

does InitializeOnLoad occur even if the script is not on a game object in the scene

snow aspen
#

It might be when the script instance is first loaded into memory.

broken pasture
#

i want to say its a unity bug but it doesnt happen in a fresh clean project

snow aspen
broken pasture
#

the thumbnail is correct however:

#

and the material thumbnails:

#

im currently installing an older unity version to check if its the latest version specific or my project - if it happens in a version i used a month ago when it didn't happen, then i know its my project

snow aspen
# broken pasture

First of all, it's clear that the issue is with the texture itself, since the preview is broken too.

broken pasture
#

but the thumbnail isn't broken and its only broke if read/write is not ticked

snow aspen
#

The thumbnail is not real time rendered. It's cached is only updated when the asset data is changed.

broken pasture
#

ah okay

snow aspen
#

The preview however renders the in memory version of the texture.

#

Which kinda makes me think about mip maps and texture streaming again.

broken pasture
#

well when i deleted them i got no ref errors so im not sure why the read/write tick box fixes it

snow aspen
#

It probably reloads the texture from disk.

#

Just to be safe, can you also uninstall the shader graph package temporarily?

broken pasture
#

will my custom shaders cause compile errors if i do that

#

there appears to be no way to remove it

#

testing older unity version now - might take a few minutes

snow aspen
broken pasture
#

i think its just permanently in the engine in 6.1 onwards

#

ok its happening on an old unity version too so its project specific

#

i really have a suspicion its related to my custom shaders but they aren't running

snow aspen
broken pasture
#

i dunno what the heck is happening but now the materials are broken even if the textures are not

#

no console errors

#

think i might need to do a fresh unity reinstall and just drag asset folder into the new install

#

because something is seriously broken here

snow aspen
broken pasture
#

Deleted library folder so it would rebuild

broken pasture
#

@snow aspeni think i might have possibly found the cause

#

my hlsl file for a custom node uses StructeredBuffer<T> which is usually set as material.SetBuffer but im thinking the shaders run in scene before ive set the buffer in a monobehaviour

#

so its trying to access a buffer ive not yet binded

#

its a theory anyway lol

snow aspen