Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: fightermedic on September 27, 2016, 04:37:22 am

Title: Distribution of color information sub-optimal for PBR right now
Post by: fightermedic on September 27, 2016, 04:37:22 am
I find that our PBR maps as they are right now have 2 problems, please let's discuss this while there are still extremely few PBR ships, and before it is to late and everything is set in stone :

1: For most of our ships, the "most important" map is going to be the -reflect map, as many spaceships are going to be a big part made out of metal, this is the map that is going to be the most "visible" in many cases + it holds the roughness information; BUT it's also going to be the one with the most .dds compression errors
it is the only map using 4 channels, 3 for color, 1 for roughness; This is very bad because of compression artefacts, maps with only 2 or 3 channels being used produce MUCH better results in my experience!
hence the following suggestion:
move the roughness somewhere else, my suggestion would be the blue channel of the AO map

advantages:
- less compression artefacts in the relfection map!
- roughness ALSO is going to have less artifacts
- reflection map can be compressed without alpha channel -> saving memory, more than 1/2 of the texture actually!
- ao map can still be compressed without alpha channel -> memory for ao does not increase -> net gain of memory!
- it is more intuative to work with the reflection map, as not the whole damn thing is transparent as soon as it has some roughness

disadvantages:
- slightly less intuative AO map; Roughness in AO, hugh? mostly just a problem the very first time however
- slightly more compression artefacts in the AO, but here they matter the least by far, they are going to be the least visible here!


2. normal maps using the green/alpha channel, instead of the traditional red and green. there are several reasons to not do this anymore, if we are changing the renderer anyway:

advantages:
- no more alpha channel needed in normal maps -> saving memory, again only half the size!
- normal maps are easier to create, less steps needed than to convert from red/green/blue to green/alpha
- it's more intuative, almost every other application out there uses these channels

disadvantages:
- legacy support, but this should be simple: if there is a -albedo map, read the old channels, otherwise, the new ones! something like this has to be in place already to read the old -spec maps anyway

overall i just don't see any valid reason not to make these changes, as long as we still can, the memory saving aspect alone should be enough for a start, and the ships are only going to look better for it!
i hope i didn't forget anything important  :confused:
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on September 27, 2016, 11:15:47 am
I agree with the second point for the most part, so let's address the first point.

I highly doubt anyone is going to be willing to change the reflectance map now. The issue with compression artifacts in dds is something that's been addressed in the past and I believe the general concensus is to use either nvdxt or Paint.NET. The suggestion to put the gloss in the AO map is absolutely inadvisable as it has no relation to occlusion and is only going to confuse modders.

It is not appropriate to think that, because the information hasn't been fully compiled and released in an ordered way, the system should be partially rewritten to cater to one persons preference.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: fightermedic on September 27, 2016, 02:30:36 pm
well, changing the few reflectance maps that already exist would be a matter of minutes, and seeing how something like 90% of those are on ships i created, and would have to change, that kind of defeats the point
compression artifacts are a real problem on reflectance maps, the leviathan textures for example are full of ugly violet artifacts everywhere, and yes, i know how to compress those maps
yes, my solution might be a bit confusing, as i did write myself, but i think the technical advantages outweigh that by far - on larger maps thats more than 10 MB of video memory for each map! + the artifacts, that could be so easily dealt with by moving the roughness
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on September 27, 2016, 03:54:33 pm
Relevant things STAY together, we're not going to change that ever. There also isn't really a technical advantage to this, you're going to get artifacts regardless and the way the reflectance and specular maps get loaded currently always loads the alpha(in fact several maps do, even if the alpha isn't filled) so you wouldn't actually get that memory back. The artifacts are going to be unavoidable with any sort of lossy compression you use unfortunately. You can get around this by using different save formats like 8888, especially for testing. Additionally, some of the textures you've made show signs of multiple compression procedures, so if you want to know why there are a lot of artifacts, probably take a look at what you're doing your work on before finalizing everything.

