View Code? Open in Web Editor
NEW
A method that allows for fast GPU resizing in the Unity Engine.
unity-gpu-texture-resize's Introduction
Why This Script Was Created
This class allows you to resize an image on the GPU.
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]
RenderTexture rt = RenderTexture.GetTemporary()
create a temporary render texture with the target size
RenderTexture.active
set the active RenderTexture to the temporary texture so we can read from it
Graphics.Blit()
Copies source texture into destination render texture with a shader (on the gpu) more info
texture2D.Resize()
resize the texture to the target values (this sets the pixel data as undefined) more info
texture2D.ReadPixels()
reads the pixel values from the temporary RenderTexture onto the resized texture more info
texture2D.Apply()
actually upload the changed pixels to the graphics card more info
unity-gpu-texture-resize's People
Contributors
unity-gpu-texture-resize's Issues
I don't really see why the rendertexture is used here, the data is blitted once from input Texture2d to the rendertexture it doesn't seem to be used anywhere later.
What purpose does the rt fullfill?
Seems you are only applying Graphics.Blit
- how does this compare to ResizePro?