Corona Renderer Forum

General Category => Bug Reporting => Topic started by: ferrarod on 2018-04-10, 20:17:35

Title: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-04-10, 20:17:35
Hoping the more technical-minded here can help me out with a really strange issue I'm having. If this isn't corona related then maybe I'll take it straight to Autodesk, haha. I haven't cross-tested in V-Ray.

ANYHOW

While doing product render tests, I've noticed that using an image for the mask of a layered or mix material gives an incorrect stroke appearance or halo of sorts around the text. I've tested this every way I know how - Using a white/black jpg, tiff, png, inverting the white/black jpg, tiff, png, testing all the different filtering methods, blur settings, as well as gamma changes, corona bitmap, max standard bitmap, corona layered material and standard mix material. Each time, same result.

HERE'S THE KICKER!

When its a white background (bottle) and black text, the sharpness reads perfectly, just as in the real photo. Both of those examples are attached here...

Anyone have any thoughts as to what this could be, or has anyone run into a similar issue in the past??

Any help is greatly appreciated.

Thanks!
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-10, 20:53:41
Hard to say without seeing an example input image. Thoughts

- Any Blur used in the Filtering section of the Bitmap?
- You mention this happening used as a mask for layer / mix materials, what happens if you just use it directly on a single material e.g. as Diffuse (and other inputs)? That would show if this is something to do with masking, or just something to do with the way the Bitmap nodes are handling it
- Any blur or sharpen or other post effects used in the VFB?
- Is the bitmap of a high enough resolution?
- Any Denoising used?
- Anything changed from the defaults in the Image Filter section of the System tab of the Render Settings?


Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-04-10, 21:24:05
Thanks Tom!

I'll go one by one:

Can't share the original input image unfortunately, but rest assure it's as basic as it gets. White background with crisp black text from Illustrator.

- I tried every blur setting down to .01
- I can definitely do a test with the text as the single material...I'll upload results
- No post effects, blur or sharpen
- The bitmap is 4k and from a print EPS (and again, works fine when it's black text on white bottle)
- No denoising
- No change to default image filter settings

Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-10, 22:14:56
TY for the info!

On tests here, I can't see any difference between using it as a mask or using it directly as a Diffuse material (not doing reflection or anything, just black and white color) - for me, I am not seeing a problem, the only thing showing is the anti-aliasing expected in the image (which can be affected by Exposure and Highlight Compress values as to just how strong that anti-aliasing shows up). I also couldn't see any difference with white on black or black on white (I had both in the same image, a 4K PNG, attaching that here).



Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-04-10, 23:26:46
Interesting!

A few more tests here. It seems changing the image filter works in favor a bit, however does introduce unwanted aliasing on some edges of the product itself. The tests done are standard (Tent 2px), Sharper (Tent  1.5px) and Sharpest (Blackman-Harris 1px). Blackman absolutely worked the best for text, but introduced the most jagged aliasing on other geo. NOW what's more interesting about all this is if I undo the "invert" on the alpha mask to bring it back to its original white background, black text, the text is the most sharp and delicate even while using the standard Tent @ 2px.......

The final test is the bottle with a corona bitmap as the base material, and not a layered alpha. This still seems to keep the text a bit "bulky"

All those attached...
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-11, 14:29:30
Can the image file being used not be sent via the private uploader? (or even the entire scene, since it would be private and only we would see it for testing purposes)
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-11, 14:46:46
While testing whether the "Invert" option had any bearing on the issue, it gave me an interesting way to do an A/B comparison. White text on black is more likely to "grow" depending mostly on Exposure but also partly on Highlight Compress, while black text on white does not (or maybe black on white is more likely to shrink... not sure!)

Here are three images with different values were used in Exposure and Highlight Compress. Note that these were done with pure white which has is too high in albedo, but correcting for that did not seem to change that this takes place.

Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-11, 14:49:14
PS inverting isn't the cause, as in the lower half of my image where there is reversed text on background colors, it is still the white text on black that "grows"
EDIT - attaching an image, with an even more extreme Highlight compress value change too; still the white text that "grows" even though it is now the "Not inverted" version
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-11, 14:55:40
And as a last note, doesn't matter whether the bitmap is used as Diffuse, or as a mask on a Layered. Whether anything is wrong here I can't say, but it seems to come down to the Exposure and Highlight compress as the cause (without seeing the scene itself to confirm).
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-04-11, 16:36:38
Wow thanks for all the replies and tests! I think I see what you're getting at, and I had the same experience - Whether the diffuse slot is a white text on black bitmap OR it's a layered material with an alpha (inverted or not), the result is the same.

The highlight compression is an interesting note - not sure if there's a definitive reason, but my highlight compression typically around 5-10 depending on the scene, so this isn't floating around the 0-1-2's like you tested. I'd assume the "growing" effect of the white on black gets worse the lower the compression value.

I can privately send you a pared down scene to test, for sure. New to the forums though so let me know the best way to do that.

Thanks again for all the help.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: TomG on 2018-04-11, 16:46:03
If you want to share the scene, can use our private uploader - https://corona-renderer.com/upload (https://corona-renderer.com/upload)

Stripped down to just the parts that show the issue is definitely preferred if you can, makes it easier to work with, smaller to upload, and means you are sharing less :)
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-04-11, 17:12:33
1523459517_CORONA-BLACK-WHITE-TESTING-001.zip

