Skip to content

A method that allows for fast GPU resizing in the Unity Engine.

Notifications You must be signed in to change notification settings

ababilinski/unity-gpu-texture-resize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Why This Script Was Created

This class allows you to resize an image on the GPU.

Speeds

Methods Speeds Source
ResizeTool.Resize(..) 00:00:40.89 This Tool [FREE]
UnityEngine.Texture2D.Resize(..) 01:08:08.55 Unity Method
ResizePro.Resize(..) 00:00:40.28 ResizePro [PAID ASSET]

progress bars of ResizeTool vs Texture2D.Resize

Here is the process:

  1. RenderTexture rt = RenderTexture.GetTemporary() create a temporary render texture with the target size
  2. RenderTexture.active set the active RenderTexture to the temporary texture so we can read from it
  3. Graphics.Blit() Copies source texture into destination render texture with a shader (on the gpu) more info
  4. texture2D.Resize() resize the texture to the target values (this sets the pixel data as undefined) more info
  5. texture2D.ReadPixels() reads the pixel values from the temporary RenderTexture onto the resized texture more info
  6. texture2D.Apply() actually upload the changed pixels to the graphics card more info

About

A method that allows for fast GPU resizing in the Unity Engine.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages