unity使用RenderTexture可以渲染粒子特效

编程入门 行业动态 更新时间:2024-10-10 23:21:57

unity使用RenderTexture可以渲染<a href=https://www.elefans.com/category/jswz/34/1771345.html style=粒子特效"/>

unity使用RenderTexture可以渲染粒子特效

一,使用UIRawImage,创建材质球,把Shader给材质球,放到RawImage的Material上,

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'Shader "UI/Default No-Alpha"
{Properties{[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}_Color("Tint", Color) = (1,1,1,1)_StencilComp("Stencil Comparison", Float) = 8_Stencil("Stencil ID", Float) = 0_StencilOp("Stencil Operation", Float) = 0_StencilWriteMask("Stencil Write Mask", Float) = 255_StencilReadMask("Stencil Read Mask", Float) = 255_ColorMask("Color Mask", Float) = 15}SubShader{Tags{"Queue" = "Transparent""IgnoreProjector" = "True""RenderType" = "Transparent""PreviewType" = "Plane""CanUseSpriteAtlas" = "True"}Stencil{Ref[_Stencil]Comp[_StencilComp]Pass[_StencilOp]ReadMask[_StencilReadMask]WriteMask[_StencilWriteMask]}Cull OffLighting OffZWrite OffZTest[unity_GUIZTestMode]Fog { Mode Off }Blend One ZeroColorMask[_ColorMask]Blend One OneMinusSrcAlpha // 源rgba*1 + 背景rgba*(1-源A值)  Pass{CGPROGRAM#pragma vertex vert  #pragma fragment frag  #include "UnityCG.cginc"  struct appdata_t{float4 vertex   : POSITION;float4 color    : COLOR;float2 texcoord : TEXCOORD0;};struct v2f{float4 vertex   : SV_POSITION;fixed4 color : COLOR;half2 texcoord  : TEXCOORD0;};fixed4 _Color;v2f vert(appdata_t IN){v2f OUT;OUT.vertex = UnityObjectToClipPos(IN.vertex);OUT.texcoord = IN.texcoord;#ifdef UNITY_HALF_TEXEL_OFFSET  OUT.vertex.xy -= (_ScreenParams.zw - 1.0);#endif  OUT.color = IN.color * _Color;return OUT;}sampler2D _MainTex;fixed4 frag(v2f IN) : SV_Target{half4 color = tex2D(_MainTex, IN.texcoord) * IN.color;//clip (color.a - 0.01);  return color;}ENDCG}}
}

最后设置摄像机ClearFlags:Solid Color,
BackGround为黑色

更多推荐

unity使用RenderTexture可以渲染粒子特效

本文发布于:2024-02-13 22:34:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1760904.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:粒子   特效   unity   RenderTexture

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!