Example achieve unity herbal

https://blog.csdn.net/qq_38275140/article/details/89070146
https://roystan.net/articles/grass-shader.html
https://blog.csdn.net/yangxuan0261/article/details/90382630

1, grass mesh grid
Here Insert Picture Description
grass main Texture:
Here Insert Picture Description
Grass sampling shader:

Shader "Unlit/GrassShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        Pass
        {
			Cull Off //背面剔除关闭,使草正反面都绘制
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
				clip(col.a - 0.5); //剔除alpha小于0.5的点
				return col;
            }
            ENDCG
        }
    }
}

Here Insert Picture Description

To define the vertex animation:
To be continued ......

The vertex animation, belong to private files. Haha

Published 646 original articles · won praise 107 · views 360 000 +

Guess you like

Origin blog.csdn.net/wodownload2/article/details/104948515