Skip to content

Unityで画像処理を行うためのライブラリ/A library for image processing in Unity

License

Notifications You must be signed in to change notification settings

Asalato/ImageProcessingLibraryforUnity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageProcessingLibraryforUnity

Unityで画像処理を行うためのライブラリ
A library for image processing in Unity

簡単な画像処理をComputeShaderを利用することで高速に行うことができます.
You can simple image processing rapidly by using ComputeShader.

メソッドチェーンのように記述することができ,直感的に書けるのが特徴です.
You can write like a method chain, so you can write intuitively.

導入 / Installation

Releaseのページから最新版をダウンロードし,利用するUnityプロジェクト内で展開してください
Please download the latest version from the Release page, and deploy it in your Unity project.

利用方法 / How to Use

事前準備 / Prepare before Scripting

利用したいシーン内に ShaderSettings のPrefabを置きます.
Put a Prefab called ShaderSettings in the scene you want to use.

コードの書き方 / How to write codes

  • 画像処理したいテクスチャをTexture2D等のフォーマットからRenderTexture(ComputeShaderで扱えるフォーマット)に変換します.
    Converts a texture to RenderTexture (a format that can be handled by ComputeShader).
var renderTexture = tex2D.ToRenderTexture();
  • FilterLibrary.cs を参考に,好きなフィルタ関数を選びRenderTextureに適用します.
    Refer to FilterLibrary.cs and choose your favorite filter function and apply it to RenderTexture.
// このようにメソッドチェーンのように連続して処理を行うことができます
// you can write a sequence of operations like a method chain
var editedTexture = renderTexture.GaussianFilter3x3().MedianFilter3x3();
  • RenderTextureのままRawImageに貼りつけることで,画像を表示できます
    You can view the image by pasting it to RawImage, even if it is still a RenderTexture.
this.GetComponent<RawImage>().texture = renderTexture;
  • 画像をRenderTextureからTexture2Dに変更することもできます
    You can also change the image from RenderTexture to Texture2D.
var texture2D = renderTexture().ToTexture2D();

About

Unityで画像処理を行うためのライブラリ/A library for image processing in Unity

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages