[27864-mesh.png |27864]
I am trying bulid a mesh , but when I use a transparent shader , I found some of vectices alpha is not right, it seems alpha not same with others , I don’t know why this happen?
use transparent shader
Shader "Custom/water_trans" {
Properties
{
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white"
}
Category
{
Lighting Off
ZWrite Off
//ZWrite On // uncomment if you have problems like the sprite disappear in some rotations.
Cull back
//ZTest less 0.1f
Blend SrcAlpha OneMinusSrcAlpha
//AlphaTest Greater 0.001 // uncomment if you have problems like the sprites or 3d text have white quads instead of alpha pixels.
Tags {Queue=Transparent}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
ConstantColor [_Color]
Combine Texture * constant
}
}
}
}
}
procedual mesh code
//构建顶点索引
Vector3[] vertices = new Vector3[veclist.Count];
Vector2[] uvs = new Vector2[veclist.Count];
for (int i=0; i<veclist.Count; i++)
{
Vector3 ss_pt = new Vector3(veclist_.x,veclist*.y,0.5f);*_
* Vector3 new_pt = Camera.main.ScreenToWorldPoint (ss_pt);
vertices = new_pt;
uvs = new Vector2( (veclist.x-center_pos.x)/water_width+0.5f,(veclist.y-center_pos.y)/water_heigth+0.5f);*
* }*
* List vecIndecs = new List();*
* for (int i=0; i<water_array.pCol.Count-1; i++)
_ {_
int next_i = i+1;
int c_count = water_array.pCol.pRow.Count;
int n_count = water_array.pCol[next_i].pRow.Count;*
* int max_count = (c_count<n_count)? n_count : c_count;
int min_count = (c_count>n_count)? n_count : c_count;
for (int j=0; j<max_count-1; j++)
_ {_
int next_j = j+1;
if(next_j<min_count)
_ {*_
* MY_PTS p1,p2,p3,p4;*
p1 = water_array.pCol*.pRow[j];
p2 = water_array.pCol[next_i].pRow[j];
p3 = water_array.pCol.pRow[next_j];
p4 = water_array.pCol[next_i].pRow[next_j];*
* vecIndecs.Add(p2.index);*
* vecIndecs.Add(p1.index);*
* vecIndecs.Add(p3.index);*
* vecIndecs.Add(p2.index);*
* vecIndecs.Add(p3.index);*
* vecIndecs.Add(p4.index);*
* }*
* else*
* {*
* if(c_count<n_count)
_ {_
int fix_j = c_count -1;
//for(int p=0;p<(n_count-c_count);p++)
_ {_
MY_PTS p1,p2,p3;*
p1 = water_array.pCol*.pRow[fix_j];
p2 = water_array.pCol[next_i].pRow[fix_j+0];
p3 = water_array.pCol[next_i].pRow[n_count-1];*
* vecIndecs.Add(p2.index);*
* vecIndecs.Add(p1.index);*
* vecIndecs.Add(p3.index);*
* }*
* }*
* if(c_count>n_count)
_ {_
int fix_j = n_count -1;
//for(int p=0;p<(c_count-n_count);p++)
_ {_
MY_PTS p1,p2,p3;*
p1 = water_array.pCol*.pRow[fix_j+0];
p2 = water_array.pCol[next_i].pRow[fix_j];
p3 = water_array.pCol.pRow[c_count-1];*
* vecIndecs.Add(p2.index);*
* vecIndecs.Add(p1.index);*
* vecIndecs.Add(p3.index);*
* }*
* } *
* } *
* }*
* }*
* int[] indices = new int[vecIndecs.Count]; *
* for (int i=0; i<vecIndecs.Count; i++)*
* { *
indices = vecIndecs*;*
_ //print (indices*);
}*_
* // Create the mesh*
* Mesh msh = new Mesh();*
* msh.vertices = vertices;*
* msh.uv = uvs;*
* msh.triangles = indices;*
* msh.RecalculateNormals();*
* msh.RecalculateBounds();*
* MeshFilter filter = gameObject.GetComponent(typeof(MeshFilter)) as MeshFilter;*
* filter.mesh = msh;*