Once the object is rotated, the material changes it's brightness.

I’m using 's plugin to use external textures.
I’m importing them as jpg’s.
In here you can see two cubes that are exactly the same with the exact same material.
The right cube is upside down ( 180 degrees rotated ).


It doesn’t happen if I assign textures from the content browser to this material.
Any idea what could cause this?

Ok I’v noticed now it happens only if the material uses the external normal maps.
Is there any way to fix it?

Also, I’v noticed changes with normal textures from the content browser if I multiply the normal map intensity really high.

1 Like

That’s most likely caused because texture is interpreted as sRGB, and normal maps shouldn’t. Is there a way for your to disable it, as it is with normal textures?

Thanks.
This is the function’s code, Do you have any idea what has to be changed?


UTexture2D* UVictoryBPFunctionLibrary::Victory_LoadTexture2D_FromFile(const FString& FullFilePath,EJoyImageFormats ImageFormat, bool& IsValid,int32& Width, int32& Height)
{
	
	
	IsValid = false;
	UTexture2D* LoadedT2D = NULL;
	
	IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
	IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(GetJoyImageFormat(ImageFormat));
 
	//Load From File
	TArray<uint8> RawFileData;
	if (!FFileHelper::LoadFileToArray(RawFileData, *FullFilePath)) return NULL;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	  
	//Create T2D!
	if (ImageWrapper.IsValid() && ImageWrapper->SetCompressed(RawFileData.GetData(), RawFileData.Num()))
	{ 
		const TArray<uint8>* UncompressedBGRA = NULL;
		if (ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, UncompressedBGRA))
		{
			LoadedT2D = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), PF_B8G8R8A8);
			
			//Valid?
			if(!LoadedT2D) return NULL;
			//~~~~~~~~~~~~~~
			
			//Out!
			Width = ImageWrapper->GetWidth();
			Height = ImageWrapper->GetHeight();
			 
			//Copy!
			void* TextureData = LoadedT2D->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
			FMemory::Memcpy(TextureData, UncompressedBGRA->GetData(), UncompressedBGRA->Num());
			LoadedT2D->PlatformData->Mips[0].BulkData.Unlock();

			//Update!
			LoadedT2D->UpdateResource();
		}
	}
	 
	// Success!
	IsValid = true;
	return LoadedT2D;
}

In that case, there wouldn’t be an issue with color correction at the import stage.

Could you check color profile in Photoshop or whatever program you use to edit images, to make sure it does NOT use sRGB while working with normal maps?

You can get Photoshop to stop color management on the document you’re working, by following these instructions:
http://help.adobe.com/en_US/creativesuite/cs/using/WSBB0A8512-8151-408c-9F79-4A9E9E3BA84C.html#WSF8890E7B-90A1-4a11-859E-0BCE0D1A088B

Let me know if this solves your problem.

When using UE4’s built-in system to import normal maps, it checks what color space source is coming from, and adjusts values it reads. Perfectly flat normal map should have values of 128,128,255, but this often gets pushed into 168,168,255 for color-corrected documents (I’m not sure if this number is accurate), when converted to xyz vector this vector is slanted, and not normalized, hence incorrect shading that depends on orientation of the object.

Thanks man! With your help I’v found the solution!

I’v used ImageMagick and entered this line inside the command line window: ( The image I wanted to convert was in the same folder as the program for convinient )


convert source.jpg -set colorspace RGB destination.jpg

(Hold shift and right click on the program’s folder so you will have the option to open the command window with this path )

It converts it from sRGB to linearRGB.

The normal map becomes brighter. You can higher the intensity of the normal map inside the material editor. it will be more noticable and will not cause this wierd dark effect!

Another note: Lossy image compression formats are not well suited for images that does not store pictures. Those algorithms are tuned to compress without huge visual quality loss. Normal maps store vector direction data which is not them strong suite. I would always use lossless compression like png.

The images supposed to load at real time. This is why I need them to be small as possible.

The images supposed to load at real time. This is why I need them to be small as possible.
[/QUOTE]

Uncompressing jpg can be slower than just loading the non compressed file. (in all test that I have ever done from normal hard drive)
What I would do is to load dxt compressed file from DDS. Then you don’t actually have to anything but load it before sending it to the gpu.

Do you care to explain it? I’m not familiar with that dxt and DDS you are talking about.

http://www.fsdeveloper.com/wiki/index.php?title=DXT_compression_explained
This is compression method that UE4 use by default on PC. DDS is just container format. DirectDraw Surface - Wikipedia