Convert Figma logo to code with AI

keijiro logoKlak

Creative coding library for Unity

1,878
186
1,878
15

Top Related Projects

3,292

Special Effects with Skinned Mesh in Unity

Video glitch effects for Unity

Additional tools for Visual Effect Artists

A first person multiplayer shooter example project in Unity

Quick Overview

Klak is a collection of Unity scripts and tools designed to enhance creative coding and prototyping in Unity. It provides a set of utilities and components that simplify common tasks in Unity development, particularly for audiovisual and interactive projects.

Pros

  • Simplifies complex Unity tasks, making it easier for beginners and experienced developers alike
  • Offers a wide range of utilities, from input handling to audio visualization
  • Regularly updated and maintained, ensuring compatibility with newer Unity versions
  • Open-source, allowing for community contributions and customizations

Cons

  • May have a learning curve for those unfamiliar with Unity or creative coding concepts
  • Some components might be overkill for simple projects
  • Documentation could be more comprehensive for certain features
  • Dependency on Unity means it's not usable in other game engines or frameworks

Code Examples

  1. Creating a simple oscillator:
using Klak.Math;
using UnityEngine;

public class OscillatorExample : MonoBehaviour
{
    void Update()
    {
        float value = Oscillator.Sine(Time.time, 1.0f);
        transform.position = new Vector3(value, 0, 0);
    }
}
  1. Using the Waveform class for audio visualization:
using Klak.Waveform;
using UnityEngine;

public class WaveformExample : MonoBehaviour
{
    public WaveformProvider waveform;
    public LineRenderer lineRenderer;

    void Update()
    {
        Vector3[] positions = new Vector3[waveform.resolution];
        for (int i = 0; i < waveform.resolution; i++)
        {
            float x = (float)i / (waveform.resolution - 1);
            float y = waveform.GetValue(x);
            positions[i] = new Vector3(x, y, 0);
        }
        lineRenderer.positionCount = waveform.resolution;
        lineRenderer.SetPositions(positions);
    }
}
  1. Using the Noise class for procedural animation:
using Klak.Math;
using UnityEngine;

public class NoiseExample : MonoBehaviour
{
    void Update()
    {
        float noiseX = Noise.Perlin(Time.time, 0, 0);
        float noiseY = Noise.Perlin(0, Time.time, 0);
        transform.position = new Vector3(noiseX, noiseY, 0);
    }
}

Getting Started

  1. Clone or download the Klak repository from GitHub: https://github.com/keijiro/Klak
  2. Copy the desired Klak folders (e.g., Klak.Math, Klak.Waveform) into your Unity project's Assets folder
  3. In your Unity scripts, add the appropriate using statements (e.g., using Klak.Math;)
  4. Start using Klak's classes and components in your Unity project

For more detailed information and examples, refer to the repository's README and individual component documentation.

Competitor Comparisons

3,292

Special Effects with Skinned Mesh in Unity

Pros of Skinner

  • Specialized for mesh skinning and deformation effects
  • Provides advanced GPU-based skinning techniques
  • Offers unique visual effects for character animation

Cons of Skinner

  • More focused on a specific use case (skinning) compared to Klak's broader utility
  • May have a steeper learning curve for users unfamiliar with mesh deformation concepts
  • Less versatile for general-purpose Unity enhancements

Code Comparison

Skinner (GPU-based skinning):

[ComputeShader]
public ComputeShader skinningShader;

void ApplySkinning()
{
    skinningShader.Dispatch(0, meshVertexCount / 64 + 1, 1, 1);
}

Klak (general-purpose utility):

[SerializeField]
KlakWave _waveEffect;

void Update()
{
    _waveEffect.Amplitude = Mathf.Sin(Time.time) * 0.5f;
}

Summary

Skinner is a specialized tool for advanced mesh skinning and deformation, offering unique visual effects for character animation. It excels in GPU-based skinning techniques but may be less versatile for general Unity enhancements. Klak, on the other hand, provides a broader set of utilities and effects for Unity projects, making it more suitable for various use cases beyond character animation.

Video glitch effects for Unity

Pros of KinoGlitch

  • Focused specifically on glitch effects for Unity
  • Simpler to use for quick glitch implementations
  • Lightweight and optimized for real-time performance

