How to emulate realistic lighting with Illuminate 2D Shape?

Hi.
I am trying to light 2D shapes using a rendered 3d model as a reference.

Reference
Simple sphere lighted with a single lamp.

Colored 2D shape
Circle colorized with G’MIC Colorize Interactive filter

Shading
Shading generated with G’MIC Illuminate 2D Shape filter

Shaded
The shading layer is layered on top of the colored shape with Blend Mode:Hard Light and Opacity 85%.

Comparison
Top Image is the reference image.
Bottom Image is the generated one.

All the configurations are done inside the G’MIC filter and I didn’t use any other editing options within GIMP.

My biggest gripe is I couldn’t match the shadows.
The reference image has a sharp shadow.
I fiddled with the filter’s settings under Illumination section but couldn’t generate anything similar to the reference one.
Also the quality of the rendered image is much higher to the generated one.
Increasing smoothness introduces a dark shadow on the rims.
Specular highlight seems off but I think I can manage that.

I am testing all these as I am planning to do lighting for 2d objects used for backgrounds/environments in animations with the help of this filter.

I was inspired by @bazza’s post and @dubi’s tests.

How can I match the lighting almost perfectly within G’MIC?

There is no way you can achieve your goal in a display-referred space and the issues you are having are typical of non-linearly encoded RGB spaces (dark fringes around edges, posterization in gradients, non-realistic light fall-off). I don’t even need to ask you, the picture speaks for itself: it’s obvious that you are working in some kind of sRGB space with gamma 2.2-2.4.

You need to do the lighting over a 32 bits float file encoded in a linear RGB space (no OETF/gamma nonsense). I don’t know if GIMP and GMIC can take that, but that’s how you do it.

See, for the past year I have kept repeating to people that image processing in non-linear spaces was doomed, and many thought I exaggerated and display-referred was just fine. Well, that’s what you get when you push ill-managed image software beyond the point of “I’m just shooting the dog and the kids, no biggy”.

Slack on the pixel management pipeline, and expect this kind of result.

1 Like

Hey, thank you for pointing that out.

See, for the past year I have kept repeating to people that image processing in non-linear spaces was doomed, and many thought I exaggerated and display-referred was just fine.

Can you recommend anything to learn more about this issue?

You need to do the lighting over a 32 bits float file encoded in a linear RGB space (no OETF/gamma nonsense). I don’t know if GIMP and GMIC can take that, but that’s how you do it.

And thank you for suggesting this. :slight_smile:

The best that attain although has some glitch

2 Likes

I don’t think the illumination command was meant to be realistic. It was a first implementation with an artistic bent. I am sure that it could be improved. Not sure of the level of interest though.

G’MIC is a general purpose tool. It has the building blocks to build whatever you wish. Complaining about nonlinear or display-referred space is moot for this reason. But it does mean you need a firm grasp of the concepts and a bit of scripting ability to know when to adapt the code for your purposes.

2 Likes

No. But it gives much more than what is expected of her.

Please show your work in steps.

1 Like

1 Like

Yes, I am thankful for the code to exist. Not perfect but if it exists it can be improved. :wink:

2 Likes

Hey, thank you for trying this out.
You have matched the shadows almost perfectly. :slight_smile:
And thank you for sharing the values.
One question.
The fringes around the edges can be smoothed by increasing Smoothness value, but it get rids of other necessary details within the shape. Any workarounds to this?

And the posterization effects that we can notice in the mid-tones here are due to GIMP itself or the way the Illuminate 2D Shape filter works?

@afre
I am happy with the tool, I just wish I had better grasp over it like @bazza here. :slight_smile:

Yes. This disappears as the resolution increases.

1 Like

Thank you. :slightly_smiling_face:

1 Like

Just fore the completeness:

  1. Gmic is independent from Gimp. You can use it standalone, as Krita or Gimp plugin.
  2. AFAIK Gmic has no concept of color spaces, it just looks at the numbers. But @David_Tschumperle should know more.
  3. Gimp can handle 32 bits floats and linear light. Have a look at: Image -> Precision -> … in Gimp.
2 Likes

The path of least BS will be the doc :

2 Likes

@bazza in what colour space did you work ?

I use the space by defect in gimp.
I open image of @nrcarla

It was not a problem of depth of colour. Only of parameter to generate the shadow.

They solved when increasing the resolution of the filter

Which is… sRGB ?

gimp says RGB but has channel alpha.

I have examined the code: it is not sRGB; please stop with the condescension. Potential weak points might be the colour selection tool and the raster editor interfacing with the plugin.

2 Likes

G’MIC has no concept of Colour Space. We can try to give the illusion of it, but all in all, it doesn’t. For this reason, I do find myself trying to my g’mic code work with as many “colour space” possible, and still doing different ways about it. Right now, I’m thinking of multimultiply/multidivide by separating channels and multiplying per channel where number is given by $* where * is the variable placement.

1 Like