Thanks! Uploaded now. Looking forward to hearing back...
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-05-15, 21:40:30
Hi - just wondering if there's been any update on this behind the scenes?

Thanks!
Dan
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2018-05-16, 16:51:59
Sorry for the delay. We will eventually get to it. It's just a super busy period right now.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-05-16, 16:53:33
No worries! Just curious

Thanks
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2018-05-24, 14:00:12
Try this string option (https://coronarenderer.freshdesk.com/support/solutions/articles/5000518663-string-options):
bool shading.enableAa = false

It will completely prevent this effect, and will also disable AA for you.
So I guess it means that this is how AA works in Corona, and this is how it is supposed to work. I do not think it makes sense to turn this thread into a report in our tracking system, so I will just leave it here, and hopefully someone from our dev team will check it at some point, and provide technical explanation, since this is what we are all interested in. :)

I am also curious if this effect also happens in other renderers, and if so, then how it looks compared with Corona.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-05-24, 19:08:34
Thanks maru for your help. This does seem like a workaround as disabling AA won't be great for many other edges and details in the image. Hopefully a technical explanation will come along too! I don't have a Vray license unfortunately so I can't test in another platform, but it would be interesting.

Thanks again!
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2018-05-25, 11:05:14
Thanks maru for your help. This does seem like a workaround as disabling AA won't be great for many other edges and details in the image.
This was by no means meant to be a solution or even workaround. It's just an explanation which part of the rendering process affects this.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2018-05-25, 18:27:22
Gotcha - thank you either way!
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2019-03-04, 12:10:43
So the final answer is:
GAMMA!

You can see the edges of the letters as tiny black-to-white or white-to-black gradients, right?
And we all know what gamma 2,2 does to gradients, right?

Here are some example images to confirm that.
2.2 images were saved "just like that" from 3ds Max with gamma 2.2 - that's what you get when rendering with 3ds Max and Corona by default.
1.0 images were saved with gamma overridden from 2.2 to 1.0, which as you can see results in a linear gradient. So the tiny gradients in the letters are linear too.

Check out these comparisons:
Gamma 1.0 - https://corona-renderer.com/comparer/8uaHMw
Gamma 2.2 - https://corona-renderer.com/comparer/hEoxV6

As you can clearly see, with 2.2 the white-on-black text is thicker.
As you can also clearly see, with 1.0 the letters are the same. Some monitor profiles or optical illusions may be at play here, but if you take a look at the thin lines in "h" or "w", you will definitely see it.

Extra: why did disabling anti-aliasing completely produce similar results? Because then we basically removed the tiny gradients on the edges of the letters.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2019-03-04, 17:07:33
YOU are a GENIUS!

1000  thank you's for taking the time to follow up on this. This will be a huge help in quite a number of projects moving forward.

Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2019-03-04, 17:27:15
YOU are a GENIUS!

1000  thank you's for taking the time to follow up on this. This will be a huge help in quite a number of projects moving forward.

First of all, the credit goes to our dev team. They provided an explanation, and I just showed some examples to make it easier to understand. :)
Secondly, I am not sure if there is any "workaround" to this which would not destroy the image by applying incorrect gamma...

That's basically how rendering works, and it will happen in other renderers as well (already confirmed with V-Ray).
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: ferrarod on 2019-03-04, 17:31:38
Haha totally - go dev team!

Yes, the gamma change is a problem, but at least we know what was happening. And who knows...maybe there is some workaround in the future for it.
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: romullus on 2019-03-04, 19:20:55
Secondly, I am not sure if there is any "workaround" to this which would not destroy the image by applying incorrect gamma...

How about saving linearly to 32 bit image and then converting to 8 bits in photoshop? Would that work?
Title: Re: Black and White Masking Issue - Stroked/Halo Edges
Post by: maru on 2019-03-06, 19:30:00
Secondly, I am not sure if there is any "workaround" to this which would not destroy the image by applying incorrect gamma...

How about saving linearly to 32 bit image and then converting to 8 bits in photoshop? Would that work?

But you would either end up with gamma-1-contrasty image, or you would get the same issue (if you would convert to gamma 2.2).