- Home /
This question was
closed Nov 07, 2013 at 12:58 PM by
Dave-Carlile for the following reason:
Duplicate Question: http://answers.unity3d.com/questions/570824/it-will-not-show-correctly-using-custom-shader-whi-1.html
Question by
gyb_bobo · Nov 07, 2013 at 12:57 PM ·
shaderiosassetbundle
It will not show correctly using custom shader while loading assetbundle built in iPhone
Just like title. this is the code pack the prefab
private static void PackSelect() { string path = Application.streamingAssetsPath + "/bundle.pack";
BuildPipeline.PushAssetDependencies();
BuildPipeline.BuildAssetBundle(Selection.activeObject, null, path,
BuildAssetBundleOptions.CollectDependencies |
BuildAssetBundleOptions.CompleteAssets
, BuildTarget.iPhone);
BuildPipeline.PopAssetDependencies();
}
the prefab can be shown on iPhone correctly, but it turned black(may be execute "Fallback" in shader) while loading assetbundle in UNITY_EDITOR and other platforms.
shader code Shader "Mobile/Cutoff2Side" {
Properties
{
_Color("_Color", Color) = (0.4980392,0.4980392,0.4980392,1)
_Colorpower("_Colorpower", Float) = 2
_Diffusemap("_Diffusemap", 2D) = "gray" {}
_Clipbias("_Clipbias", Range(0,1) ) = 0.466
_Alphabias("_Alphabias", Range(0,1) ) = 0
}
SubShader
{
LOD 200
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Cull Back
Lighting Off
ZWrite Off
AlphaTest Off
Fog { Mode Off }
Offset -1, -1
ColorMask RGB
Blend One OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
CGPROGRAM
#pragma surface surf Lambert
#pragma target 2.0
float4 _Color;
float _Colorpower;
sampler2D _Diffusemap;
float _Clipbias;
float _Alphabias;
struct Input
{
float2 uv_Diffusemap;
};
void surf(Input IN, inout SurfaceOutput o)
{
float4 color = tex2D(_Diffusemap, IN.uv_Diffusemap);
o.Emission = (color * _Colorpower.xxxx * _Color).xyz;
o.Alpha = (color.a - _Alphabias).x;
float c = (color.a - _Clipbias).x;
clip(c);
}
ENDCG
}
Fallback "Diffuse"
}
Comment