Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3   Go Down

Author Topic: Normal / Bump mapping  (Read 13390 times)

0 Members and 1 Guest are viewing this topic.

vpmedia

  • Modder
  • member
  • Offline Offline
  • Posts: 6652
  • www.vpmedia.hu/il2
    • VPMEDIA SKINS
Re: Normal / Bump mapping
« Reply #12 on: March 06, 2015, 07:52:33 AM »

I noticed two things: the source of the normal map must have a higher contrast level + you cannot apply this normal map over the texture it was generated from, try a Kurfurst skin from here: http://www.adlerhorst-hangar.com/kurfuerst.html

Cheers
Istvan

edit: here's a corrected tga source
http://ulozto.net/x4Cft3xC/vp-bf-109k-normal-map-tga

Ghost129er

  • EX F.A.C. #65
  • member
  • Offline Offline
  • Posts: 1317
  • Ghost of the skies.
Re: Normal / Bump mapping
« Reply #13 on: March 06, 2015, 08:12:10 AM »

I RPG-d you a PM. Check it and lemme know how it goes.
*Waits impatiently.*
Logged
But whenever they talked about him, they always had a slight smile on their faces.. And that, perhaps, maybe your answer.

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #14 on: March 06, 2015, 03:55:18 PM »

OK.

This is with the new normal map, but no texture. A few issues, but quite nice.




With the texture it's less obvious



Doing a turn on and off with a different view.








Logged

Herra Tohtori

  • Modder
  • member
  • Offline Offline
  • Posts: 671
Re: Normal / Bump mapping
« Reply #15 on: March 06, 2015, 08:56:39 PM »

I don't actually see any normal mapping there on the last pictures. I'm also a bit confused, since only one image posted by vpmedia actually seems like a normal map (the radiosity one). Also, 1024^2 is rather insufficient resolution for good, detailed normal mapping on something like a fighter aircraft. Fine for testing purposes, though, I suppose.


At any rate, your code seems to be working based on the earlier example, it's just that generating normals from a texture is an exercise in futility and doomed to failure. There is no possible way to generate good height maps from diffuse texture information alone, and if you're working just with textures, you need a good height map to generate a good normal map.

If you don't have a nice height map available you kind of have to craft one yourself.

The other path is to create a high detail model with same UV coordinates as lower detail model, bake the high detail to a normal map, and then use that on the lower detail model.


That said there are some ways to improve the results you get from a diffuse->height->normal conversion. Here's what I ended up with, using the given height map as a source:




Stainless, normal maps are probably something that only few people would be interested in modding. As such, I think it would be prudent to optimize the quality and performance of the normal maps over ease of use.

Two things you need to decide are channel assignments, and file formats. The basic RGB normal map format usually stores the normals information in red and green textures. Some applications leave blue channel completely white (blank), some store some occlusion information there (which basically looks a lot like a faint trace of the height map in most cases).

For the purposes of normal mapping in tangent space, only the normal data is used, leaving the blue channel as ballast unless you decide to store some other information there - like glossyness map, for example.

Another popular arrangement of channels is to use RGBA textures, and store normal map information on green and alpha channel. This ensures compatibility with a popular way to use DXT compression for normal maps (DXT5nm to be precise).

You could also use either 3DC (two channels, independently compressed) or u8v8 (two 8-bit, uncompressed channels) since for tangent space normal mapping you only need two channels.

Of course, it would be ideal if the program could identify the normal map type from the file input and assign the normals data appropriately from there. Basic identification by headers, number of channels, that kind of thing could be used to tell the program where to look for the normals information. That way, all of the above options could technically be valid.


For sanity reasons I would suggest just using basic, uncompressed RGB textures (like the one I posted) as a WIP phase format. It is so much easier and faster to work with them than one of the more exotic varieties, even if the other formats would offer better performance.
Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #16 on: March 07, 2015, 02:44:24 AM »

I have plans to support all sorts of textures on airframes.

Specular maps. Reflectance maps. Self illumination. and anything else that looks like it will be useful.

All are optional.

You can just load a vanilla MSH from here and it will work, or you can start playing and end up with something that looks really good.

I use xNormal to convert height maps into normal maps. It's a pretty useful tool.

The code is going to take a few iterations to get right.

For example I have a float value that modifies the strength of the bump normal. On this pass it is 1.5, before it was 1. Let me keep playing



Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #17 on: March 07, 2015, 02:58:43 AM »

