Korman:Soft Volumes

Revision as of 16:01, 13 July 2020 by Doobes (Talk | contribs) (Intersect)

Disambig gray.png

This is a tutorial page.Versions available: PyPRP; 3ds Max; Korman.
 

Typically, regions in Plasma have two settings: on or off -- either you are inside of it or outside of it. This would be referred to as a hard volume. Soft Volumes, on the other hand, allow a mechanism for artists to expose a transitional area in which the region is activating or deactivating. This could be roughly thought of as the way the volume of sound decreases as a listener moves away from its source. Soft Volumes accomplish this by assigning a numerical strength value to every point in space. Typically, inside the soft region the strength is 1.0 (or 100%) and fades at the boundary to 0.0 (or 0%). However, this is configurable by the artist.

Soft Volumes can be used in Korman to control sounds, runtime lights, and object visibility.

Simple Soft Volumes

Soft Volume Modifier

To create a simple soft volume in Korman, one simply needs to create a mesh and apply the Region > Soft Volume modifier. The default settings are for the region to be fully activated when inside and fully disabled when outside with no fade distance.

Figure 1

Typically in Blender, we deal with meshes whose faces are quadrilaterals. This is a good representation of traditional hard regions which tend to report when we are inside the exact bounds of said region. Soft Volumes, on the other hand, do not work on this principle. Rather, soft volumes are exported as a set of planes, one for each face on your Blender mesh. This is done so that the engine can evaluate the region's strength with respect to each plane. The result of the soft volume is the lowest strength value calculated by the engine.

Figure 2

For example, your region is the cube shape shown in Figure 1, and you're looking at it from the top down. The soft volume version of this region is depicted in the two dimensional diagram Figure 2. Notice that you can still observe the shape of the mesh. Now, assume that your avatar is located at the green "X". The strength of planes B, C, and D would be whatever you set Inside Strength as. In this case, it is 100%. However, because we cross the boundary of plane A, this is going to be our lowest value, and therefore the value of the region. Based on the settings for Distance, we know that this region will not allow any fading at all, so the result is the value of Outside Strength, or zero. If distance were nonzero we would observe a graduate fade from Inside Strength to Outside Strength as we moved over outside plane A, up to Distance.

NOTE: Soft Volume planes continue toward infinity. They do not stop as implied by Figure 2.

You could create an "inverted" region by swapping the values of Inside Strength and Outside Strength. This would mean the region is active when you are outside of it and inactive when inside of it. Alternatively, you can click the Invert checkbox in the modifier properties. However, this does not actually function the same way under the hood.

Complex Soft Volumes

As you can tell, Soft Volumes can be utilized to create intricate regions. Additionally, multiple Soft Volumes can be combined into a single Soft Volume to create more detailed effects. For example, you may want to have a single sound that fades out gradually on one side of a region but abruptly on the other side of the region. This can be done using the following techniques.

KorSoftVolumeModifierComplex.png

Complex Soft Volumes are made using nodes. To activate complex mode, click the node tree icon by Simple Soft Volume in the modifier panel. This will change the modifier to complex mode and will ask you for a node tree.

NOTE: Complex Soft Volumes should be attached to Empty objects. You will still need to have Simple Soft Volume modifiers attached to your region meshes, otherwise, Korman will not export any Soft Volume planes.

Switch to the Node Editor space and create a new Plasma node tree. Do not use a node tree with other logic nodes in it.

Soft Volume node tree output

The purpose of this node tree is to produce a "final" Soft Volume that can be referenced in lamps, sounds, and visibility regions by specifying the object you attached the Complex Soft Volume modifier to. To that end, we need to ensure that we add a Soft Volume > Soft Volume Output node to this tree so that Korman understands what you've created. This is similar to how Cycles material nodes work.

Invert

As mentioned above, when enabling Invert on the Simple Soft Volume modifier, Korman does not simply swap the Inside Strength and Outside Strength. Rather, Korman creates an inverted Soft Volume and adds the original Soft Volume as an input. Functionally, Soft Volume Invert takes the input Soft Volume's result and multiplies it by -1.0, effectively swapping the sign of the numerical result.

NOTE: Soft Volume Invert will only accept one Soft Volume as an input.
Soft Volume Invert node tree

To recreate the effect of the Invert checkbox using nodes, you will need to first add a reference to your Simple Soft Volume to the node tree by adding a Soft Volume > Soft Region node. This node allows you to specify any object that has a Soft Volume modifier attached to it.

Specifying a complex node-based Soft Volume using this node has undefined results. HERE BE DRAGONS -- errr -- just don't do it, okay?

Then, you connect the Soft Region node to a new Soft Volume > Soft Volume Invert node. You then connect that node to the output. Any light, sound, or visibility region you point to this Soft Volume will obey the rules set forth in this sample node tree.

You may also connect complex Soft Volumes as an input to the Soft Volume Invert node, allowing you to, for example, play one sound outside and another inside the soft volume. This is used extensively in the Neighborhood age to silence lake ambience while inside the classroom and egg room.

Union

Soft Volume Union node tree
Two cube Soft Volumes from the top

Let's assume you have two Soft Volumes and want for a sound to be heard while inside either region. You can accomplish this using the Soft Volume > Soft Volume Union node. This node evaluates all input Soft Volumes and returns the largest result of all connected input volumes. Let's examine how this is accomplished.

Figure 4: Cuboid Soft Volume planes

Recall that Soft Volumes are exported as infinite planes, not meshes. This situation is shown in Figure 4. There are three Soft Volumes shown in this figure. The tan Simple Soft Volume, the teal Simple Soft Volume, and the Union Soft Volume of tan and teal. Pink arrows have been added to each plane to indicate the inside of the volume. Note that while planes E/G and F/H are indeed coplanar, they are exported and evaluated separately because they are members of separate Soft Volumes.

Let us assume that we are standing at point Z. First, we evaluate the tan Soft Volume. So, we only consider planes A, B, E, and F. Point Y is outside of all of the aforementioned planes, and, given that we are experimenting with an on/off type of Soft Volume, we can conclude that the result of the tan Soft Volume is the value of its Outside Strength, zero. Next, we evaluate the teal Soft Volume. So we are only considering planes C, D, G, and H. As we are inside each plane, the engine returns the value of Inside Strength, or 1.0 for this Soft Volume. The Union Soft Volume then takes the highest of the input results (0.0 and 1.0) and returns that as its result. In short, at point Z the Soft Volume is fully active.


Region Activation per Point

  • X: Fully active (inside tan Soft Volume)
  • Y: Inactive (outside tan and teal Soft Volumes)
  • Z: Fully active (inside teal Soft Volume)

Intersect

Soft Volume Intersect node tree

Using the Soft Volume > Soft Volume Intersect node, you can combine many simple or complex Soft Volumes into a single result. This result is the smallest of all of the connected input volumes.

Strengths on Complex Soft Volumes

Applying strengths to Complex Soft Volumes

Inside Strength and Outside Strength can be set on Complex Soft Volumes by utilizing the Soft Volume > Soft Volume Properties node. Remember that Simple Soft Volume Inside Strength and Outside Strength should be specified on the Soft Volume modifier. The values specified in this node are applied to the result of the Complex Soft Volume just as in the Simple Soft Volume.

outside + result * (inside - outside)