Author Topic: CoronaColorCorrect slows down rendering 2-3 times (OR much more if you want it)  (Read 42627 times)

2019-07-10, 22:55:41

Benjamin_F

  • Active Users
  • **
  • Posts: 50
    • View Profile
Hello,

short story: I wanted to start to implement OSL maps into our shading pipeline to live a long, relaxed life, but I did some very simple tests. After I noticed massive slowdowns with even just an OSL color node, I started to test different corona maps too, to find out if this problem only connected to OSL or not.
It's seems Corona maps can heavily affect render times, even if they are basically do nothing at all.

How I did the tests:
- almost all of the maps was "turned off", no default parameters are changed, I expected that they should act as a pass-thru node or just output a single color. Connected to the diffuse slot.
- with bitmaps
- with disable shading(render only masks) and CShading Source(RAW)Color: diffuse, bitmap sampling turned off, with nearest-neighbor and others in the bitmap sampling(because of the OSL text. loader)
- with environment maps: single bacgkround color(no map), single coronaColor node, coronaBitmapHDRI in a very simple leftover of an interior scene
- in the diffuse, glossiness and reflection color slots of CoronaMtl

Recreate the problem:

Sample scenes are attached(2019), materials and nodes are in SME. Everything is super simple.

You can test to render the scene with only connect a CoronaColor to the diffuse and compare it with adding a CoronaColorCorrect after the color, don't change the defaults(does nothing in this state), render time is doubled.
I tested it with many possible combinations, with many nodes like CoronaColor+someNode, connected to diffuse or env.

- When I used a CoronaColor(white)+CoronaColorCorrect in the env. slot and in the diffuse, rendertime is tripled.
- If there is a Corona ColorCorrect only in the environment map, no less slowdown.
- It affects the diffuse and reflection color but not the glossy or bump channel

Attached some test renders, I hope the filenames are understandable.
- coronaCC_speedDecrease.zip - a very simple leftover of an interior scene, model is shit
- corna_OSL_speed_v01_01.zip - disabled shading, CShading_SourceColor, you need to select the plane before render(blowup auto select region is on)

Basically almost every corona map affects render time more or less, I think much more than it could be considered acceptable. Did some simple tests in Arnold, no render time increases like these.
CoronaColorCorrect is the worst one of all the corona maps. It can slowdown rendering 2-3 times. General OSL nodes 2 times slowdown, TextureLoader is the slowest OSL.

Ohh, by the way, multiplied CoronaCC train is multiplying slowdown, however OSL nodes are not, it seems they are only triggering something sensitive stuff. Check the last picture, fun.
I was able to do 30 x longer render times with a few CoronaColorCorrect nodes doing nothing. :)

I pretty  hope you will fix this in a hotfix together with the OSL slowdowns.

Please let me know if something is unclear or I wrote some bullshit in this f****g too long post.
Corona 4.1, Max 2019.3(2020 too), multiple dualXeon machines, win10


ps.: I found this old topic about OSL trace() call, I guess you know it's fixed in 2020(OSL APT for 3rd party renderer dev include OSL trace() function call). https://forum.corona-renderer.com/index.php?topic=20128.msg125617#msg125617
« Last Edit: 2019-07-10, 22:59:20 by Benjamin_F »

2019-07-10, 23:32:55
Reply #1

pokoy

  • Active Users
  • **
  • Posts: 1635
    • View Profile
As far as I know, it's expected that any mix of Max shading context maps and OSL will be slower than OSL or Max legacy only. IIRC this was inevitable and not on Corona's side. You may not notice this with Arnold unless you check 'use legacy 3dsmax maps' in its options (it'll use Arnold's own OSL implementation when it's unchecked).

But to see that a CoronaCC will blow up like this is stunning... this shouldn't happen, good catch. I was just starting to use it more and more.
I did some test myself 2 years ago to when testing OSL and found that Corona didn't slow down that much with many maps added... might be that it's been introduced somewhere between v2 and v4.

Thanks for posting this, I hope the developers will look into it, performance regressions need to be fixed.

2019-07-11, 00:22:32
Reply #2

Benjamin_F

  • Active Users
  • **
  • Posts: 50
    • View Profile
Yeah, I also know about the mixing shading context thing. But I think it's just partly true here. You break the OSL optimization chain if you insert a non OSL node between them, into an input slot of an OSL node.
If your non OSL nodes are at the and of the chain it's okay. But I'm really a beginner with OSL yet.

You can see in the render message window, it will show this error message:
"A non OSL shader (Map #3 (CoronaColorCorrect)) was connected to the input 'Input_map' of an OSL shader (Map #5 (OSL: Tweak (color))).
This can lead to suboptimal performance, and will be less portable. Try to use only OSL shaders."

Checked the legacy thing in Arnold, but the documentation talks about the legacy built in Max maps, not the new OSL implementation. Only mentioning viewport - render differences.
I guess, it's written before the 2019.3 update. Zap Andersson demoing this in his video. Arnold doc: https://docs.arnoldrenderer.com/display/A5AF3DSUG/Shaders

Loosing 10M rays/s from 31M, one third of the "computation power" only because one OSL color value node is connected to the diffuse, doesn't seems to be a realistic scenario in any way.

I also wanted to check this in Vray, but I only have it under 2018 and there is no OSL.

I badly want to use OSL in production.

The best, ideal thing would be just simply forget about most of the corona map nodes, and rewrite them in OSL, voila you can use them in any DCC which supports OSL.
Users could write them so the Corona team wouldn't need to waste it's time to do these.

Of course I know many things, even UI controls are not supported officially by osl. And C4D is not support it, if I'm correct.
« Last Edit: 2019-07-11, 00:47:24 by Benjamin_F »

2019-07-11, 01:07:13
Reply #3

pokoy

  • Active Users
  • **
  • Posts: 1635
    • View Profile
For Arnold - when enabling the legacy checkbox, Arnold will render OSL through max shading context (where it also supports other Max maps), that will be probably slower and will not support all OSL features (raycasting for example).
When the checkbox is disabled, Arnold uses its own OSL implementation.
You'll probably see a performance difference between the two modes.

The color node in a diffuse channel - is this with Corona? Does performance drop that much? Compared to a CoronaColor map or something else?

2019-07-11, 09:48:36
Reply #4

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 8964
  • Turning coffee to features since 2009
    • View Profile
Found the problem, expect massive ColorCorrect speedup
Rendering is magic.
Private scene uploader | How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2019-07-11, 10:21:14
Reply #5

rowmanns

  • Corona Team
  • Active Users
  • ****
  • Posts: 1364
    • View Profile
(Internal ID=373015519)
Please read this before reporting bugs:
How to report issues to us!

2019-07-11, 11:41:07
Reply #6

miladeah

  • Users
  • *
  • Posts: 1
    • View Profile
Found the problem, expect massive ColorCorrect speedup
It seems this problem is not only limited to corona colorcorrect. What about the other nodes which are substantially affecting the render speed? CoronaTonemapcontrol, Corona Triplanar, Corona mix,etc...? throw a couple of coronamix in there and you will lose 20% performance.

2019-07-11, 14:42:25
Reply #7

Benjamin_F

  • Active Users
  • **
  • Posts: 50
    • View Profile
Pokoy, I did some tests with Arnold with the same circumstances like in Corona. There are some differences(more than I thought), but not much between legacy off or on.
These are not average numbers, only 1 render.

Simple color in the standardSurface : 113.691s, 100%
OSL color value in the diffuse slot, Legacy off: 118.862s, 104.54%
OSL color value in the diffuse slot, Legacy on: 119.832s, 105.40%
OSL 6 nodes, Legacy on: 123.533s, 108.65%
OSL 6 nodes, Legacy ff: 123.444s, 108.57%

...
The color node in a diffuse channel - is this with Corona? Does performance drop that much? Compared to a CoronaColor map or something else?
I' not sure what you mean, but I compared to a single CoronaColor connected to CoronaMtl diffuse. Than I just connected 1 or more nodes between the CoronaColor and the material, with the default settings.
Is it an answer to your question?

Thanks Ondra, good news.
Did you guys checked other nodes?  E.g. 6*UVW randomizer 18% drop, 6*CoronaMultiMap 25% drop, 6*CoronaMix 30% drop. (default settings)

Would you mind share some thoughts about the OSL slowdown problem?

2019-07-24, 13:54:37
Reply #8

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 8964
  • Turning coffee to features since 2009
    • View Profile
optimization done, now the scene renders almost 2x faster
Rendering is magic.
Private scene uploader | How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2019-07-30, 20:11:23
Reply #9

Benjamin_F

  • Active Users
  • **
  • Posts: 50
    • View Profile
Can we expect a hotfix for version 4? October is far away.