I understand that the artifacts are frustrating, but the pipeline was designed the way it is for a reason.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Spoon on September 27, 2016, 08:16:12 pm
Quote
well, changing the few reflectance maps that already exist would be a matter of minutes
Yeah. No.

Unless you are willing to go change all 95 reflect maps that I made for WoD for me, I'm going to say. No, too late. Should have brought this up with Swifty months ago. There has been a long period to test these things and suggest these things, but apparantly you didn't care to do it back then. I'm sure Swifty has better things to do than to make fundamental changes to his (probably massively complex) code after its effectively 99% done and in trunk and already in use by people.

And for what? A few artifacts? big woop. There are a lot of games out there that don't have pixel perfect graphics, and that don't run on an engine that was made in 1998.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: fightermedic on September 28, 2016, 02:24:53 am
Quote
well, changing the few reflectance maps that already exist would be a matter of minutes
Yeah. No.

Unless you are willing to go change all 95 reflect maps that I made for WoD for me

just for the record: i would

as for the rest: for mostly grey metal ships the artifats are massive, and only in this one type of map, because of the 4 channels being actively used

furthermore i can not for the love of god believe that it should not make a difference in the memory usage which method the maps are compressed with
if that kind of change in the code would be anything but minor, it would massively surprise me - the complexity is in the rendering, not which channel gets loaded where

my opinion stays unchanged, a substantial potential for optimisation is wasted here, and the negative consequences would be extremely minor
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Chromatix on October 04, 2016, 12:41:00 am
Freespace has quite a few grey metallic ships - most of the Terran fleets in particular, with the Colossus, Orion and Hecate being the main exceptions to the rule.  If the compression artefacts are objectionable on those, that's a Problem which needs to be Solved.

Moving the roughness channel away from the colour channels seems like a logical thing to do in my book - and if 95+ ships need some texture rework done as a result, that's better than having ten times that number need it later, when someone finally decides enough is enough, by which time half the original, uncompressed texture files have been lost to bitrot.

The suggestion of putting it in with the AO channels is as good as any, especially if the resulting artefacts are not objectionable.  Are both maps using the same texture coordinates and resolution already?  I tend to agree that moving channels around isn't too difficult from a programming point of view, but I'll defer to Swifty (if he weighs in on the discussion), since he knows the code better.  It might be feasible to detect how many channels are defined in a texture, and distinguish the two cases that way - that would avoid the rework, but might increase the number of shaders in flight, which would be bad.

I have to ask, why was putting normals in green and alpha done in the first place?  It's definitely better to not do that.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on October 04, 2016, 09:52:48 am
Moving the roughness away from the reflectance maps alpha channel isn't going to help. From what I remember during discussion and research, DDS artifacts are due to the compression algorithm itself acting on 4x4 squares in the image in addition to sometimes dropping information from the red and blue channels during compression. The part about the information drop is probably why we chose to use the green alpha normals. Sometimes the algorithm goes awry, resulting in strangely colored areas on the texture or black/white lines around the regions of uniform color.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Spoon on October 04, 2016, 11:54:30 am
Holy poo poo the recent nightlies have done something naughty with the pbr because everything is turbo black. This turned out to be a fortunate thing in this case actually, cause I can more easily show the artifacts.

