Update
Dissolver is back! Now with emissive mask support and more features.
What is Dissolver?
Dissolver is a module that allows you to create DissolverObjects that dissolve a MeshPart’s texture with customizable settings such as dissolve time, texture resolution, FPS, and more. This allows the creation of various interesting visual effects.
The effect shown above is available in the demo place below:
Dissolver Demo Place.rbxl (98.5 KB)
How to Use
First of all, put the module somewhere that the client can access (such as ReplicatedStorage) and require the module on the client. It does NOT run on the server!
Then, create a TextureGroup using Dissolver.NewTextureGroup(). These are the textures that the dissolved meshes will use.
local TextureGroup = Dissolver.NewTextureGroup(
ColorMap, -- Must be either a ContentID or a Color3
MetalnessMapID, -- Optional ContentID
NormalMapID, -- Optional ContentID
RoughnessMapID, -- Optional ContentID
EmissiveMaskID -- Optional ContentID
)
Or alternatively, if you are lazy like me, you can use Dissolver.NewTextureGroupFromMesh() to make one for you.
local TextureGroup = Dissolver.NewTextureGroupFromMesh(
MeshPart -- The MeshPart that the TextureGroup will be based on
)
Afterwards, create a DissolverSetting using Dissolver.NewSetting().
local Dissolver = require(path.to.module)
local Setting = Dissolver.NewSetting(
1, -- The time it takes to dissolve.
256, -- The texture resolution. Anything higher than 512 is not recommended.
20, -- Noise zoom out. The higher the number, the more zoomed out the noise is.
Color3.fromRGB(255, 255, 255), -- Edge color.
0.05, -- Size of the colored edge. Ranges from 0 to 1.
true -- Whether you want the edge to glow or not. Drastically increases memory usage.
)
After that, create a DissolverObject using Dissolver.NewDissolver() and pass the TextureGroup, Settings, and any initial MeshParts you want to add to it. You can always add more MeshParts to it using Dissolver:AddMeshPart() later.
local DissolverObject = Dissolver.NewDissolver(
TextureGroup, -- The textures that the dissolver will use.
Setting, -- The DissolverSetting you made.
InitialMeshParts -- An optional array of MeshParts that will be added to the DissolverObject.
)
It should take a couple of seconds to compute the textures. After thats done, experiment with the various methods available on the DissolverObject.
DissolverObject.DissolveFinished:Connect(function()
print("Dissolve finished!")
end)
DissolverObject:Dissolve(1)
And you’re done! There are also other methods you can use such as DissolverObject:SetTime() and DissolverObject:StopDissolve(). To see the full list of features, see the documentation below.
Is it Memory Performant?
ABSOLUTELY NOT!
When the textures are first created, they are cached so that you don’t need to create the same texture twice. But this also means that they will be sitting around and eating up your memory. So be careful when you are computing a lot of high-res textures. Clean up unused textures here and there so you don’t blow up Lil’ Timmy’s phone.
IMPORTANT NOTES
You are required to enable the “EditableImage support for SurfaceApperance maps” and the “Emissive Maps” Beta Features.
When you no longer need a DissolverObject, use DissolverObject:Destroy() to remove the it and free up some memory. If you also want to get rid of a cached texture to free up memory, you can use Dissolver.RemoveFromCache() to remove the cached textures.
If you want to pre-compute the textures so that you can use them later, you can use Dissolver.PrecomputeImages() and pass the same arguments you passed with Dissolver.NewDissolver() (Except for the array of MeshParts).
You should not make multiple active DissolverObjects on one MeshPart. There should be at most one DissolverObject active on a MeshPart at any given time.
Limitations
- In order to maximize performance, textures need to be first computed and then cached. When there are multiple different textures and settings, it can result in VERY high memory usage.
- If the original texture resolution is higher than the specified resolution, the texture will get downscaled to match the specified resolution.
- The UV of the mesh will affect how the dissolved texture will look. Some MeshParts might not look good with this.
- There might be features that are missing that you would like to add. Feel free to edit the code as much as you want because I am unlikely to work on this anymore.
- Includes every other EditableImage limitations such as the memory budget.
Documentation
Dissolver Global Settings
These are settings found within the Dissolver module itself.
PrintMessages: boolean
Prints the progress of texture computation. Should be used for debugging only.
Default: false
FPS: number
The FPS that Dissolver will run at. Higher values means a smoother dissolve but more textures will need to be computed. Anything above 60 is discourged.
NOTE: This value should only be an integer. Unintended behavior may occur otherwise.
Default: 30
InitialEmissiveStrength: number
The EmissiveStrength of the SurfaceApperance when they are initially created.
Default: 5
NumberOfWorkers: number
How many Actors will be created for parallelism.
Default: 64
PixelsPerWorker: number
How many pixels each Actor will process at once
Default: 4096
Dissolver Library Functions
function Dissolver.NewSetting(
Time: number?, Default: 1
Resolution: number?, Default: 256
NoiseZoomOut: number?, Default: 20
EdgeColor: Color3?, Default: Color3.fromRGB(255, 255, 255)
EdgeSize: number? Default: 0.05
EdgeGlowEnabled: boolean? Default: true
) -> DissolverSetting
Creates a new DissolverSetting from the given values. Leaving arguments nil will use the default values.
For the sake of performance and memory, a resolution of above 512 is strongly discouraged.
Time (optional): How long the whole dissolve progress will take, in seconds.
Resolution (optional): The resolution of the texture, in pixels.
NoiseZoomOut (optional): Higher values result in a more zoomed-out noise.
EdgeColor (optional): The color of the colored edge.
EdgeSize (optional): The size of the colored edge. Ranges from 0 to 1.
EdgeGlowEnabled (optional): Whether the colored edge will glow. If false, then no emissive masks for the edge will be generated, saving memory.
function Dissolver.NewTextureGroup(
ColorMap: string | Color3,
MetalnessMap: string?,
NormalMap: string?,
RoughnessMap: string?,
EmissiveMask: string?
) -> TextureGroup
Creates a new TextureGroup to be used for computing textures.
ColorMap: The ColorMap ContentID to be used. If it is instead a Color3, then the color map will be a solid color.
MetalnessMap (optional): The MetalnessMap ContentID.
NormalMap (optional): The NormalMap ContentID.
RoughnessMap (optional): The RoughnessMap ContentID.
EmissiveMask (optional): The EmissiveMask ContentID.
function Dissolver.NewTextureGroupFromMesh(
MeshPart: MeshPart
) -> TextureGroup
Creates a new TextureGroup based on the given MeshPart.
If the MeshPart has a SurfaceAppearance, then all of its maps will be used. Otherwise, if the MeshPart’s TextureID is not empty, then it will be used as the ColorMap. Else, its Color will be used.
MeshPart: The MeshPart to get the TextureGroup from.
function Dissolver.ComputeSingleImage(
Setting: DissolverSetting,
Threshold: number,
Source: string | Color3,
EmissiveSource: string?
) -> (buffer, buffer?)
Returns a single texture and optionally an emissive mask using the specified Setting, Threshold and Source. Useful for creating custom dissolvers.
NOTE: This function can yield.
Setting: A DissolverSetting object.
Threshold: Threshold ranging from 0 (no dissolve) to 1 (fully dissolved).
Source: The source of the computed texture. Can either be a ContentID or Color3.
EmissiveSource (optional): The ContentID of the emissive mask. This is ignored if EdgeGlowEnabled is false.
function Dissolver.ComputeImages(
Setting: DissolverSetting,
Source: string | Color3,
EmissiveSource: string?
) -> ({buffer}, {buffer}?)
Not to be confused with Dissolver.PrecomputeImages().
Returns an array of textures (and optionally emissive masks) ordered from least dissolved to most dissolved using the specified Setting and Source. Useful for creating custom dissolvers
NOTE: This function will yield for up to several seconds.
Setting: A DissolverSetting object.
Source: The source of the computed texture. Can either be an ContentID or Color3.
EmissiveSource (optional): The ContentID of the emissive mask. This is ignored if EdgeGlowEnabled is false.
function Dissolver.PrecomputeImages(
TextureGroup: TextureGroup,
Setting: DissolverSetting
) -> TextureMaps
Not to be confused with Dissolver.ComputeImages().
Computes the textures from the given TextureGroup and Setting and caches them for later use. This function does nothing if the textures are already cached.
NOTE: Computing textures will yield for up to several seconds.
Setting: A DissolverSetting object.
TextureGroup: The textures used for the computed texture.
function Dissolver.RemoveFromCache(
TextureGroup: TextureGroup,
Setting: DissolverSetting
) -> nil
Removes and destroys the textures associated with the given TextureGroup and Setting from the cache, freeing memory.
TextureGroup: The TextureGroup used for computing the textures.
Setting: The DissolverSetting used for computing the textures.
function Dissolver.NewDissolver(
TextureGroup: TextureGroup,
Setting: DissolverSetting,
InitialMeshParts: {MeshPart}?
) -> DissolverObject
Creates a new DissolverObject.
If the source texture is not already cached, they will be automatically computed and cached using Dissolver.PrecomputeImages(); yielding for several seconds.
NOTE: You should not make multiple active DissolverObjects on one MeshPart. There should be at most one DissolverObject active on a MeshPart at any given time.
TextureGroup: The TextureGroup used for the textures.
Setting: The DissolverSetting used for the textures.
InitialMeshParts (optional): The initial array of MeshParts to be added to this DissolverObject.
DissolverObject Properties
[READ ONLY] TextureMaps: TextureMaps
A reference to the table of textures used by this DissolverObject.
[READ ONLY] Time: number
The current dissolve progress in the range of 0 to the maximum time specified in the settings.
[READ ONLY] EmissiveStrength: number
The strength of the emissive glow of the MeshParts. If you wish to modify this value, use DissolverObject:SetEmissiveStrength()
[READ ONLY] TextureGroup: TextureGroup
A reference to the TextureGroup used by this DissolverObject.
[READ ONLY] Setting: DissolverSetting
A reference to the settings used by this DissolverObject.
DissolverObject Events
DissolveFinished: RBXScriptSignal
Fires when a dissolve process finishes, is interrupted by starting another dissolve process, or stopped using DissolverObject:StopDissolve(). Does not fire if this object is destroyed using DissolverObject:Destroy().
DissolverObject Methods
function DissolverObject:AddMeshPart(
MeshPart: MeshPart
) -> nil
Adds a MeshPart to the DissolverObject, creating a new SurfaceAppearance, and removing the old SurfaceAppearance if there was one.
MeshPart: The MeshPart to be added.
function DissolverObject:RemoveMeshPart(
MeshPart: MeshPart
) -> nil
Removes a MeshPart from the DissolverObject, destroying the new SurfaceAppearance, and restoring the old SurfaceAppearance if there was one.
MeshPart: The MeshPart to be removed.
function DissolverObject:SetEmissiveStrength(
Strength: number
) -> nil
Sets and updates the emissive strength of all MeshParts.
Strength: The new emissive strength.
function DissolverObject:SetTrueTime(
TrueTime: number
) -> nil
Sets the current dissolve progress using true time.
TrueTime: The time to be set in seconds. Should be in the range from 0 to the maximum time specified in the settings.
function DissolverObject:SetTime(
Time: number
) -> nil
Sets the current dissolve progress using normalized time.
Time: The time to be set in the range from 0 to 1.
function DissolverObject:TrueTimeDissolve(
TargetTrueTime: number
) -> nil
Dissolves the MeshPart texture until the target true time is reached. If a dissolve is already in progress, it will be canceled and the most recent dissolve request will run instead.
This method does not yield.
TargetTrueTime: The target time to be set in seconds. Should be in the range from 0 to the maximum time specified in the settings.
function DissolverObject:Dissolve(
TargetTime: number
) -> nil
Dissolves the MeshPart texture until the target time is reached. If a dissolve is already in progress, it will be canceled and the most recent dissolve request will run instead.
This method does not yield.
TargetTime: The target time to be set in the range from 0 to 1.
function DissolverObject:StopDissolve() -> nil
Stops the current dissolve process.
function DissolverObject:Destroy() -> nil
Disconnects all events, stops the current dissolve process, destroys the created EditableImage, and removes any MeshParts from the Dissolver.
This method can be used to destroy the DissolverObject once it is not needed.
Get Dissolver Here
https://create.roblox.com/store/asset/115268111251030/Dissolver