Transparency for background persons

Guides Transparency for background persons

transparency_for_background_persons-banner.png


How to fake more people in a scene
and other stuff besides people

People without more person atoms

As you know, person atoms are very demanding in resources, and even if you have insane hardware more than 3 persons in a scene will leave you with shit FPS quickly.
Having more people in a scene can improve scene immersion if the theme is suitable, especially if all you need is filler persons in the background. To do this there's fortunately some methods to achieve this, having a reduced impact on FPS at scale.

The CUA (CustomUnityAsset) method

This is a great option as you continue to have a three-dimensional asset and is animatable (baked in animation). You already can find many around, mainly in the Assets category, as well as plugins like Crowd Generator, and with some playing around with Unity and tools like Mixamo for the animation it can be relatively easy to make your own custom persons.

Unsurprisingly there are limitations when it comes to turning VaM people into a CUA. While you can export the person as a OBJ and reuse the textures, you can't do that for hair (actually, you can in a way) or clothing. This limits what you can make as a CUA, as well as you need to learn how to do all those parts to eventually make your own. Not saying you shouldn't, it's very useful to learn to do this, but if you have simple needs on a scene this may be too much work for the benefit.

Using perspective to make 2D images fit a 3D environment


@PhantasyStarfan already made a great guide on how to fake depth using Perspective rules, check it out:

🕵️‍♂️ 🔎 Currently taking a look at Eosin's Video Renderer for 3D VR180, VR360 and Flat 2D & Audio + BVH Animation Recorder plugin and testing what it can offer on this topic. If you use it and can share ideas it would be greatly appreciated.
Thanks for the suggestion, @ethanfel

What this guide offers

This guide will focus on the perspective method to set up a scalable workflow for generating transparent background photos of person atoms.


What this means is that with the tools provided, you can:
  1. take multiple-angled photos of a posed person
  2. quickly remove the background
  3. import into a scene a set of ImageTransparentPanels to show the photos you made
  4. tweak them to blend in the scene's environment and POV
POV in perspective: the photos above are limited to a angle range based on the point of view (POV) of the camera. As you can expect, the depth perception exploited here with a 2D person photo doesn't work with a 360º, more like up to 30-45º away the focus point. As such, this method is best employed with possession or in a limited movement location.

⚠️What I say here may not be correct or pass good methods for doing whatever is being said, it's my current state of knowledge and experience in the subject(s) mixed with personal bias. If you want to improve and correct this guide, please let me know in the Discussion area of the guide. ⚠️


VAR in Downloads

This guide has a VAR you can use to help you take photos and apply them on a scene. It's a single VAR that includes a scene: Background person photo creator; and a subscene: Background person photo subscene.

Background person photo creator
This scene has a posed person with 4 cameras - front, left, right, back - to take photos of the person in the pose you want to use for a scene or more. The 4 cameras are optional, they're there to give more photo options per pose. The photos are taken with the Supershot plugin in the UI atom.
The Timeline plugin is used to set a pose, it currently includes two or three. Change them as you wish or include more poses to the sequence.

In a nutshell, change or add all the poses you want to use, load a appearance preset, and take photos. After you have all the photos you want, move over to the script further below to remove the background (or do it some other way your prefer).

The file from SuperShot should be a PNG because JPG doesn't have Alpha channels.
Background person photo creator model
Background person photo subscene
This subscene is to be loaded in the scene for which you made the photos above, after removing the background. It includes 4 ImageTransparentPanel atoms positioned at equal distances from and facing the subscene icon, and scaled to 5 to give more or less the expected size of the person at that distance.

Load the photo you want per image panel that is suitable for your scene's environment. Use the subscene icon as the planned place for the POV to be in the scene (see spoiler above "POV in perspective") and make any adjustments that you see fit. See further below for tips on adjustments.
Background person photo subscene model


Tips on photo taking and in scene placement

Cameras facing the wrong angle
In the scene provided, the four cameras (and lights) are positioned at equal distance and facing the person's root control. They're set to hidden (H) in case you can't find them. They are parent-linked to the person's root to always keep the same distance and rotation to give more consistent results.
When you load a pose, sometimes the cameras are not facing the angle you'd like them to have. For those moments my suggestion is to detach root control (Control % Physics 1 tab) to rotate the setup and keep the person in that pose.

Keep the person centered when posing (hip)
Try to keep the center of the person in the same spot when taking photos. It's much easier later in the scene you're adding the photos in to adjust the image panel and retain a better depth if the person is shown distributed in the centre rather than the corners. In most poses the hip area is the central point that I refer.

Render queue for occultation
This number in the Materials tab tells in what order should the image be shown compared to others. For example, you have two photos closeby and you want to say that one photo should always be shown on top of the other. This will make the one on top appear closer (occultation).

