- Home /
How to get/pass (Vector2) arrays in a shader?
I am trying to do image processing which I've found is much too slow with GetPixels32(). Instead I'm looking at using a shader. The problem is there is no way I have found to set an array or get an array, specifically a Vector2[]. I thought I could take advantage of the uv[] array but didn't know if this was possible. Does anyone have a suggestion as to what I can do?
Answer by ScroodgeM · Aug 31, 2012 at 11:06 PM
SepiaToneEffect.cs
using UnityEngine;
[ExecuteInEditMode] [AddComponentMenu("Image Effects/Sepia Tone")] public class SepiaToneEffect : ImageEffectBase {
// Called by camera to apply image effect void OnRenderImage (RenderTexture source, RenderTexture destination) { Graphics.Blit (source, destination, material); } }
So you think I should wrap my data inside the destination RenderTexture? This seems the most feasible idea.
this is the best and fastest way to make image processing, cause this method uses GPU, that is many times faster with tasks like this then CPU. which used in GetPixels32 and Vector2[]