[Java] Multiply and screen colors

[Last update: 10/06/2022]

Cubism SDK for Java is currently in alpha version, and the specifications may change in the beta or official version.

By applying Multiply Color and Screen Color to the model, tints can be changed in real time.
Multiply and screen colors set on Cubism Editor are applied by using Cubism Java Framework from Cubism 4.2 or later, without any additional coding.
For details on setting the Multiply Color and Screen Color in the Cubism Editor, please refer to “Multiply Color/Screen Color” in the Editor manual.
Also, by coding as needed, it is possible to manipulate Multiply Color and Screen Color from the SDK and perform the following operations.

  • Apply Multiply Color and Screen Color interactively.
  • Apply Multiply Color and Screen Color that have not been set on the Cubism Editor.
  • Disable Multiply Color and Screen Color set on Cubism Editor.

The following is an explanation of the procedure.

 

Procedures

The process is as follows.

  • Override flag setting for Multiply Color and Screen Color
  • Multiply Color and Screen Color settings
  • Model drawing

 

Override flag setting for Multiply Color and Screen Color

First, set the overwrite flag for Multiply Color and Screen Color to true. The default is false.

public void setOverwriteFlagForModelMultiplyColors(boolean value) and public voidsetOverwriteFlagForModelScreenColors(boolean value) are defined in the CubismModel class of the Framework.
Cubism SDK for Java (alpha version) sample project defines LAppModel class with CubismModel as base class to manipulate models, and model in the above code is an instance of LAppModel class.
getModel() is used as an intermediary to call methods of the CubismModel class from the LAppModel class.

 

Multiply Color and Screen Color settings

Define Multiply Color and Screen Color and set them to the model.
The code below shows the set values for setting the Multiply Color to red and the Screen Color to green for all Drawables.
RGBA can be used for the setting color.

 

Before applying Multiply Color and Screen Color

 

After applying red to Multiply Color and green to Screen Color

 

By looping through the model's DrawableCount, the multiply and screen colors are processed for all Drawables in every frame.

Tips

In this case, the same Multiply Color and Screen Color are set for all Drawables, but it is possible to set different Multiply Color and Screen Color for each Drawable index.
The argument i is the index of the Drawable.

To disable the Multiply Color and Screen Color set on the Cubism Editor, set 0 for the Multiply Color and 1 for the Screen Color. If set, the respective default value will be used.

 

 

Model Drawing

Cubism SDK for Java (alpha version) Cubism JavaFramework internal rendering process will draw the model including multiply and screen colors by calling draw() function of the model, which is originally done in the sample project of Cubism SDK for Java.

 

Other Related Functions

Get overwrite flag for Multiply Color and Screen Color

If set to true, the color information set in the SDK is given priority; if set to false, the color information of the model is given priority.

 

You can also get the individual overwrite flags for each Drawable.

 

 

Multiply Color and Screen Color settings

CubismRenderer.CubismTextureColor as an argument above, but there is also a method that can set RGBA directly. (Input value 0.0–1.0)

 

 

Obtain Multiply Color and Screen Color

Get the Multiply Color and Screen Color of each Drawable with the CubismTextureColor type.

The argument is the index of Drawable.

 

Internal processing of Cubism Java Framework (alpha version)

This is the Framework's internal process for representing Multiply Color and Screen Color.
The process is as follows.

  1. Get model multiply and screen colors from Cubism Core Java
  2. Determine the acquired Multiply Color and Screen Color by the overwrite flag.
  3. Set the acquired multiply and screen colors to the shader program
  4. Add multiply and screen colors to fragment shaders when calculating texture color

Tips

Get the model's multiply and screen colors from Cubism Core Java in RGBA, but A (transparency) is not set in Cubism Editor.
Therefore, it is not used for multiply and screen color calculations.

 

Get model multiply and screen colors from Cubism Core Java

Use the API of the CubismModel class in Cubism Core Java to obtain an array containing all Drawables of multiply and screen colors from the model.
The specified index of the array is accessed and its value is returned.

 

In Core Java, when a moc3 file is loaded, information on all Drawables is retrieved and held in a member array.
To set the multiply and screen colors on the SDK side, setOverwriteFlagForModelMultiplyColors() and setOverwriteFlagForScreenColors() to true, then setMultiplyColor() and setScreenColor(), then setMultiplyColor() and setScreenColor() overwrite the member arrays.
To set multiply and screen colors for a specific Drawable, setOverwriteFlagForDrawableMultiplyColors() and setOverwriteFlagForDrawableScreenColors() to true and perform the and perform the same operation.

Tips

All subsequent Drawable colors will be set to the overwritten color information when the above process is performed.
If you want to use the model's original color settings again, you must add a separate process.

© 2010 - 2022 Live2D Inc.