This shows what I am looking for a bit better.

The first image is without bump mapping, the second with.

You can see the edges of features are much more defined, I still have to play with the lighting, but as a first pass it's not bad.

As for ease of use, I have added bump map support to my mod tool. So it's as easy to add as changing a skin.







Logged

vpmedia

  • Modder
  • member
  • Offline Offline
  • Posts: 6652
  • www.vpmedia.hu/il2
    • VPMEDIA SKINS
Re: Normal / Bump mapping
« Reply #18 on: March 07, 2015, 03:25:36 AM »

You cannot use this normal map with the same texture it was generated from because it has the same bump maps hardcoded so you only increasing the effect a bit, try a Kurfurst skin from here: http://www.adlerhorst-hangar.com/kurfuerst.html

Herra Tohtori

  • Modder
  • member
  • Offline Offline
  • Posts: 671
Re: Normal / Bump mapping
« Reply #19 on: March 07, 2015, 07:53:59 AM »

You cannot use this normal map with the same texture it was generated from because it has the same bump maps hardcoded so you only increasing the effect a bit, try a Kurfurst skin from here: http://www.adlerhorst-hangar.com/kurfuerst.html

Well, that's only partially true. Most of the skins made for older games have lots of details as static bevels because they didn't support normal mapping, and you're definitely right that one shouldn't use a normal map AND bevels on the diffused texture at the same time. It's not going to produce optimal results. It'll look weird, and wrong, and it's better to have a "flat", non-beveled diffuse texture and let the normal map take care of shading the bumps and recesses appropriately.

But you can still use a texture with baked bevels in conjunction with a normal map, especially in testing stage. It's just not going to look particularly good.

Then again. Apart from testing, you shouldn't try to generate normal maps from any diffuse texture to begin with. It just doesn't work very well...
Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #20 on: March 08, 2015, 05:57:58 AM »

I grabbed that vanilla texture and started using that in testing.

I also went back to the original height map and played around with some settings in xNormal. This gave me the following normal map.




I then made the bump strength a variable and added a slider to the gui. This is a sequence of screen shots from 0 to max. You can see the code is doing it's job, but it has issues. It's swamping the original vertex normals. Not sure what is the best way to fix that


















Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #21 on: March 08, 2015, 06:24:42 AM »

Doing the same with the normal map you supplied shows better results.
















Logged

Herra Tohtori

  • Modder
  • member
  • Offline Offline
  • Posts: 671
Re: Normal / Bump mapping
« Reply #22 on: March 08, 2015, 03:47:33 PM »

The problem with that normal map is that it's not normalized, so to speak.

Tangent space normal maps contain the information on what direction the face normal should be angled to, in U and V coordinate directions. This corresponds to two values in the range of [0,255] with 8-bit channels.

That means that 0 and 255 are the extreme limits for the normal vector's deflection, and the middle value (127 or 128) reflects the "neutral" position.

So when you have "flat", non-angled area, the red and green channel should have values of 127. Looking at the normal map produced by your tool, the flat regions actually have values of 169 on both red and green channel. In other words, the tool outputs a "too bright" normal map and that causes a constant deflection in the normals even on the areas where you would want the normal vector to point straight away from the surface.

And since some areas are mapped differently from adjacent areas, this can lead to "changes" in the direction of the normal vectors, and results in change of apparent brightness as the lighting adjusts for that. You can see the difference between the underside of the wing and the flaps.

Adjusting the levels on the normal map so that the flat areas have correct, neutral colour should work. In this case, adjusting the input levels from [0,255] to [84,255] corrected the flat grey areas from 169 to 127.

This is how the Level adjustment tool looks like in GIMP, I'm sure Photoshop has some kind of equivalent tool with a histogram for adjustment.



This is how the adjusted normal map should look like:



And, since I personally prefer the "cleaner" look where the blue channel contains no misleading information, here's how it would look with that scheme (fully white blue channel):




Both of these should work equally badly, considering how noisy the original texture is. But should work OK for testing purposes.
Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Normal / Bump mapping
« Reply #23 on: March 09, 2015, 02:29:47 PM »

Okay here we go, I'm happy the code works.

Nice work Herra

Here is the flat shaded mesh.



And two images with the bump map enabled at different strengths







Logged
Pages: 1 [2] 3   Go Up
 

Page created in 0.043 seconds with 28 queries.