(https://ibin.co/2xKPuDMD3xLw.jpg)
This is with the normal map you put in the release

(https://ibin.co/2xKQXF2yqN26.jpg)
This is with a normal I quick and dirty made

I actually wrote a lot of very mean words, but I'll be nice.

Okay, I lied, I'll say something quick and mean anyway.
A lot of what you wrote in this thread is poo poo, and I think the fault lies with the user, ergo your maps. You are frustrated and are trying to blame it on code and stuff, looking stupid in the progress. Look, I understand. I've absolutely been there. The artifacting on normal maps actually ruined a whole day for me before I figured it out with the help of Dahblount. If there are artifacts on the reflect map, its user error. If there are artifacts on the normal maps, it's probably user error too. I found out that if you don't make the normals in a pretty specific way, it becomes ugly like in the first pic.

and if 95+ ships need some texture rework done as a result, that's bet-
No. Bugger off.

Okay, got that off my chest.

When I was first trying out reflect maps, I had this little issue
(https://ibin.co/2xKHApQ4yhBA.jpg)
Turns out that was completely my fault for not painting inside the uv islands properly. The levi's reflect map is uh, well. I'd use 'dirty' as word to describe it.
A reflect map just has to be a simple "this is gloss, this is matte" map really.
like:
(https://ibin.co/2xKJVhJBDWFc.jpg)
It minimizes the odds of light reflecting in weird ways.

Meanwhile the levi's map looks like:
(https://ibin.co/2xKJzyzIXITd.jpg)
And with the uvunwarp overlayed on it, it didn't exactly look like everything was painted nice and cleanly inside the island. THEN AGAIN, I have no idea where on the ship those islands actually are. So that very well might not matter at all.

But I don't actually think the reflect map is the issue. It's the normal.

Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Kobrar44 on October 04, 2016, 07:04:44 pm
The specific textures/channels are sampled in the shaders, so if you need to rearrange the channels to meet your needs you can have your own version of shaders distributed with your mod. That said, you probably don't have such needs.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: mjn.mixael on October 04, 2016, 10:30:21 pm
The specific textures/channels are sampled in the shaders, so if you need to rearrange the channels to meet your needs you can have your own version of shaders distributed with your mod. That said, you probably don't have such needs.

Woah woah woah. Hold on there, buddy... before we suddenly get model releases that only work on specific shader sets. That is -not- intuitive for modders, especially new modders, to just grab a bunch of ships and plop them in their mod. Suddenly we'd have to match up shader sets or start rearranging texture channels to get things to be compatible with one another.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on October 05, 2016, 12:13:31 am
Yeah, custom shaders are at best used for debugging possible issues and testing new additions imho.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: m!m on October 05, 2016, 05:56:11 am
Custom shaders are only there for testing purposes and are not officially supported by the SCP. We frequently change the code that uses the shaders so it's very likely that a custom shader will be broken at some point.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: fightermedic on October 05, 2016, 06:35:58 am

Okay, I lied, I'll say something quick and mean anyway.
A lot of what you wrote in this thread is poo poo, and I think the fault lies with the user, ergo your maps. You are frustrated and are trying to blame it on code and stuff, looking stupid in the progress. Look, I understand. I've absolutely been there. The artifacting on normal maps actually ruined a whole day for me before I figured it out with the help of Dahblount. If there are artifacts on the reflect map, its user error. If there are artifacts on the normal maps, it's probably user error too. I found out that if you don't make the normals in a pretty specific way, it becomes ugly like in the first pic.


1) the problem are compression artifacts in areas with grey color in the reflection maps, because of violet or green spots - the roughness part of the map is fine, the artifacts are there too, but they almost never matter, since they are a lot less visible
2) if you compress the same map without the alpha channel, those artifacts are drastically less, because the information of one less chanel has to be considered
3) this problem also existed exactly in the same way with the old shine maps, we just have the chance to correct it now that we are switching rendering anyway

THIS is what i am talking about, and the reason is the setup of the map, and nothing else
(http://i1293.photobucket.com/albums/b590/lolaldanee/screen0018_zpshtkc6mdj.png~original)

it is ugly, and it's going to be there on every grey metal area on every ship, and a lot more visible than in the days of yore with the shine maps, as now almost ALL the color information for those areas comes from the map with the most artifacts - plain and simple  :shaking:

normal maps in the current PBR builds are perfectly fine result wise, the compression is just wasting a lot of memory without any reason to right now

i can not understand where all this furor is coming from, to fight against something that would lead to more efficient memory use, AND better results at the same time
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on October 05, 2016, 09:08:25 am
That? That's not part of the reflectance map actually, that's from the diffuse map. Take a close look at your reflectnace map again at a very high zoom and you will find that those aren't present. In fact, the two maps with the biggest artifact issues in your Leviathan release are the diffuse and normal map. The reflectance map actually looks ok.

i can not understand where all this furor is coming from, to fight against something that would lead to more efficient memory use, AND better results at the same time
Maybe it's because what you're suggesting goes against SCP coding conventions and your assumptions about the issue are wrong?
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: m!m on October 05, 2016, 09:15:07 am
[...] goes against SCP coding conventions [...]
We only guarantee backwards compatibility for official releases, not nightly builds. Since PBR is not present in an official release it can still be changed. We usually don't do it since it may invalidate the work of someone (which is the case here) but if there are good technical reasons for changing something then now is the best time to do so. However, I am not suggesting that we actually change the way PBR currently works since I don't know enough about it to make such a statement.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: The E on October 05, 2016, 09:27:32 am
I would be against such a change. In the end, if the issue is one of texture compression, artists are always free to distribute uncompressed textures (which is something I would encourage regardless to make sure that if someone wishes to alter a texture, they can start with the highest quality possible); The way I see it, it's the job of whoever assembles a modpack to make sure that whatever collection of assets is chosen stays within reasonable ressource use limits. It is the integrators who have to make the final decision on such issues, not the artists.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: fightermedic on October 05, 2016, 09:54:24 am
That? That's not part of the reflectance map actually, that's from the diffuse map. Take a close look at your reflectnace map again at a very high zoom and you will find that those aren't present. In fact, the two maps with the biggest artifact issues in your Leviathan release are the diffuse and normal map. The reflectance map actually looks ok.

i have tested it with an uncompressed diffuse, and it looks exactly the same, the compression errors are in the reflection map, that much at least is for sure
it wouldn't have made sense anyway if that had been the diffuse
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Spoon on October 05, 2016, 10:00:56 am
[...] goes against SCP coding conventions [...]
We only guarantee backwards compatibility for official releases, not nightly builds. Since PBR is not present in an official release it can still be changed. We usually don't do it since it may invalidate the work of someone (which is the case here) but if there are good technical reasons for changing something then now is the best time to do so. However, I am not suggesting that we actually change the way PBR currently works since I don't know enough about it to make such a statement.
PBR has been available for testing a long long time before it came to nightlies. If there was a good technical reason for changing something, it was before Swifty finalized most of the PRB code and put it into trunk. Now we've got several people who already made maps in the not unreasonable assumption that their efforts aren't suddenly annulled.

I would be against such a change. In the end, if the issue is one of texture compression, artists are always free to distribute uncompressed textures (which is something I would encourage regardless to make sure that if someone wishes to alter a texture, they can start with the highest quality possible); The way I see it, it's the job of whoever assembles a modpack to make sure that whatever collection of assets is chosen stays within reasonable ressource use limits. It is the integrators who have to make the final decision on such issues, not the artists.
Agreed.
DXT is going to have compression artifacts no matter what channel you swap stuff to. Its the nature of the beast.

Then again, my ships don't have these ugly artifacts to begin with. So hey ¯\_(ツ)_/¯
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Oddgrim on October 05, 2016, 12:56:06 pm
Those artifacts very defiantly looks like a conversion error happened when going from psd to dds.( In my own humble opinon) I would reinstall gxf drivers and plugins used, that would usally fix the issue for me when that happened to me. Hopefully the problem would go away then.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: DahBlount on October 05, 2016, 01:29:29 pm
I reconverted the base textures (but not the -misc textures) using 8888 unsigned, texture by texture, and found that the diffuse WAS the problem. I didn't even get to reconvert the reflect map.
(http://puu.sh/ryNi3/fb377f6387.png)

Comparison between changed base diffuse and unchanged misc diffuse:
(http://puu.sh/ryNrW/513491575b.png)

Additionally, GFX drivers do change the results of NVDXT and several other DDS compression programs out there.
Title: Re: Distribution of color information sub-optimal for PBR right now
Post by: Bryan See on October 22, 2016, 01:06:36 pm
fightermedic, you forgot to mention the use of heightmaps and parallax occlusion/relief shading (and possibly future displacement mapping) in the context of PBR improvements. How does this affect it?