Dynamic Palette System Documentation
Introduction
The Dynamic Palette System is a powerful tool for Unreal Engine that enables developers to switch between different collections of Material Parameter Collections (MPC) directly in the editor or smoothly interpolate their values during gameplay. This system is perfect for creating dynamic visual changes in your game environment without the need for complex material setups or extensive coding.
With the Dynamic Palette System, you can easily create day/night cycles, weather effects, dynamic color transitions, or quick scene appearance changes. The system provides an intuitive interface for managing multiple palette configurations and seamlessly transitioning between them.
Core Concepts
The Dynamic Palette System is built around the concept of Material Parameter Collection Palettes. Each palette represents a complete set of material parameter values that define a particular visual state or mood. By organizing your parameters into palettes, you can quickly switch between different visual styles or gradually blend them together.
- Palette: A collection of material parameter values representing a specific visual state
- Palette Switcher: The main component that manages transitions between palettes
- Interpolation: Smooth blending between palette values over time
- Material Parameter Collection (MPC): Unreal Engine's system for storing global material parameters
Palette Switcher Component
The Palette Switcher is the main component of the Dynamic Palette System. It manages the transition between two or more Material Parameter Collection configurations, allowing you to create dynamic visual changes in your game.
Setup Instructions
- Add the Palette Switcher component to your level or Blueprint.
- Create or reference your Material Parameter Collection assets.
- Define multiple palettes, each containing specific parameter values.
- Configure the active palette index in the editor to preview different visual states.
- Use Blueprint functions to switch between palettes at runtime.
- Optionally configure interpolation settings for smooth transitions.
Key Properties
- MaterialParameterCollection: Reference to the MPC asset that will be controlled by the system.
- Palettes: Array of palette configurations, each containing a complete set of parameter values.
- ActivePaletteIndex: The currently active palette (used for editor visualization and as the starting palette at runtime).
- bInterpolateBetweenPalettes: If true, transitions between palettes will be smoothly interpolated rather than instant.
- InterpolationSpeed: Controls how quickly the system transitions from one palette to another.
- bPreviewInEditor: If true, palette changes will be visible in the editor viewport, making it easy to set up and test different configurations.
Blueprint Functions
- SetActivePalette(int32 PaletteIndex): Switches to the specified palette. If interpolation is enabled, the transition will be smooth.
- SetNextPalette(): Advances to the next palette in the array, wrapping around to the first palette after the last one.
- SetPreviousPalette(): Goes back to the previous palette in the array, wrapping around to the last palette from the first one.
- SetInterpolationSpeed(float NewSpeed): Dynamically changes the interpolation speed during runtime.
- GetCurrentPaletteIndex(): Returns the index of the currently active palette.
- ForceCompleteInterpolation(): Immediately completes any ongoing interpolation, jumping to the target palette.
Creating Palettes
Creating effective palettes is key to getting the most out of the Dynamic Palette System. Each palette should represent a distinct visual state that you want to be able to switch to.
Palette Configuration
- Define Your Visual States: Decide what different visual modes your scene needs (e.g., day, night, sunrise, sunset for a day/night cycle).
- Set Up Material Parameters: In your Material Parameter Collection, create scalar and vector parameters for all the values you want to control (e.g., sun intensity, sky color, ambient light color).
- Create Palette Entries: For each visual state, create a palette entry in the Palette Switcher and configure all the parameter values for that state.
- Test in Editor: Use the
ActivePaletteIndexproperty withbPreviewInEditorenabled to preview how each palette looks. - Refine Values: Adjust the parameter values in each palette until you achieve the desired visual appearance.
Best Practices
- Consistent Parameters: Make sure all palettes define the same set of parameters to avoid unexpected behavior during transitions.
- Meaningful Names: Give your palettes descriptive names (e.g., "Daytime", "Sunset", "Night") to make them easier to work with.
- Test Transitions: Always test the interpolation between palettes to ensure smooth visual transitions.
- Performance: Be mindful of the number of parameters you're controlling. While the system is efficient, excessive parameter updates can impact performance.
- Modular Design: Consider creating separate Palette Switchers for different aspects of your scene (e.g., one for lighting, one for post-process effects) for better organization.
Common Use Cases
The Dynamic Palette System is versatile and can be used in many different scenarios. Here are some common use cases:
Day/Night Cycle
Create multiple palettes representing different times of day (dawn, day, dusk, night). Control parameters like sun intensity, sky color, ambient light color, and fog density. Use a timer to automatically cycle through the palettes or trigger transitions based on gameplay events.
Weather Effects
Set up palettes for different weather conditions (sunny, cloudy, rainy, foggy). Adjust parameters like sky brightness, fog density, color tints, and precipitation effects. Switch between weather states dynamically based on game logic.
Mood and Atmosphere
Create palettes that represent different emotional tones or gameplay states (normal, danger, stealth, victory). Use color grading, lighting intensity, and post-process parameters to reinforce the mood. Trigger palette changes based on game events to enhance the player experience.
Level Themes
Design palettes for different areas or themes within your game (forest, desert, snow, urban). Transition between palettes when the player moves between different regions. Use this to create visual variety without needing completely separate material setups.
Special Effects
Create dramatic visual changes for special moments (power-up effects, time manipulation, dimension shifts). Use fast interpolation speeds for sudden, impactful changes. Combine with other gameplay systems for enhanced feedback.
Advanced Techniques
Blending Multiple Palettes
While the system primarily transitions between two palettes at a time, you can create complex visual states by carefully sequencing palette transitions or by using multiple Palette Switcher instances controlling different aspects of your scene.
Dynamic Interpolation Control
Use the SetInterpolationSpeed function to create variable transition speeds. For example, you might want weather changes to happen slowly, but danger state transitions to be very fast. You can even use curves or custom logic to create non-linear transition behaviors.
Palette-Driven Gameplay
Consider tying gameplay mechanics to palette states. For example, certain enemies might only appear during specific palette configurations, or player abilities might be enhanced or restricted based on the active palette.
Editor Workflow Integration
Take advantage of the editor preview functionality to rapidly iterate on your visual design. You can even set up editor utility widgets to quickly switch between palettes during level design, making it easier to ensure your level looks good in all visual states.
Troubleshooting
Palettes Not Updating
If your palettes aren't updating in the editor:
- Ensure
bPreviewInEditoris enabled - Verify that your Material Parameter Collection is properly referenced
- Check that your materials are actually using the MPC parameters
- Try toggling the
ActivePaletteIndexto force a refresh
Jerky Interpolation
If transitions between palettes aren't smooth:
- Increase the
InterpolationSpeedvalue for slower transitions - Ensure
bInterpolateBetweenPalettesis enabled - Check that parameter values in different palettes are reasonable (very large jumps may appear jerky)
Performance Issues
If you're experiencing performance problems:
- Reduce the number of parameters in your Material Parameter Collection
- Consider using multiple Palette Switchers with fewer parameters each
- Use
ForceCompleteInterpolation()when instant transitions are acceptable - Profile your game to ensure the Palette System is actually the source of the performance issue
Integration with Other Systems
The Dynamic Palette System is designed to work seamlessly with other Typico Games plugins and standard Unreal Engine systems:
Core Interaction System
Integrate the Palette Switcher with the Core Interaction System by adding a Receiver Component to your Palette Switcher Blueprint. You can then trigger palette changes through the interaction system:
- Action1 - Switch to next palette
- Action2 - Switch to previous palette
- Action3 - Switch to a specific palette index
Blueprint Integration
All Palette Switcher functions are exposed to Blueprints, making it easy to create complex logic for palette transitions. You can trigger palette changes based on game events, player actions, time of day systems, or any other custom logic you implement.
Sequencer Support
Use the Palette Switcher in cinematic sequences by keyframing the ActivePaletteIndex property or by calling the switching functions through sequence events. This allows you to create precisely timed visual changes in your cutscenes.