alelievr / Mixture

Mixture is a powerful node-based tool crafted in unity to generate all kinds of textures in realtime
https://trello.com/b/2JiH2Vsp/mixture
MIT License
1.18k stars 124 forks source link

External Output sRGB Write Fix / sRGB Preview Fixes #38

Closed peeweek closed 2 years ago

peeweek commented 2 years ago

(Also added the sRGB toggle to the UIElements schema but it seems it is not used yet)

peeweek commented 2 years ago

I'm changing a bit how the external output file type works. Now there's an option to select either PNG or EXR (independently of the node precision). This allows to save the data from a FP16 directly to PNG and prevent that issue happening in LDR because of the SRGB Conversion. Color Conversion was happening in 8 bit as the node was output in that precision. Instead, the conversion can happen with default precision (FP16) without loss in the darkest tones.

The node has now an option for Texture2d dimension that allows selecting PNG or EXR as file type. Also, changing this type invalidates the update button.

image

peeweek commented 2 years ago

Some weirdness is that EncodeToEXR data can be fed into a PNG, caused me a headache, but finally fixed.

@alelievr : currently the PR is in an acceptable state regarding exported data and previews, however here's a summary of what could be improved:

1) need to find a way to manual color (reverse-)conversion happening at export (because we do a Linear>SRGB conversion in finalOutputMaterial and texture importer also does its own), right now the state of the PR is functional but the code is messy. 2) preview weirdness (low precision), could not find what is causing that.

stuff to do / questions:

peeweek commented 2 years ago

Finally I have cleaned up the behavior in external output : no more conversion in finalOutputMaterial, and no more inverse-conversion in C#. Now, the conversion is only handled by the texture importer.

I have added a sRGB Preview System:

Unity_ezn2krOFJ1

Preview can be implemented on any MixtureNode:

I've implemented specific behavior in 3 nodes: