tv_SaveDisplay with layer(s) in "multiply" blending mode Topic is solved

A forum dedicated to George scripting questions
Post Reply
User avatar
aAntin
Posts: 29
Joined: 29 Aug 2007, 09:40
Location: France
Contact:

tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by aAntin »

Hello there!
Long time, no see! :)

I've already read the George wiki doc and I can't find how to get out of my issue:
I'm trying to use tv_SaveDisplay but layers in blending mode other than "color" don't show up in the exported image files... ("multiply" mode layer don't show up at all.)

Code: Select all

tv_SaveMode JPG 100
// tv_AlphaSaveMode "NoPreMultiply" // PreMultiply|NoPreMultiply|NoAlpha|AlphaOnly
tv_SaveDisplay "/myPath/filename.jpg"
I've also played with tv_AlphaSaveMode but doesn't seem to help me a lot...

Is there anything I'm missing?

Thank you!

PS: Same issue with tv_SaveImage
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by Svengali »

In your example, you've commented out the line:
// tv_AlphaSaveMode "NoPremultiply"
which of course isn't going to execute.

As for tv_SaveDisplay you might try preceding that with the line:
tv_Display ALL

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by NathanOtano »

Salut Antoine :)

I tried with svengali's scripts here, same problem : http://forum.tvpaint.com/viewtopic.php? ... ave#p94059
I never noticed that problem before however it seems that while merging multiple layers with no background and layer modes, i get the same result than when I save the file (all layers with a blending mode are erased if there is no background)

One solution could be to automatically add a background with your script and delete it afterward with tv_undo for exemple. Do you have a before/after image to see what's going on?
Spoiler : my before/after merging my layers with blending modes, i lose everything outside of the plain circle. Exporting works however when i export with a white layer underneath :
screen.png
screen.png (68.05 KiB) Viewed 2314 times
screen.jpg
screen.jpg (91.1 KiB) Viewed 2314 times
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
aAntin
Posts: 29
Joined: 29 Aug 2007, 09:40
Location: France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by aAntin »

Hi Sven,

Of course the documented line will not been executed, I might be absent-minded but not this time! ;) I commented this line in my post just to show you where I tested it. When I said I've been playing with tv_AlphaSaveMode, I meant with and without documenting the line, and also with other alpha save modes to see how it works.

Following your suggestion, I've tried the line tv_Display ALL, but with the same unexpected result. (See below the images I get)

Hi Nathan, :)
Thanks for the link! I've just tested the palette and I have the same issue indeed. But you actually gave me a hint: I've tried turning my BG layer opacity to 100% and the anim layer actually shows up! Unfortunately, I would like my BG layer to have a low opacity. I wish we could use a purist solution, otherwise I'll go with your suggestion (which unfortunately will be time consuming).

Here is how my scene inside TVPaint looks with both the anim and the background layers with a 100 % opacity (anim layer in "multiply" blending mode):
Spoiler : :
tvp_100.jpg
tvp_100.jpg (80.66 KiB) Viewed 2305 times
Here is how I work inside TVPaint (anim layer: 100 %; BG layer: 25%) and also how I actually would like my export to look like:
Spoiler : :
tvp_25.jpg
tvp_25.jpg (66.03 KiB) Viewed 2305 times
And here is what I get after exporting with tv_SaveDisplay:
Spoiler : :
export_25.jpg
export_25.jpg (62.75 KiB) Viewed 2305 times
Thanks guys and have a nice weekend!
Antoine
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by Svengali »

Maybe the MergeAllLayers button - Option Two will do what you want?

Creates a new, merged, top layer (which combines all the other layers no matter what blending modes they use.)

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by NathanOtano »

Thinking about it, seems normal to me that saving a display with transparent pixels on the background doesn't work because there is nothing for the pixels to blend with if you have an unusual blending mode. When exporting with the tvpaint UI you have a "background option" that creates a background to help with blending modes, so you have to do the same with your script.

Just wrote this script for you. It should work for what you want and be lightning fast, indeed it creates a white BG layer and deletes it afterward. I put some hints in it about how it works and ways to tweak it a little, hope it helps.

Code: Select all

	//Freezes Display
tv_lockdisplay "quiet"

	//Freezes undo stack
tv_undoopenstack

	//Creates BG layer
tv_layercreate "BG_tmp"
BGlayerID = Result
tv_layerset BGlayerID
tv_layeranim

	//Saves Current Tool, Apen Color and Paper Active State
tv_getActiveShape
ActiveTool = result
tv_getApen
ApenColor = result
tv_paperinfo
parse result a a a a a a a a a a a a a a a a a PaperActiveState a

	//Fills layer with white
tv_paper active 0                                //that line is to avoid getting paper texture while filling layer
tv_SetApen 255 255 255                           //you can change the bg color here
tv_rectfill 0 0 99999 99999						 //you lose your active tool here, this command sets tool to rectangle to fill layer

	//Moves layer to BG
LayerCount = 0
DO
	tv_layergetID LayerCount
	LayerID=result
	LayerCount = LayerCount +1
UNTIL CMP(LayerID,"none")==1

BGPos = Layercount - 1
tv_layermove BGPos

	//Updates undo stack, !!! without this line the saved display image doesn't save the pixels created by the "tv_rectfill" command !!!
tv_updateundo 

	//Saves Display to selected path in Jpeg 80 format
tv_savemode "JPG" "80"
tv_reqfile                                                                              
tv_savedisplay result                              //if you want a specific path just put it here instead of "result", and delete the "tv_reqfile" line above to avoid the popup window

	//Sets back Tool, APenColor and Paper Active State
tv_setActiveShape ActiveTool
tv_setApen ApenColor
tv_paper active PaperActiveState

	//Undoes Script Actions on Layers
tv_undoclosestack
tv_undo

	//Unfreezes Display
tv_unlockdisplay
Nathan :)
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
aAntin
Posts: 29
Joined: 29 Aug 2007, 09:40
Location: France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by aAntin »

Hi guys,

Thank you for your replies!

Sven, your "merge all, blended" action does what I expected indeed! :) I wish I could dive into your code to understand how you managed it.

Nathan, thanks for the tips and for sharing this code! :) Still, there is something I have trouble to understand: why does blending mode use background's alpha even if pixel's alpha of blended layer is 255? Beside, about setting the BG color line in your code, I would suggest womething like the following to be more portable:

Code: Select all

tv_Background
PARSE result mode rgb
tv_SetApen rgb
Anyway, I'll definitely play with it.

Thanks, guys! :)
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by NathanOtano »

Yes using tv_background seems a good idea :)
You can go to tvpaint's folder to open scripts that are integrated in a panel you installed, just go in Users/yoursessionname/appdata/roaming/tvpaintversion/configfolder/george to study svengali's scripts

For your question I guess that multiply mode has some maths going on using also alpha, so if it blends to a 50% opaque pixel you have a 50% opaque layer if in multiply mode. When it uses a 100% opaque background you don't notice anything but when it is transparent, as in our case, and you lower the opacity of your own background layer the layer with a blending mode uses your background layer opacity instead of using 50% your bg and 50% your background color. Does it make sense?
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
aAntin
Posts: 29
Joined: 29 Aug 2007, 09:40
Location: France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by aAntin »

It does.
Thank you, Nathan!
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_SaveDisplay with layer(s) in "multiply" blending mode

Post by NathanOtano »

No pb :)
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
Post Reply