Scaling/moving
To make a photo look closer/further, you can reduce the scale or move it closer/further. Depending on the scenario you're in, one may look more realistic than the other. See also the render queue tip above.

And pointing this out again, read PhantasyStarfan's guide linked above.


Removing the black background in photos

A simple and fast way to remove the black background of a photo is to tell a image editor to do a "Color to Alpha". Taking Gimp's documentation explanation:
The Color to Alpha command makes transparent all pixels of the active layer that have a selected color. An Alpha channel is created.
This is not the only or best method, far from it, but it is a easy and fast method that can provide very decent results for the simple needs here of adding persons in the background.

The black background in the Photo Creator scene is not a requirement, you can use any color and later with Color to Alpha be able to adjust it to also affect similar colors. I choose to use pure black because:

  • it's the default one used in VaM
  • it's not so common to see pure black used in persons or clothes, almost pure black yes
  • black (not pure black) pixels not made transparent blend better with a scene's environment, especially low light ones, compared to other colors I've tried
I'll mention again, there will be artifacts, but we're using these as background persons, not our focus of attention or close proximity.
Depending on the environment you're using find if the ImageTransparentPanels or the Emissive kind works better.


Some examples applied in a scene

bgpersons1.jpg
bgpersons2.jpg

The lighting is exagerated to see the applied images better in these shots. The scene's POV is around that central restraint chair, but even moved a bit off from it the perspective results still look good to mimic a 3D person in there. A dark environment like this also helps masking any blackish pixels from the background, or that were removed from the body without noticing anything.


Python script to do a batch job of all photos

Now that you took many photos are you going to do them all one by one with Gimp's Color to Alpha (or others)? Well, that's up to you, but I if you want to have dozens of them in a few seconds I made a Python script you can use to do that for you.

To use the script you need:
What the script below will do is:
  1. find any PNG file in the folder it's running from, including subfolders
  2. use ImageMagick to turn any pure black (#000000) in the PNG to a transparent pixel
  3. create a new file called alpha_PNGfilename with the color replacement
Takes less than a second to do each file and so you can go nuts and do tons of photos.

How to use the script
  1. make sure you have installed Python and ImageMagick
  2. make a new text file and copy the script below, name it whatever you want and change the extension to .py
  3. move the script to a new folder and move/copy your screenshots to that folder
    • you can have the photos in subfolders, the script will include the PNGs in them
  4. open the command prompt/powershell/... on this folder and run python .\ScriptName.py (change the script name accordingly)
  5. the command prompt will show "Color to alpha conversion completed" when it's finished

Python:
import subprocess
from pathlib import Path

# Color to alpha conversion
# turns a specific color in a png file to a alpha channel, then exports that new image
## you need ImageMagick installed to run the conversion command
### https://imagemagick.org/index.php


images = Path.cwd()

print("Converting all png files")
for file in images.rglob("*.png"):
    folder = str(file.parent)
    png = file.name
    newpng = "alpha_" + png
    print("Converting " + file.name)
    conversion = str('convert "' + folder + '\\' + png + '" -transparent "#000000" "' + folder + '\\' + newpng + '"')
    subprocess.run(conversion, shell=True, check=True)
print("Color to alpha conversion completed")

Expanding the ImageMagick command: you can add more options to the IM command, such as opacity and transparency, to get even better (or worse) results. I left it out as I'm happy with the simpler command.


Not just for photos, videos too

Why not make a transparent GIF to have some movement in the background?
Animation.gif


For the GIF on the right I used ScreenToGif (thanks for the tip @Matt_ ), and in the export process you can select a color for transparency.
It's the same thing as the photos, use a ImageTransparentPanel (emissive or not) and same perspective rules. Finally you can make that whorehouse you always dreamed of doing.

Transparency is not something you can do with any codec, bear than in mind. In this case I made a GIF, but if you want video you will need to find a suitable codec and filter options to remove the background.


Model used is Aida (atani) using built-in clothes
Should have used WindControl to get the hair flowing a bit, damn it, it would have looked better



Credits for assets, screenshots and tips

AcidBubbles - Timeline
AshAuryn - poses
hazmhox - VAMStory
klphgz - poses
MacGruber - Chair, LogicBricks, Supershot
Nayris - bucket
Syrinxo - person
TGC - environment
Vecterror - person
Vonic - person
Wikipedia :)
ZRSX - cum splatters
And everyone else in Discord that gave me great tips about this
Author
atani
Downloads
810
Views
4,241
Dependencies
4
Packages
1
Total Size
0.09 MB
Version
22/10/2023
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from atani

Click the links below to support the other creators whose content was used to make this resource!

Latest reviews

Nice clear explanation, and extra points for the idea in the first place.
atani
atani
ah ah, nice touch with the use of "clear" 😉
Extra points for you too 🙂
Upvote 0
Back
Top Bottom