[Feature request] Posterization effect

Talk about the mods you'd like to see in Daggerfall Unity. Give mod creators some ideas!
User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [Feature request] Posterization effect

Post by pango »

Thanks mate :D

I spent most of the day trying to optimize it further, but it's hard! Shaders really don't like branching (and do like unrolling), and the non-trivial k-d tree algorithm is all about decimating a search tree...

The best I managed so far is to increase k-d tree depth by one, going from 8 leaf functions to 16, and consequently to usually test 18 colors instead of 36. But ShaderCompiler takes ages, the Unity Editor complains about some timeout after 600s, the shader eventually compiles anyway and works perfectly. Not sure it's too safe though :shock:
All attempts to speed up compilation resulted in either no change (the optimizing compiler undoing all my modifications) or code that doesn't compile (if I try to handle my own stack, the compiler complains it can't unroll my main loop).
Unless somebody comes with a totally new approach I guess it'll stay as-is... in any case, I'm learning about shaders...
And now I understand why barely anybody tried such insane idea :D (only a few using the naive approach on shadertoy)
Attachments
DaggerfallRetroPalettization-byhand.shader.gz
(3.55 KiB) Downloaded 132 times
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Lokkrin Zhataros
Posts: 256
Joined: Thu Nov 21, 2019 9:27 pm

-

Post by Lokkrin Zhataros »

-
Last edited by Lokkrin Zhataros on Wed May 26, 2021 3:30 am, edited 2 times in total.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [Feature request] Posterization effect

Post by pango »

Thanks!

Palettization outputs RGB values taken from classic palette (from ART_PAL.COL to be precise).
So it has to be some color rendering difference after that step (darker/more saturated color is probably related to a higher gamma value).
(it could also be that plain DFU output - before post-processing - is brighter/more saturated than classic Daggerfall output, so palettization still picks color from classic palette, but has to pick more saturated colors. I think that's less likely though, but you can use Shift-F11 to dynamically switch post-processing on/off and check).
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Lokkrin Zhataros
Posts: 256
Joined: Thu Nov 21, 2019 9:27 pm

-

Post by Lokkrin Zhataros »

-
Last edited by Lokkrin Zhataros on Wed May 26, 2021 3:30 am, edited 2 times in total.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [Feature request] Posterization effect

Post by pango »

Are you using default DFU lighting? (All ambient lightings to 1.0, player item based lighting off) It seems DFU uses less ambient lighting in your examples
I don't have DFU at hand to experiment right now, but I should probably do that.

By the way there has been a related discussion before on reddit: https://www.reddit.com/r/daggerfallunit ... nights_of/ (on brightness alone)
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Lokkrin Zhataros
Posts: 256
Joined: Thu Nov 21, 2019 9:27 pm

-

Post by Lokkrin Zhataros »

-
Last edited by Lokkrin Zhataros on Wed May 26, 2021 3:30 am, edited 2 times in total.

User avatar
MasonFace
Posts: 543
Joined: Tue Nov 27, 2018 7:28 pm
Location: Tennessee, USA
Contact:

Re: [Feature request] Posterization effect

Post by MasonFace »

I wonder how linear vs gamma lighting will effect this.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [Feature request] Posterization effect

Post by pango »

We'll see, palettization does nothing about color balance, it just rounds each pixel's color to the closest one found in a palette, so balance may have to be fixed elsewhere.

On that topic, in 0.10.24 I've added 3 very dark grey values to the classic palette, that had no value between (0,0,0) and (15,15,15). That should help a bit with all low light condition, and as you mentioned they're a lot more of those in DFU than in classic. For example it should help at dawn and dusk times.
It makes the dungeons slightly less claustrophobic, but I think it's globally a good move:
darkness before.jpg
darkness before.jpg (133.76 KiB) Viewed 1784 times
darkness after.jpg
darkness after.jpg (134.15 KiB) Viewed 1784 times
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Lokkrin Zhataros
Posts: 256
Joined: Thu Nov 21, 2019 9:27 pm

-

Post by Lokkrin Zhataros »

-
Last edited by Lokkrin Zhataros on Wed May 26, 2021 3:28 am, edited 2 times in total.

Lokkrin Zhataros
Posts: 256
Joined: Thu Nov 21, 2019 9:27 pm

-

Post by Lokkrin Zhataros »

-
Last edited by Lokkrin Zhataros on Wed May 26, 2021 3:28 am, edited 2 times in total.

Post Reply