Older bump mapped mods (and how to make them work in OpenMW)

Learn about OpenMW mod compatibility, check for problematic mods, discuss issues, and give us feedback about your experience with modded OpenMW.
User avatar
AnyOldName3
Posts: 1193
Joined: 26 Nov 2015, 03:25

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by AnyOldName3 » 25 Sep 2018, 19:45

Is that a description of the vanilla behaviour or the MGE XE behaviour? I know there's supposed to be something hacky about how MGE XE actually uses the normal maps in the environment map slot, and that definitely doesn't sound like bog-standard normal mapping.
AnyOldName3, Master of Shadows

User avatar
Capostrophic
Posts: 476
Joined: 22 Feb 2016, 20:32

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by Capostrophic » 25 Sep 2018, 19:49

Pure vanilla behavior. MCP option applies the local lighting to the environment map colors, but that's it. MGE XE doesn't change anything about bumpmapping - PBR alpha uses normal mapping functionality of PBR but that's separate from bumpmapping - and EMBM is not something unique to Morrowind, just obscure as a technique.

Edit: currently environment maps are applied *after* the lighting is, but the order can be swapped so it's not impossible to set up the MCP behavior of environment mapping.
shitty lingua anglica grammar ftw

User avatar
AnyOldName3
Posts: 1193
Joined: 26 Nov 2015, 03:25

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by AnyOldName3 » 25 Sep 2018, 21:06

There shouldn't be any question about implementing pure vanilla behaviour, so I think we should go ahead with it whenever someone's ready.
AnyOldName3, Master of Shadows

User avatar
Capostrophic
Posts: 476
Joined: 22 Feb 2016, 20:32

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by Capostrophic » 26 Sep 2018, 13:54

I found out that openmw handles spherical environment maps differently, but I'm not sure in what way yet. This is a blocker.
shitty lingua anglica grammar ftw

User avatar
Capostrophic
Posts: 476
Joined: 22 Feb 2016, 20:32

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by Capostrophic » 03 Oct 2018, 16:29

I've got some new information and links to additional sources of helpful info. Will report back soon.
shitty lingua anglica grammar ftw

User avatar
Capostrophic
Posts: 476
Joined: 22 Feb 2016, 20:32

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by Capostrophic » 04 Oct 2018, 16:53

So I got my hands on Gamebryo 1.1.2 (2004) documentation that who knows how happened to get to the internet archive (link removed for legal reasons). Note: this is actually a full Gamebryo copy, so its licensing is questionable. You can find the chm file if you unpack the documentation installer like an archive.

Among other helpful info it obviously touches on EMBM. Some excerpts:
The Bump Map is a special format map that represents the micro-scale bumpiness and glossiness of the surface being textured. The Bump map can be used with an environment map to create specular bump mapping [...]. There are two basic forms of specular Bump Maps: with and without Luminance (or Luma) channels. If present, the Luma channel represents the monochromatic glossiness of the surface. It is exactly equivalent to the Gloss Map above, but only allows attenuation of the environment map, not tinting.

The effect of the specular Bump Map itself is complex. An artist generates an RGB map (or RGBA if they wish to include a Luma channel) where the color channels (only red is used; green and blue are normally set equal to the red, forming a grayscale image) represent a height field — brighter means higher, darker means lower. The image converter converts this into the required format, and, when applied, the slope of the bumps in the bump map are used to shift the environment map on a per-pixel basis, making the surface appear to have subtle bumps in it. Depending on the overall "texture" of the Bump Map, the surface can be made to have any type of look — hammered metal, brushed aluminum, gritty stone, etc.

[...]
Bump Map Luminance Coefficients

Because Bump-mapping cannot be used with a gloss map, most bump-mapping hardware supports adjusting the luminance of the environment map (also known as the glossiness). The luminance coefficients are normally stored in the luminance channel of the bump map. The luminance scale and offset may be used to modify these values on the fly. The overall effect of bump mapping is as follows:

Color = BaseTexMapResult

+ BumpedEnvMap * (LumaOffset + LumaScale * BumpMapLuma)

With the defaults of LumaScale = 1.0, LumaOffset = 0.0, this formula becomes:

Color = BaseTexMapResult + BumpedEnvMap * BumpMapLuma
The Bump Matrix: A 2x2 matrix that is defined by the four bump map matrix entries (SetBumpMat00, SetBumpMat01, SetBumpMat10 and SetBumpMat11) defines the rotation and scale of the bump map's dU and dV channels w.r.t. the environment map coordinates. The incoming bump map dU and dV as sampled from the bump are multiplied as a vector times the 2x2 matrix, and then applied to the U and V values computed for the environment map. Most frequently, the 00 and 11 matrices are set to the same positive value between 0 and 1.0, depending on the roughness of the surface. The 01 and 10 elements are left at 0.0 in these cases. Other values may be used to rotate the basis of the bump mapping.

