Jump to content

Making Normal map in gimp


Recommended Posts

I've been playing around with a custom kerbal head texture adding some detail, right now just throat and teeth (all that white, but only a tiny area is used). I want to make a normal map. gray desaturated it and then stretched the level range. I then used gaussian and selective gaussian blur with low settings to remove the gradient created by stretching the range. But I find the normal map plugin has a lot of settings. Do I just use default? or do some need changing?

Also for saving, I see there is a DXT5nm .dds format option. I'm guessing that is the correct format to use?

Link to comment
Share on other sites

I've been playing around with a custom kerbal head texture adding some detail, right now just throat and teeth (all that white, but only a tiny area is used). I want to make a normal map. gray desaturated it and then stretched the level range. I then used gaussian and selective gaussian blur with low settings to remove the gradient created by stretching the range. But I find the normal map plugin has a lot of settings. Do I just use default? or do some need changing?

Also for saving, I see there is a DXT5nm .dds format option. I'm guessing that is the correct format to use?

My personal settings for the GIMP normal-map plugin are:

Filter Type: Sobel 3x3 (though, you can play around to find what works best for you)

tick the check-box for 'invert Y' (needed, as otherwise the normals come out...uhh..partially inverted)

All other settings left at default

Yes, DXT5nm is the correct format for normal maps.

Link to comment
Share on other sites

...IF using dds that is. DXT5nm causes it to become a pinkish-hued normal map and removes a lot of details from the map as a whole... at least in most cases. There are some outlying cases where the resulting normal doesn't get a hue change at all. I've found that highly-detailed normal maps, especially with vertical-line details in it, will loose a lot of those details in the conversion. You might get around that by making the normal map with the original texture already inverted, and using higher-detail filters like the Sobel 3x3 may also help. For some normal maps, I've had to resort to leaving them in png format to keep the finer details alive.

However, if doing it the manual way like you described works best for you, all power to you. You can still save in the DXT5nm format, you'll just want to make sure your y-axis of the normal is properly oriented like it does when inverting the Y axis in the normal map plugin. I honestly don't understand it enough to explain it here.

Edited by Gaalidas
Link to comment
Share on other sites

  • 6 months later...

I've been messing with this some more and ran into more problems. KSP seems to have partly locked the light source to below the kerbal, so shadows are above instead of below. Also, KSP randomly inverts the ears.

Here is the normal map: https://www.dropbox.com/s/3frgyzadknczn7f/kerbalHeadNRM.dds?dl=0

And here is the grey scale: https://www.dropbox.com/s/5k8ilsr6utnaivq/kerbalHeadNMGrey.png?dl=0

Link to comment
Share on other sites

On 9.9.2015 at 9:55 PM, Gaalidas said:

...IF using dds that is. DXT5nm causes it to become a pinkish-hued normal map and removes a lot of details from the map as a whole... at least in most cases. There are some outlying cases where the resulting normal doesn't get a hue change at all. I've found that highly-detailed normal maps, especially with vertical-line details in it, will loose a lot of those details in the conversion. You might get around that by making the normal map with the original texture already inverted, and using higher-detail filters like the Sobel 3x3 may also help. For some normal maps, I've had to resort to leaving them in png format to keep the finer details alive.

However, if doing it the manual way like you described works best for you, all power to you. You can still save in the DXT5nm format, you'll just want to make sure your y-axis of the normal is properly oriented like it does when inverting the Y axis in the normal map plugin. I honestly don't understand it enough to explain it here.

Unfortunately, that is quite wrong.

First, please keep in mind that a normal map doesn't store color. It stores x/y/z coordinates in object or tangent space.

DXT5nm INCREASES the quality when using dds as it stores the information in the green and alpha channels of the image (which are compressed less lossy - red 5bits, green 6bits, blue 5bits, alpha 8bits - for the eye is mostly sensitive in green-ish wavelenghts and you need 8 bits=256 values for smooth alpha), while not storying the z coordinates as it can be reprocuded from the rest of the information and filling the red and blue ones with a single color to minimize compression artefacts as the compressors are usually comparing the differences between the channels to weight the lossy compression that is used (what color exactly can be variing, when using white, the result will be the pinkish hue as described).

As the channels are swizzled, its obvious why, when looked at with a standard image viewer, a "loss" of (vertical) detail may be seen. Because this information in now in the alpha channel!

So long story short: dxt5nm uses some tricks (only storing x and y coordinates + storing them in the channels with the least lossy compression + minimizing artefacts by not storing different data in red and blue channels) to increase the quality of a normal map stored in a dds file. The flipped storage has nothing to do with dxt5nm.

 

@Vorg: could be false coordinates. KSP uses y+ up, x+ right. z- far

Edited by InsaneDruid
Link to comment
Share on other sites

So how do I fix it? I use Invert Y when making the normal to get the normal map to look as expected. There is also an Invert X That I leave unchecked along with swap RGB

For Filter I have tried Sobel and Prewitt 3x3. Sobel looks a bit crisper in the preview window. 5x5 seems to scale too much making it clip in some areas.

