Shader材质上传到ios后效果跟编辑不一样。求帮助
不知道是否PC品台跟ios的运算方式不一样,所以造成在电脑上编辑的材质上传到ipad后显示的效果不一样。然后发现应该是这个各向异性的高光不知道应该要怎样写才能在ios也能达到跟电脑的效果一样。下面是源码,请各位大大帮忙看看,帮忙解决解决。谢谢Shader "Wshader/XGQML" {
Properties {
//添加属性;
_MainTint("Diffuse Tint",Color)=(1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_SpecularColor("Specular Color",Color)=(1,1,1,1)
_SpecPower("Specular Power", Range(0.1,1))=0.5
_Specular("Specular Amount",Range(0.1,1))=0.5
_AnisoDir("Aniso Image",2D)=""{}
_AnisoOffset("Aniso Offset",Range(-1,1))=0.5
_MaskMap("Reflect (R) Glossiness (G)", 2D) = "white" {}
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_Cube ("Cubemap", CUBE) = "" {}
_ReflAmount("Reflection Amount",Range(0,1)) =0.5
_RimTex("Rim Tex" ,2D)="white"{}
_RimColor("Rim Color" , Color)=(0.26,0.19,0.16,0.0)
_RimPower("Rim Power",Range(0,20.0))=3.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf AnisoPhong
#pragma target 3.0
//设置变量;
sampler2D _MainTex;
sampler2D _AnisoDir;
float4 _MainTint;
float4 _SpecularColor;
float _AnisoOffset;
float _SpecPower;
float _Specular;
float4 _ReflectColor;
samplerCUBE _Cube;
float _ReflAmount;
sampler2D _MaskMap;
float4 _RimColor;
float _RimPower;
sampler2D _RimTex;
struct Input {
float2 uv_MainTex;
float2 uv_AnisoDir;
float2 uv_MaskMap;
float3 worldRefl;
float3 viewDir;
float2 uv_RimTex;
};
//自定义输出结构体;
struct SurfaceAnisoOutput
{
fixed3 Albedo;
fixed3 Normal;
fixed3 Emission;
fixed3 AnisoDirection;
half Specular;
fixed Gloss;
fixed Alpha;
};
//自定义光照模型;
inline fixed4 LightingAnisoPhong(SurfaceAnisoOutput s,fixed3 lightDir,half3 viewDir, fixed atten){
fixed3 halfVector = normalize(normalize(lightDir)+normalize(viewDir));
float NdotL = saturate( dot(s.Normal,lightDir) );
fixed HdotA = dot(normalize(s.Normal+s.AnisoDirection),halfVector);
float aniso = max(0,sin(radians(HdotA+_AnisoOffset)*180));
float spec = saturate(pow(aniso,s.Gloss*50)*s.Specular);
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb*NdotL)+(_LightColor0.rgb * _SpecularColor.rgb*spec)*(atten*2);
c.a=1;
return c;
}
void surf (Input IN, inout SurfaceAnisoOutput o) {
half rim = saturate(dot(normalize(IN.viewDir),o.Normal));
half4 r = tex2D (_RimTex, IN.uv_RimTex)*_RimColor;
//half rim = 1.0-saturate(dot(normalize(IN.viewDir),o.Normal));
//o.Emission =_RimColor.rgb*pow(rim,_RimPower);
half4 c = tex2D (_MainTex, IN.uv_MainTex)*_MainTint;
float3 anisoTex = UnpackNormal(tex2D(_AnisoDir,IN.uv_AnisoDir));
o.AnisoDirection = anisoTex;
o.Specular = _Specular;
o.Gloss = _SpecPower;
o.Albedo = c.rgb+r.rgb*30*pow(rim,_RimPower);
o.Alpha = c.a;
half4 d = tex2D(_MaskMap, IN.uv_MaskMap);
_SpecPower = _SpecPower * _SpecPower * 0.111111 * d.g;
o.Emission =texCUBE(_Cube,IN.worldRefl).rgb*_ReflectColor*_ReflAmount*d.rgb*2;
}
ENDCG
}
FallBack "Diffuse"
}
求大神帮忙看看应该要怎样改。感谢感谢啊 很不错 楼主是超人 顶顶多好 真心顶 难得一见的好帖 很不错 楼主是超人 好帖就是要顶
页:
[1]