I’m trying to Create a Render Target as a Normal Map. However, it doesn’t seem to change the compression settings to normalmap even though I’ve set them (they just save as HDR).
Here’s a little example to show what I mean. The Render Target isn’t changing to normal and when I export it the new .png file it creates still shows the compression settings as HDR.
Any help on how to properly change the Render Target to a Normal Map?
(Worth noting I’m trying to do this through code - I know I could save it to disk and manually change the format but that’s not what I’m looking for).
The saved PNG will not remember what you set the compression type as - it uses the built in PNG compression and doesn’t have anywhere to store the UE compression type (That’s stored in the uasset files).
UE decides which compression type to use when importing PNGs depending on the color information - if the png file has the blue colors in it (dark blue to cyan to greenish) it will recognize it as a NormalMap and change the compression type to Normal then.
All you should need to do is to make sure that the rendertarget has the correct normal data in it - UE will do the rest…
…but the exported render target is still DXT1 / Default format. It doesn’t automatically recognize it as Normal. What am I doing wrong here??
(I also tried making the normal material lit and sending the normal map through the normal channel. It didn’t really make sense to do that and I can confirm that didn’t work either).
Try changing the “Clear Color” to 0.5,0.5,1.0 which is a Normal pointing towards the camera - I just tested it here by just saving that - and it imported it as a normal map…
If that imports as a normal for you, it will be something to do with the draw material - something else to check is to make sure “sRGB” is turned off…
If it doesn’t import as a normal with just the simple Clear Color - it could be that you need to choose a new name for your file - I don’t know if it works this way, but it’s possible you’ve clicked “revert” after UE has decided to import the file as a normal and it’s remembered that setting…
Thanks again @RecourseDesign. I can recreate your graph and it does import the png as a normal map when not using a material.
However, the minute I plug a material into the Render Target it doesn’t work. As you can see the material I’m testing with is super simple and is just an unlit shader with a normal plugged into the Emissive channel. Were you able to get it to work with a normal material plugged in?
I just tried and yes, I can see what is happening - you need to make a couple of changes to your material (atm it’s setting the alpha channel to 0 which UE then interprets as it NOT being a normal):
Set the Materials “Blend Mode” to “AlphaHoldout” and pass in a value of “0” to the Opacity pin:
The way to get it working with a normal map passed in is to change the “Blend Mode” to “Additive” (make sure you’re clearing the render target to 0,0,0,1) - this seems to fill the alpha channel correctly.
Normal Maps are stored as values between -1.0 and 1.0 - so to get that information out from an “unlit” material - you need to multiple the normal value by 0.5, then add 0.5 to make it range between 0.0 and 1.0:
The output looks like it’s correct - as in the colors look correct - I’m guess that the noise that you’re merging it with is the culprit - try adding a FlattenNormal node for the source of that one:
Dear @RecourseDesign ,
Thank you immensely for your prompt response! Following your suggestion, I connected the FlattenNormal node to where your arrow indicates.
Here is the full connection:
Moreover, when I tried to simply input a common Normal texture for baking, the result was quite peculiar. The details vanished, and the baked Normal texture became exceptionally bright.
The normal map I input:
I attempted to follow your instructions, but regrettably, the result still appears to be off. The “DetailAmount” parameter seems to merely adjust the Alpha of the Lerp, yet the final baked image doesn’t seem to be calculated correctly.
The node:
But I tried changing the value of input A for Lerp from [0,0,1] to [0,0,0], and upon baking, there seemed to be some progress.
Adjust the input Lerp value:
That’s close - you just need to add “Normalize” nodes after the “BlendAndleCorrectedNormals” - note that the “TeethSharpNormal” seems to be out of placement too - you may need to clean up that texture.
OMG! After I follow your instruction, add two normalize, and it works perfectly! And I also check the problem you mentioned, I found out there is one connection input in the Multiply node from the original Material Graph.
I adjust the Texture Group option to “WorldNormalMap” and Compression Settings to “NormalMap (DXT5, BC5 onDX11)”, which seems to display more accurately.
But one thing I’m not sure about is the original normal map “Mip Gen Settings” is set to “FromTextureGroup”, but my Baking result is set to “NoMipmaps”, is there any difference between these two options?
The default Compression settings for NormalMap is DXT5 - setting it there is a good idea to ensure it stays as a normalmap.
The “NoMipMap” setting will mean the texture is always stored in your GFX card at the full resolution - if you’re wanting top quality (and this isn’t in a game) then that’s a good setting to use - otherwise leaving it as “From Texture Group” is a good idea - that way it gets controlled from the “Scalability” settings.