我试图建立一个统一的WebIS使用统一5测试版WebGL。 我写的自定义着色器(或从现有的着色器更准确地编辑)不再适用于Unity 5. 继承人着色器应该做什么。创建一个圆球曲线中的阿尔法斜线的元球效果。 着色器打开这个.. 到这个..(通过渲染纹理) 自定义着色器不再工作在Unity 5
继承人的整个事情..
//Water Metaball Shader effect by Rodrigo Fernandez Diaz-2013
//Visit http://codeartist.info/ for more!!
Shader "Custom/Metaballs" {
Properties {
_MyColor ("Some Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" { }
_botmcut ("bottom cutoff", Range(0,1)) = 0.1
_topcut ("top cutoff", Range(0,4)) = 0.8
_constant ("curvature constant", Range(0,5)) = 1
}
SubShader {
Tags {"Queue" = "Transparent" }
Pass {
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _MyColor;
float4 _Color;
sampler2D _MainTex;
float _botmcut,_topcut,_constant;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert (appdata_base v){
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
return o;
}
half4 frag (v2f i) : COLOR{
half4 texcol,finalColor;
texcol = tex2D (_MainTex, i.uv);
//finalColor=_Color*texcol;
finalColor=_MyColor;
if(texcol.a<_botmcut)
{
finalColor.a= 0;
}
else if((texcol.a>_topcut))
{
finalColor.a= 0;
}
else
{
float r = _topcut-_botmcut;
float xpos = _topcut - texcol.a;
finalColor.a= 1-(_botmcut + sqrt((xpos*xpos)-(r*r)))/_constant;
}
return finalColor;
}
ENDCG
}
}
Fallback "VertexLit"
}
我在Unity 5时遇到的问题是,所产生的纹理是空白的。即。 0 alpha。 似乎是导致问题的位是这一个。
else
{
float r = _topcut-_botmcut;
float xpos = _topcut - texcol.a;
finalColor.a= 1-(_botmcut + sqrt((xpos*xpos)-(r*r)))/_constant;
}
如果我注释掉这个“finalCOlor ......等等等等”的最后一行,然后我看到东西 这是通常创建圆形alpha曲线线,但在统一五是始终似乎解决为0。 API有没有变化?因为这个数学应该和它在团结中的工作方式一样。 Ps。我不太了解着色器!
这使我相信在xpos
nfirvine
2015-03-20 00:38:54