A downloadable game

Download NowName your own price

BAKIN Shader Controller

Drive shader parameters on any character's materials at runtime — directly from event sheets. Swap materials, tint colors, animate rim lights, and more. Changes can persist across map transitions.

■ ShaderController.cs — attach to a Cast event, targets that character
■ PlayerShaderController.cs — attach to a common event called when need changes, always targets the player hero


Features

  • Target any material slot by global index — works across display objects and subgraphics
  • Set colors, floats, and integers on any shader parameter
  • Swap materials at runtime by catalog name
  • GlobalSet* functions — persist changes across map transitions, re-applied automatically on every map load
  • Save and restore parameter values with StoreParam / ResetParam for temporary effects
  • ListMaterials debug function — prints every slot name and index to the log
  • Retry-safe initialization — queues Set* calls if the character isn't ready on startup
  • Available in English, Japanese (日本語), and Simplified Chinese (简体中文)

Functions — ShaderController

SetMaterialIndex
Choose which material slot to affect. Pass -1 for all slots (default). Use ListMaterials to find the right number.

SetParamName
Set the shader parameter name for the next Set* call. Must match the shader declaration exactly.

SetFloat
Set a numeric value on the active parameter. For brightness, strength, threshold, and similar sliders.

SetInt
Set a whole-number value on the active parameter. For toggle flags.

SetColor
Set a color using comma-separated RGB values from 0 to 255. Example: 255,0,0 for red, 0,255,128 for teal.

SetMaterial
Swap this character's material by catalog name. Re-initializes material instances automatically after the swap.

GlobalSetFloat
Same as SetFloat but also saves the value — re-applied automatically on every map load.

GlobalSetColor
Same as SetColor but also saves the value — re-applied automatically on every map load.

GlobalSetMaterial
Same as SetMaterial but also saves the swap — re-applied automatically on every map load.

ApplyGlobals
Re-push all stored global values onto the current materials. Called automatically on Start() — no manual call needed.

ClearGlobals
Wipe all stored global values for this character so they are no longer re-applied on map load.

StoreParam
Save the current parameter value so it can be restored later with ResetParam.

ResetParam
Restore the parameter to the value saved by StoreParam. Good for temporary tint or highlight effects.

ListMaterials
Print all material slots to the debug log with their global index numbers and names. Call this first.

ReadMaterial
Print the currently targeted material name to the debug log.

ReadParam
Print the current parameter value to the debug log.

Reinitialize
Force a full re-scan of the character's materials. Call if the character graphic was swapped at runtime.


Functions — PlayerShaderController

All the same functions as ShaderController. Targets the player hero instead of a Cast character. Attached and called from a common event whenever you need to make a change.


Setup

  1. Copy the .cs files into your project's Scripts folder and compile.
  2. For characters: attach ShaderController to a Cast event via the Catalog. For the player: attach PlayerShaderController to a common event.
  3. Call ListMaterials once from a one-shot event and check the debug log for slot names and index numbers.
  4. Call SetMaterialIndex, SetParamName, then SetColor or SetFloat. Use GlobalSet* versions to persist across map transitions.

Important: Always call Set* functions from a one-shot event, not a Repeat in Parallel sheet. A looping sheet calls the function every frame.


Examples

Flash a character red on hit

SetMaterialIndex   0
SetParamName       'BaseColor'
StoreParam
SetColor           '255,30,30'
Wait               0.15
ResetParam

Persistent player tint across maps

SetMaterialIndex   0
SetParamName       'BaseColor'
GlobalSetColor     '80,200,80'

Remove persistent tint

SetMaterialIndex   0
ClearGlobals
SetParamName       'BaseColor'
ResetParam

Distance-based material swap (fires once per transition)

Assign Distance Between Player and This Event to [L:Dist]
If [L:Dist] is less than 2
    If [L:State] == 0
        Assign 1 to [L:State]
        SetMaterial   'MaterialVariantA'
    End If
Else
    If [L:State] == 1
        Assign 0 to [L:State]
        SetMaterial   'MaterialVariantB'
    End If
End If

Technical notes

Global slot indexing
Material indices count across all display objects combined, including subgraphics. Use ListMaterials to confirm numbers before using them in event sheets.

Map transition persistence
GlobalSet* values are stored in a static dictionary that survives map loads. Start() calls ApplyGlobals() automatically each map to re-push saved values onto the fresh material instances.

GlobalSet* vs Set*
Use plain Set* for temporary effects like hit flashes. Use GlobalSet* for anything that should stay applied across the whole game session.

Retry on startup
Both scripts retry initialization every 10 frames if the character isn't ready yet, and queue pending Set* calls to apply once ready.

ayerShaderController plament


Free to use in any project · RPG Developer Bakin · C# · EN · 日本語 · 简体中文

Published 2 days ago
StatusReleased
Authormelontoucan
AI DisclosureAI Assisted, Code

Download

Download NowName your own price

Click download now to get access to the following files:

ShaderControllerV1.01.rar 30 kB

Development log

Leave a comment

Log in with itch.io to leave a comment.