Author Topic: Black and White Masking Issue - Stroked/Halo Edges  (Read 1799 times)

2018-04-10, 20:17:35

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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!
« Last Edit: 2018-04-10, 20:22:23 by ferrarod »

2018-04-10, 20:53:41
Reply #1

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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?



2018-04-10, 21:24:05
Reply #2

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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


2018-04-10, 22:14:56
Reply #3

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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).




2018-04-10, 23:26:46
Reply #4

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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...

2018-04-11, 14:29:30
Reply #5

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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)

2018-04-11, 14:46:46
Reply #6

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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.


2018-04-11, 14:49:14
Reply #7

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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

2018-04-11, 14:55:40
Reply #8

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
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).

2018-04-11, 16:36:38
Reply #9

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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.

2018-04-11, 16:46:03
Reply #10

TomG

  • Corona Team
  • Active Users
  • ****
  • Posts: 2449
    • View Profile
If you want to share the scene, can use our private uploader - 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 :)

2018-04-11, 17:12:33
Reply #11

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
1523459517_CORONA-BLACK-WHITE-TESTING-001.zip

Thanks! Uploaded now. Looking forward to hearing back...

2018-05-15, 21:40:30
Reply #12

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
Hi - just wondering if there's been any update on this behind the scenes?

Thanks!
Dan

2018-05-16, 16:51:59
Reply #13

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile

2018-05-16, 16:53:33
Reply #14

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
No worries! Just curious

Thanks

2018-05-24, 14:00:12
Reply #15

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile
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.

2018-05-24, 19:08:34
Reply #16

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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!

2018-05-25, 11:05:14
Reply #17

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile
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.

2018-05-25, 18:27:22
Reply #18

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
Gotcha - thank you either way!

2019-03-04, 12:10:43
Reply #19

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile
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.

2019-03-04, 17:07:33
Reply #20

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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.


2019-03-04, 17:27:15
Reply #21

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile
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).

2019-03-04, 17:31:38
Reply #22

ferrarod

  • Active Users
  • **
  • Posts: 12
    • View Profile
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.

2019-03-04, 19:20:55
Reply #23

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 5709
  • Let's move this topic, shall we?
    • View Profile
    • My Models
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?
I'm not Corona Team member. Everything i say, is my personal opinion only.

2019-03-06, 19:30:00
Reply #24

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 9031
  • Marcin
    • View Profile
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).