python网站入口,免费聊天网站模板和源码,微信内部劵网站怎么做,什么网站做简历好1.OnRenderImage (RenderTexture source, RenderTexture destination)
当这个函数被调用时#xff0c;所有的渲染已经完成#xff0c;渲染结果以参数source传入到函数中。它允许你对最终的显示图像进行处理。所以说是后期特效。
处理的最终结果会输入到destination中。如果…1.OnRenderImage (RenderTexture source, RenderTexture destination)
当这个函数被调用时所有的渲染已经完成渲染结果以参数source传入到函数中。它允许你对最终的显示图像进行处理。所以说是后期特效。
处理的最终结果会输入到destination中。如果相机上添加多个后处理脚本则会依次执行而且前一个的destination会用作下一个的source。
2.Graphics.Blit
public static void Blit(Texture source, RenderTexture dest, Material mat, int pass -1);
有三个重载方法这个方法的参数是最全的。
如果mat不为空那么source被设置为mat中的shader的_MainTex因此必须在shader开头的Properties块中定义_MainTex属性.
该方法使用mat中的shader绘制一个全屏的quad
Note that if you want to use depth or stencil buffer that is part of the source (Render)texture, youll have to do equivalent of Blit functionality manually - i.e.Graphics.SetRenderTarget with destination color buffer and source depth buffer, setup orthographic projection (GL.LoadOrtho), setup material pass (Material.SetPass) and draw a quad (GL.Begin).
由上面这段话可以看出Blit的等价方法是依次使用Graphics.SetRenderTargetGL.LoadOrthoMaterial.SetPass和
GL.Begin(GL.QUADS);(GL.QUADS);
所以说最后实际渲染的是一个以mat为材质以source为_MainTex的全屏大小的quad,渲染该quad的摄像机为正交的。渲染的结果输出到destinationdestination就是rendertarget.
网上某人写的大致应该就是这样吧没研究 static public void Blit(RenderBuffer COLOR,RenderBuffer DEPTH, Material MRTMat,int pass){Graphics.SetRenderTarget(COLOR, DEPTH);RenderQuad (MRTMat, pass);} static public void RenderQuad( Material MRTMat,int pass){GL.PushMatrix();GL.LoadOrtho();MRTMat.SetPass(pass);GL.Begin(GL.QUADS);GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(0.0f, 1.0f, 0.1f);//设置顶点这样可以全屏0,1代表屏幕左上角GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1.0f, 1.0f, 0.1f); //右上角 GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1.0f, 0.0f, 0.1f); //右下角 GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(0.0f, 0.0f, 0.1f); //左下角 GL.End();GL.PopMatrix();
} 这个函数就像过转化器一样source图片经过它的处理变成了dest图片其中材质对象mat负责算法实施更准确的说法算法是绑定到该mat上的shader来实现的。shader可以有多个pass可以通过pass参数指定特定的shader-1表示执行这个shader上所有的pass。
3. Texture size {TextureName}_TexelSize - a float4 property contains texture size information:
x contains 1.0/widthy contains 1.0/heightz contains widthw contains height