The Bump Luma Scale and Offset: Because Bump-mapping cannot be used with a gloss map, most bump-mapping hardware supports adjusting the luminance of the environment map (also known as the glossiness). This is normally stored in the luminance channel of the bump map. The luminance scale and offset values may be used to modify these values on the fly. The Scale value is multiplied by the incoming Luma value from the bump map (or times 1.0 if the Bump Map has no Luma information), and then is added to the Offset value. Generally, the Scale is set to 1.0 and the Offset to 0.0.
There's a suspicion that Morrowind bumpmaps must always lack a luma channel that I'm yet to confirm (Morrowind doesn't support gloss maps in general which might be the case here too). If it's correct, BumpMapLuma can be considered 1 here.

While it's not exactly NetImmerse 4.0 source code docs, it's close to that.

There's another suspicion that Morrowind bumpmaps are not heightmaps and they can't just be made monochrome to apply in proper. Sounds unlikely.

My previous observing of environment maps looking differently may just have been the case of using per-pixel lighting for OpenMW - it uses more precise per-pixel normals for environment maps.
Last edited by Capostrophic on 05 Oct 2018, 12:07, edited 1 time in total.
shitty lingua anglica grammar ftw

User avatar
AnyOldName3
Posts: 1193
Joined: 26 Nov 2015, 03:25

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by AnyOldName3 » 04 Oct 2018, 18:36

Note: this is actually a full Gamebryo copy, so its licensing is questionable.
I'm not sure how much this applies if you're only looking at documentation instead of the source, but bear in mind we're supposed to clean-room reverse engineer Morrowind in order for Bethesda to have no grounds to shut us down. If that does apply to documentation, then you might have removed your right to implement the same system in OpenMW. Zini etc. should definitely be consulted before proceeding.
AnyOldName3, Master of Shadows

User avatar
wareya
Posts: 263
Joined: 09 May 2015, 13:07

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by wareya » 04 Oct 2018, 20:49

I'm pretty sure it's valid as long as the person reading the documentation and doing the programming (on that particular task) are different people, at least in the US. In fact, in the US I'm pretty sure that method even applies to code. And european countries tend to have more liberal reverse engineering laws than the US.
paying attention to #1751 #2473 #3609 #3862/#3929 #3807 #4297 #4623

User avatar
AnyOldName3
Posts: 1193
Joined: 26 Nov 2015, 03:25

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by AnyOldName3 » 04 Oct 2018, 21:46

But Capostrophic is the one who's read the documentation and he's also the one who I thought was going to write the implementation. Now I've read the quoted excerpt, if the rule applies, I wouldn't be allowed to implement it either, so we're basically stuck with just Drummyfish who's done shaders before and hasn't read it.

Basically, we need someone to confirm whether the rule applies to potentially dodgily-sourced documentation. I think it might do, as I remember Dolphin's developers got a little bit panicked when the programmer's manual for the Wii CPU got uploaded to their forums.
AnyOldName3, Master of Shadows

User avatar
psi29a
Posts: 4380
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: Older bump mapped mods (and how to make them work in OpenMW)

Post by psi29a » 05 Oct 2018, 09:21

Having knowledge to do a thing, under a particular license, does not prevent you from writing your own implementation. Otherwise every knowledge-worker (aka software developer) couldn't do their job when they move to a new company.

My company for example forbids me from providing to coworkers information about how I solved a problem at a previous company. That does not mean I can't use what I've learned to create something new based on the knowledge I have gained.

The same legal question is applied to plagiarism. You copying word-for-word? You're up shit creek and a shitty person for not using your own words.

Reverse engineering for the sake of interoperability is actually a well defendable position and has been used in courts. Although not exactly the same thing, the Oracle vs. Google case (aka are headers licensable?) is providing the point that being able to communicate with software is 'open' and not copyrightable/patentable/licensable. This would also invalidate the AGPL license as well as a result. I digress...

Knowing how something is done, regardless of method, does not constitute IP theft if you can write an 'original' replacement. Think about the when JohnC wanted to open-source Quake3 but couldn't because there was a copyrighted (or patentended?) function, he had to re-write a function that turned out to be better, to replace it and then GPLed it.

Another example is the S3TC drop-in replacements. We all know how S3TC works, we have the code examples, but we couldn't implement without a license. So people made their own 'compatible' versions like S2TC to be a drop-in replacement which was legal.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests