unity3d shader BIllboard 使模型始终朝向摄像机
来源:互联网 发布:淘宝店铺背景音乐推荐 编辑:程序博客网 时间:2024/06/05 16:00
修改unity 内置shader Particles/Additive 为增加 BIllboard功能
上代码
Shader "Particles/AddtiveBillboard" {Properties { _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) _MainTex ("Particle Texture", 2D) = "white" {} _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0}Category { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Blend SrcAlpha One AlphaTest Greater .01 ColorMask RGB Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_particles #include "UnityCG.cginc" sampler2D _MainTex; fixed4 _TintColor; struct appdata_t { float4 vertex : POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; #ifdef SOFTPARTICLES_ON float4 projPos : TEXCOORD1; #endif }; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; //o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);//这里是原有的vertex 赋值代码,注释掉 //****************这里修改的vertex赋值代码******************* float4 ori=mul(UNITY_MATRIX_MV,float4(0,0,0,1)); float4 vt=v.vertex; vt.y=vt.z; vt.z=0; vt.xyz+=ori.xyz; o.vertex=mul(UNITY_MATRIX_P,vt); //****************************** #ifdef SOFTPARTICLES_ON o.projPos = ComputeScreenPos (o.vertex); COMPUTE_EYEDEPTH(o.projPos.z); #endif o.color = v.color; o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); return o; } sampler2D_float _CameraDepthTexture; float _InvFade; fixed4 frag (v2f i) : SV_Target { #ifdef SOFTPARTICLES_ON float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))); float partZ = i.projPos.z; float fade = saturate (_InvFade * (sceneZ-partZ)); i.color.a *= fade; #endif return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); } ENDCG } } }}
阅读全文
0 0
- unity3d shader BIllboard 使模型始终朝向摄像机
- unity3d Billboard(物体始终面相摄像机)
- Unity3D让物体始终朝向摄像机的2中方法
- Unity3D c# 使对象物体始终面向摄像机。
- Unity3D始终让物体面向主摄像机
- UE4让物体始终朝向摄像机(一)—Find Look At Rotation用法
- UE4让物体始终朝向摄像机(二)—RInterp To用法
- Unity3d Shader光照模型
- Unity 点击模型上任意位置,模型旋转,点击位置朝向摄像机
- BillBoard shader实现
- BillBoard shader实现
- unity3d摄像机
- unity3d摄像机
- unity3d摄像机
- unity3d摄像机
- Unity3D 摄像机
- unity3d--摄像机
- unity3d摄像机
- 数论基础 (费马小定理/扩展欧几里得/欧拉函数)
- 从0开始教你申请服务器搭建ss服务并开启多账号访问外网
- linux/Unix系统调用之getopt()
- 9.springboot整合swagger2生成rest-api
- typedef 以及vector的应用
- unity3d shader BIllboard 使模型始终朝向摄像机
- 谷歌AI中国中心北京成立 提供高质量AI及机器学习教育支持
- 金山云完成3亿美元D轮融资 未来将布局AI领域
- Parallel and Concurrent Programming in Haskell.pdf 英文原版 免费下载
- spring启动时报错No qualifying bean of type【bean 】 is defined
- Quatrz简单入门
- 深度理解java 字符串
- Java中static、this、super、final的用法
- c语言的发展历程