Hi,
either I still don’t understand the working of BlitMultiTap or I do something wrong.
I want to blend an object many times with different offsets for testing with the following setup:
ImageEffect code file:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class LensDistortion : MonoBehaviour
{
private Material _material;
public Shader ImageShader;
public Texture2D RampTex;
public Material Material
{
get
{
if (_material == null)
{
_material = new Material(ImageShader);
_material.hideFlags = HideFlags.HideAndDontSave;
}
return _material;
}
}
public void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.BlitMultiTap(source, destination, Material,
new Vector2(-50, -50),
new Vector2(50, -50),
new Vector2(-50, 50),
new Vector2(50, 50),
new Vector2(-100, -100),
new Vector2(-100, 100),
new Vector2(100, -100)
);
}
public void OnDisable()
{
if (_material != null)
{
DestroyImmediate(_material);
}
}
}
Shader:
Shader "Hidden/MultiTap" {
Properties{ _MainTex("", any) = "" {} }
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
half2 uv : TEXCOORD0;
half2 taps[4] : TEXCOORD1;
};
sampler2D _MainTex;
half4 _MainTex_TexelSize;
half4 _BlurOffsets;
v2f vert(appdata_img v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
half4 frag(v2f i) : COLOR{
return tex2D(_MainTex, i.uv);
}
ENDCG
SubShader {
Pass{
ZTest Always Cull Off ZWrite Off
Fog{ Mode off }
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}
Basically I took the BlurMultiConeTap shader and modified it.
Camera setup:

Result:
But for my understanding it should be more like:
It seems the first offset vector is already added to the v.texcoord so the first tap is already at the correct position but I cannot get the other taps to process or am I missing something?
Do I still have to blend or activate anything?
I use Unity Free 5.2.
Thank you
Best regards
Mark
