• 公告板shader


    Shader "Custom/LightPoint" {
        Properties {
            _MainTex ("Main Tex", 2D) = "white" {}
            _Color ("Color Tint", Color) = (1, 1, 1, 1)
        }
        SubShader {
            Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}
            
            Pass { 
                Tags { "LightMode"="ForwardBase" }
                
                ZWrite On//深度写入
                Blend SrcAlpha OneMinusSrcAlpha//开启混合模式
                Offset 0,-10000
            
                CGPROGRAM
                
                #pragma vertex vert
                #pragma fragment frag
                
                #include "Lighting.cginc"
                
                sampler2D _MainTex;
                float4 _MainTex_ST;
                fixed4 _Color;
                
                struct a2v {
                    float4 vertex : POSITION;
                    float4 texcoord : TEXCOORD0;
                    fixed4 texcoord1 : TEXCOORD1;
                    float3 color:COLOR;
                };
                
                struct v2f {
                    float4 pos : SV_POSITION;
                    float2 uv : TEXCOORD0;
                };
                
                v2f vert (a2v v) {
                    v2f o;
                    float scaleX = unity_ObjectToWorld[0][0];//先用3个变量对变换的分量进行记录
                    float scaleY = unity_ObjectToWorld[1][1];
                    float scaleZ = unity_ObjectToWorld[2][2];
                    unity_ObjectToWorld[0][0] = 1;
                    unity_ObjectToWorld[1][1] = 1;
                    unity_ObjectToWorld[2][2] = 1;
    
                    v.texcoord1.x = v.texcoord.x * scaleX;//将第二套uv坐标进行缩放
                    v.texcoord1.y = v.texcoord.y * scaleY;
    
                    float3    centerOffs = float3(float2(0.5, 0.5)*scaleX - v.texcoord1.xy, 0);//得保证面片是整体缩放
                    float3    centerLocal = v.vertex.xyz + centerOffs.xyz;
    
                    centerLocal.x = v.vertex.x*scaleX + centerOffs.x;
                    centerLocal.y = v.vertex.y*scaleY + centerOffs.y;
                    centerLocal.z = v.vertex.z*scaleZ + centerOffs.z;
    
                    float4 centerWolrd = mul(unity_ObjectToWorld, float4(centerLocal.xyz, 1.0));
                    float4 centerView = mul(UNITY_MATRIX_V, centerWolrd);
                    float4 viewP = centerView + float4(centerOffs.xy, 0.0, 0.0);//这里改成-,底下就不用翻转
    
                    o.pos = mul(UNITY_MATRIX_P, float4(viewP.xyz, 1));
                    o.uv = TRANSFORM_TEX(v.texcoord,_MainTex);
                    o.uv.y=1-o.uv.y;//上下翻转图像
                    return o;
                }
                
                fixed4 frag (v2f i) : SV_Target {
                    fixed4 c = tex2D (_MainTex, i.uv);
                    c.rgb *= _Color.rgb;
                    return c;
                }
                
                ENDCG
            }
        } 
        FallBack off
    }
  • 相关阅读:
    WSS3.0安装后,系统资源消耗这么大
    通过名称找到控件(VB.NET)
    zencart 对首页静态化处理
    zen cart 模板类 template_fun class
    现在网络上流行的病毒都太“厚道”了
    从SPS2003的邮件设置上看微软标准与国际标准
    我也有了BLOG,欢迎交流
    如何给WEBPART中增加客户端代码
    如何修改More Information 中的Page 2,Page 3,Page4
    汽车保养项目[转载]
  • 原文地址:https://www.cnblogs.com/luxishi/p/7274328.html
Copyright © 2020-2023  润新知