NormalNX texture resizing
Moderator: Raze Developers
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: NormalNX texture resizing
I am more talking about the color distortion, it's a lot less severe in Blood than in the other games. Even with 64 levels it still needs to work with 256 colors.
-
- Posts: 1349
- Joined: Tue Nov 05, 2019 6:48 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
Re: NormalNX texture resizing
I could be horribly wrong but I think such a method is possible.markanini wrote:At least for the former it should be possible to implement in a more future proof way if you only care about the general look of colors and not about all weird quirks of aging technology.
I seem to recall that what Fresh Supply did was not the traditional palette emulation but something else, and they looked up the colors in a lookup table to generate the original aesthetic. Edward explained this in short once, but don't quote me on that, my memory is quite fuzzy on this topic and I am mainly talking from memories.
-
- Posts: 210
- Joined: Sat Jan 18, 2020 6:10 am
Re: NormalNX texture resizing
It's functionally the same. Palette emulation and color look up tables could be considered interchangeable.
People do similar things today all the time in the form or film-like emulation for video content.
What's missing is creating a look up table in a high precision 3D space, where you would sample the reference colors while allowing for a smooth ramping between values.
People do similar things today all the time in the form or film-like emulation for video content.
What's missing is creating a look up table in a high precision 3D space, where you would sample the reference colors while allowing for a smooth ramping between values.
This makes modding for build games frustrating, so many roadblocks to adding higher quality resources. Audio is also very limited.Graf Zahl wrote: Yeah, surely you can downconvert them to the palette again, but the real advantage of doing an upscale tends to get lost if you lose all those color gradients again due to lack of available colors and the result tends to lool like total garbage, especially if you use the internal real-time scalers.
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: NormalNX texture resizing
Strictly speaking "Palette 'emulation'" is a misnomer. It doesn't 'emulate' the palette - it actually uses it, so 'palette lookup mode' would be technically more precise. "Color table" and "Palette" are synonyms for the same thing anyway.
Regarding high precision lookups, surely they could be done, but the space requirements would be prohibitive. Polymer supports a limited subset of such lookups to allow using the palette translation effects on true color images, i.e. doing precisely this, but only for the first shade level. This results in 69 PNGs, each roughly 200kb on disk and 3 MB in memory. each.
To now do proper shading you need to do the same a second time, with 32 lookups per base palette, i.e. 96 files of the same type again. You do the math where this will end up memory-wise if it was done for all games. Blood would be particularly problematic because it does not have 3 base palettes but 7, and 64 shade levels instead of 32 for Duke. Shadow Warrior uses a lot of different palette translations so its memory requirements would also be huge.
Regarding high precision lookups, surely they could be done, but the space requirements would be prohibitive. Polymer supports a limited subset of such lookups to allow using the palette translation effects on true color images, i.e. doing precisely this, but only for the first shade level. This results in 69 PNGs, each roughly 200kb on disk and 3 MB in memory. each.
To now do proper shading you need to do the same a second time, with 32 lookups per base palette, i.e. 96 files of the same type again. You do the math where this will end up memory-wise if it was done for all games. Blood would be particularly problematic because it does not have 3 base palettes but 7, and 64 shade levels instead of 32 for Duke. Shadow Warrior uses a lot of different palette translations so its memory requirements would also be huge.
-
- Posts: 210
- Joined: Sat Jan 18, 2020 6:10 am
Re: NormalNX texture resizing
Rendering on run-time doesn't sound great either, I certainly wouldn't like staring at a loading screen telling me to wait for color tables to compute.
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: NormalNX texture resizing
You can't compute these things, they need to be hand created. Otherwise you'd just end up with a natural fade to black as the hardware renderer already does.
The only reason why palette emulation even exists is that these tables were apparently hand-'optimized'.
The only reason why palette emulation even exists is that these tables were apparently hand-'optimized'.
-
- Posts: 210
- Joined: Sat Jan 18, 2020 6:10 am
Re: NormalNX texture resizing
What you could put into the engine is someone creative re-imagining of how the color tables would look in a higher precision space. But I disagree with this on principle. It's better suited as a separate community project(and pre-calculated).
-
- Posts: 1349
- Joined: Tue Nov 05, 2019 6:48 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
Re: NormalNX texture resizing
So, all things considered, with all its drawbacks it looks like the current method is still the best.
I didn't know doing it another way would actually be so taxing.
I didn't know doing it another way would actually be so taxing.
-
- Posts: 309
- Joined: Tue Apr 10, 2018 8:14 am
Re: NormalNX texture resizing
I think the first question that needs to be asked is, are we dealing with 8-bit or true color textures? If the former then what markanini is suggesting would be sufficient. I would imagine an algorithm parsing each color in the shade table, and for every section of identical entries interpolate using the neighbouring different shades.
But as Graf says, for true color it gets trickier. Could something be done where you pick the closest color in the palette, subtract that from the texture color, shade the difference linearly then add that back to the color taken from the shade table?
I gotta see later if I can make some mockup of the result...
But as Graf says, for true color it gets trickier. Could something be done where you pick the closest color in the palette, subtract that from the texture color, shade the difference linearly then add that back to the color taken from the shade table?
I gotta see later if I can make some mockup of the result...
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: NormalNX texture resizing
Not in real time in a shader. But no matter what you do, unless you do a true color lookup you can very much forget about any kind of texture filtering because it obliterates the palette entry so you'd be forced to do a true color lookup. That means no mipmapping, no anisotropic filtering and basically no aliasing reduction.
Regarding the creation of a lookup by interpolating the shade table, keep in mind that the lower shade levels suffer from severe color crushing, a good example for this would be the walls of the grave at the start of Blood's E1M1 or the total loss of color precision in some darker places in Doom. You cannot reconstruct a working true color setup from that, unless doing it manually.
Regarding the creation of a lookup by interpolating the shade table, keep in mind that the lower shade levels suffer from severe color crushing, a good example for this would be the walls of the grave at the start of Blood's E1M1 or the total loss of color precision in some darker places in Doom. You cannot reconstruct a working true color setup from that, unless doing it manually.
-
- Posts: 1349
- Joined: Tue Nov 05, 2019 6:48 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
Re: NormalNX texture resizing
Then I guess the old school palette emulation is here to stay the way it is, as a second class citizen.
I'm totally fine with that, for reasons mentioned previously. But in the case of aliasing, at least its effects in the distance can be more-or-less countered with MSAA, and with higher resolutions. Granted that means slightly more stress on the hardware for results that will obviously not be the exact same, but it's a good compromise IMO.
In 1080p, palette emulation looks really good with with 4x MSAA or more.
I'm totally fine with that, for reasons mentioned previously. But in the case of aliasing, at least its effects in the distance can be more-or-less countered with MSAA, and with higher resolutions. Granted that means slightly more stress on the hardware for results that will obviously not be the exact same, but it's a good compromise IMO.
In 1080p, palette emulation looks really good with with 4x MSAA or more.
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: NormalNX texture resizing
sinisterseed wrote: In 1080p, palette emulation looks really good with with 4x MSAA or more.
I cannot agree. MSAA doesn't do anything inside a polygon, only around its edges, I do not see any difference with it on or off. In both case there's strong aliasing in 1080p.
The only way I can reduce it to a tolerable level is with mipmapping enabled.
-
- Posts: 1349
- Joined: Tue Nov 05, 2019 6:48 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
Re: NormalNX texture resizing
Yes, and that was my main issue there.Graf Zahl wrote:I cannot agree. MSAA doesn't do anything inside a polygon, only around its edges, I do not see any difference with it on or off. In both case there's strong aliasing in 1080p.sinisterseed wrote: In 1080p, palette emulation looks really good with with 4x MSAA or more.
The only way I can reduce it to a tolerable level is with mipmapping enabled.
The image is significantly less jagged in the distance with MSAA even in paletted mode, and the edges of things are smoother as well.
-
- Posts: 18
- Joined: Tue Aug 13, 2019 12:04 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: NormalNX texture resizing
Works for textures now with the new render, still has to be set via console variables each start...
But it's great to see Duke Nukem 3D looking fantastic while only using 100W of GPU power (previously I was supersampling so it was 250W and it looked worse).
Also thought "am I missing out on having proper colors with palette emulation", but each time I turn it on... . Either terrible banding (without interpolation) or weird color shifting. I have no idea why eDuke32 developers thought that was worth giving up texture filtering for.
But it's great to see Duke Nukem 3D looking fantastic while only using 100W of GPU power (previously I was supersampling so it was 250W and it looked worse).
Also thought "am I missing out on having proper colors with palette emulation", but each time I turn it on... . Either terrible banding (without interpolation) or weird color shifting. I have no idea why eDuke32 developers thought that was worth giving up texture filtering for.
-
- Posts: 210
- Joined: Sat Jan 18, 2020 6:10 am
Re: NormalNX texture resizing
I typed gl_texture_hqresizemode 6, gl_texture_hqresizemulti 4. into the console. Looks great, no more interference patterns.