Hi,
i have wrote small skript from material example with my shader material,but i have white screen.
Here ist skript for camera
using UnityEngine;
using System.Collections;
public class CameraPostProcessing : MonoBehaviour {
public Shader shader;
Material m;
void Start () {
m = new Material(shader);
/* m = new Material (
"Shader \"Hidden/Invert\" {" +
"SubShader {" +
" Pass {" +
" ZTest Always Cull Off ZWrite Off" +
" SetTexture [_MainTex] { combine one-texture }" +
" }" +
"}" +
"}"
);*/
}
void OnRenderImage(RenderTexture source, RenderTexture dest){
RenderTexture.active = dest;
source.SetGlobalShaderProperty ("_MainTex");
GL.PushMatrix ();
GL.LoadOrtho ();
// activate the first pass (in this case we know it is the only pass)
m.SetPass (0);
// draw a quad
GL.Begin (GL.QUADS);
GL.TexCoord2 (0.0f, 0.0f); GL.Vertex3 (0.0f, 0.0f, 0.1f);
GL.TexCoord2 (1.0f, 0.0f); GL.Vertex3 (1.0f, 0.0f, 0.1f);
GL.TexCoord2 (1.0f, 1.0f); GL.Vertex3 (1.0f, 1.0f, 0.1f);
GL.TexCoord2 (0.0f, 1.0f); GL.Vertex3 (0.0f, 1.0f, 0.1f);
GL.End ();
GL.PopMatrix ();
}
}
and here shader
Shader "ColorShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0.5)
_MainTex ("Texture", RECT) = "white" { }
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
//Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#include "UnityCG.cginc"
float4 _Color;
sampler2D _MainTex;
struct v2f {
V2F_POS_FOG;
float2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uv = TRANSFORM_UV(0);
return o;
}
half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D( _MainTex, i.uv );
return texcol * _Color;
//return half4(1,0,0,1);
}
ENDCG
}
}
Fallback "VertexLit"
}
I want just source Texture on Quad drawing.
Thanks