Cons of KinoGlitch

  • Limited to glitch effects only
  • Less versatile compared to Klak's broader functionality
  • Fewer customization options for advanced users

Code Comparison

KinoGlitch:

[SerializeField, Range(0, 1)]
float _intensity = 0.1f;

[SerializeField, Range(0, 1)]
float _scanLineJitter = 0.1f;

Klak:

[SerializeField]
AnimationCurve _curve = AnimationCurve.Linear(0, 0, 1, 1);

[SerializeField]
float _speed = 1.0f;

Summary

KinoGlitch is a specialized Unity plugin for creating glitch effects, offering simplicity and optimized performance. It's ideal for projects requiring quick glitch implementations but may be limiting for more complex visual manipulations.

Klak, on the other hand, is a more comprehensive toolkit for Unity, providing a wider range of visual effects and utilities. While it offers greater versatility and customization options, it may be overkill for projects only needing glitch effects.

Choose KinoGlitch for focused glitch effects or Klak for a broader range of visual manipulations and utilities in Unity projects.

Additional tools for Visual Effect Artists

Pros of VFXToolbox

  • Official Unity tool, ensuring compatibility and long-term support
  • Comprehensive set of tools for VFX creation and management
  • Integrates seamlessly with Unity's Visual Effect Graph

Cons of VFXToolbox

  • Steeper learning curve due to more complex features
  • May be overkill for simple projects or beginners
  • Less frequent updates compared to community-driven projects

Code Comparison

VFXToolbox (using Visual Effect Graph):

public class VFXSpawner : MonoBehaviour
{
    public VisualEffect vfx;
    void Update()
    {
        vfx.SendEvent("OnSpawn");
    }
}

Klak (using particle system):

public class ParticleSpawner : MonoBehaviour
{
    public ParticleSystem particles;
    void Update()
    {
        particles.Emit(1);
    }
}

Summary

VFXToolbox is a powerful, official Unity tool for advanced VFX creation, while Klak offers a simpler, more accessible approach for quick prototyping and experimentation. VFXToolbox excels in complex projects and professional workflows, whereas Klak shines in its ease of use and rapid iteration capabilities. The choice between the two depends on project requirements, team expertise, and desired visual complexity.

A first person multiplayer shooter example project in Unity

Pros of FPSSample

  • Comprehensive FPS game template with networking, AI, and gameplay systems
  • Official Unity project showcasing best practices and optimizations
  • Extensive documentation and community support

Cons of FPSSample

  • Large project size, potentially overwhelming for beginners
  • Focused solely on FPS genre, less versatile than Klak
  • Requires more setup and configuration for custom projects

Code Comparison

FPSSample (PlayerCharacterController.cs):

public void Move(Vector3 move, bool sprint)
{
    m_MoveInput = move;
    m_SprintInput = sprint;
}

Klak (BrownianMotion.cs):

void Update()
{
    var dt = Time.deltaTime;
    _velocity += Random.insideUnitSphere * (_acceleration * dt);
    _velocity *= Mathf.Exp(-_drag * dt);
    transform.position += _velocity * dt;
}

FPSSample provides a more structured approach to player movement, while Klak offers a simple, physics-based motion system. FPSSample is tailored for FPS gameplay, whereas Klak is more versatile for various motion effects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Klak

gif gif

gif gif

gif gif

Klak is a collection of scripts for creative coding with Unity.

Features

  • Noise/Random number

  • Perlin noise

  • Reproducible random number series with xxHash

  • Reproducible noise generator

  • Interpolator

  • Frame rate independent exponential interpolation

  • Classic spring smoothing

  • Critically damped spring smoothing

  • Extension methods for the standard classes

  • Vector4/Quaternion converter

  • Material property setter

  • Klak.Motion: basic procedural motion

  • Constant motion

  • Brownian motion

  • Klak.Wiring: node-based patching system

Installation

Download one of the unitypackage files from the Releases page and import it to a project.

Extensions

  • MidiKlak - MIDI input extension
  • OscKlak - OSC (Open Sound Control) input extension
  • KlakUI - Custom UI controls
  • KlakSpout - Spout (inter-application video sharing) extension

License

MIT