I leave Minimum Z at 0 and Scale at 1. I messed with fractional scales and the 5x5 options, but it didn't look like it was working as well and if it is scaled any more, you get the stair step from using 8 bit 256 grey scale. I don't know if Gimp can do 16 bit grey scale. But I would have to then smooth it which gets tricky not to smooth stuff you don't want smoothed.

I leave the other settings default, Height Source: RGB, Alpha Channel: unchanged, conversion: none, DU/DV map: none. I tried googling more info on this plugin, but there just doesn't seem to be much. Everyone assumes you know exactly what all the settings are and do or know code well enough to read through it and figure it out.

 

There are also some option in the dds export that may or may not help, but I don't think so: "Use Perceptural error metric", "Apply gamma correction", Preserve alpha test coverage.

Link to comment
Share on other sites

More testing and I am noticing that the lighting is wrong. When on the pad, light should be coming from above and the base kerbal is lit up correctly. But the normal map is providing a secondary lighting matching how the normal map image is lit. When viewing it with just an image viewer and in Gimp, you see light under the noise and ears, etc. It's as if a light is above the image which gives it the 3d effect. But that lighting seems to be burned in. A normals map is supposed to tell the game engine how to reflect the light across the texture to ad the 3d effect, not add lighting. I have tried making the light effect come from the top, but Gimp will only put the light from above. If I create the map and rotate it to match KSP's strange upsidown requirement for dds files, gimp inverts the image. And KSP shouldn't be using that light source anyway.

Link to comment
Share on other sites

A normal map provides no light source. Never. As said before: a normal map doesn't store color or brightness. It stores information about the normals (and thus the angle of an surface in a point). Its just an array of arrays of data, stored in an existing file format that is usually used for images.

I don't use gimp and create my normals with shadermap2. So, I cant tell what buttons to press as I don't know what buttons there are ;)

Can you make a screenshot of the head in game? What you describe sounds like the normal map procudes an inverted effect of what you want, ie bumps that should be higher than the average are shaded like they are indentations, and vice versa?

Link to comment
Share on other sites

Don't have time to fire it up now. Maybe latter tonight. I'm finding the invert problem changes with nearly every tweak I try. Always, at least 1 ear is inverted, sometimes both. Sometimes the nose is inverted, sometimes not. But always something. Not even been looking in the mouth because to get them to open wide and keep the mouth open, I launch them and eva a few Km up letting them fall. Get a nice view inside then :).

The Normal map link and a PNG of the grey scale I'm using atm is posted a few post up. Here is the normal: https://www.dropbox.com/s/3frgyzadknczn7f/kerbalHeadNRM.dds?dl=0

Just put that in the "default" folder for texture replacer. Then put a command pod on the pad with a male kerbal in it (teeth also work for females, but not the outside of the face where the problem seems to be), and eva him.

Link to comment
Share on other sites

As I said, its just inverted (hights are lows and lows are heights). By inverting the grayscale heightmap it should come out ok. Or there may be an option in the filter for gimp. As I said, I never use Gimp. Maybe invert scale?

I generated a test map with shadermap and everything is fine. untitled-16kq5l.jpg.

Link to comment
Share on other sites

That smooth area around the eyes wouldn't even show up for me. Did some more testing with starting with inverted grey scale, etc. Ether it would be all inverted or partly inverted. So I tried something else. I rotated the image 180 for the PNG format (think maybe it is flipped, not rotated, textures where not aligned.) and used the default PNG options which had max compression set. And it worked. Still not as pronounced as what you have, but it was all there. Even the lip area which wasn't showing, now gives a sharp double lip. The grey scale needs much more work now that more of it gets through.

So, the problem is in the DDS Export plugin. It also has a lot of options, anyone of which may be the problem, or none of them. The little expermenting I did with those options seem to make things much worse right off before even trying it in game.

Link to comment
Share on other sites

  • 1 month later...
On 3/14/2016 at 0:30 PM, InsaneDruid said:

Unfortunately, that is quite wrong.

First, please keep in mind that a normal map doesn't store color. It stores x/y/z coordinates in object or tangent space.

DXT5nm INCREASES the quality when using dds as it stores the information in the green and alpha channels of the image (which are compressed less lossy - red 5bits, green 6bits, blue 5bits, alpha 8bits - for the eye is mostly sensitive in green-ish wavelenghts and you need 8 bits=256 values for smooth alpha), while not storying the z coordinates as it can be reprocuded from the rest of the information and filling the red and blue ones with a single color to minimize compression artefacts as the compressors are usually comparing the differences between the channels to weight the lossy compression that is used (what color exactly can be variing, when using white, the result will be the pinkish hue as described).

As the channels are swizzled, its obvious why, when looked at with a standard image viewer, a "loss" of (vertical) detail may be seen. Because this information in now in the alpha channel!

So long story short: dxt5nm uses some tricks (only storing x and y coordinates + storing them in the channels with the least lossy compression + minimizing artefacts by not storing different data in red and blue channels) to increase the quality of a normal map stored in a dds file. The flipped storage has nothing to do with dxt5nm.

 

@Vorg: could be false coordinates. KSP uses y+ up, x+ right. z- far

Ah... good to know.  I was only speaking from my experience.  The expertise simply doesn't exist in my brain.  They sure look less detailed though, which really stinks.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...