Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Shader fails on iOS

$
0
0
I've started to learn to write shaders in Cg, and I've written a few relatively straight-forward shaders, such as Lambertian, Toon and Rim-Lit. When I try to run on my iPhone6, the Lambertian and Toon shaders work just fine, but the Rim-Lit fails, with a warning in xcode saying> Warning: Creation of shader 'Awesome/EdgeLitNormal' failed.WARNING: Shader Unsupported: 'Awesome/EdgeLitNormal' - Pass '' shader state not supported WARNING: Shader Unsupported: 'Awesome/EdgeLitNormal' - Setting to default shader. All the shaders work just fine in the editor. The code for my shader is Shader "Awesome/EdgeLitNormal" { Properties { _Color ("Color", Color) = (0.3, 1.0, 0.2, 1.0) _EdgeColor ("Edge color", Color) = (1.0, 1.0, 1.0, 1.0) _EdgePower ("Edge power", Range (0.0, 10.0)) = 1.0 } SubShader { Pass { Tags { "LightMode" = "ForwardBase" } CGPROGRAM #pragma vertex vert #pragma fragment frag uniform float4 _Color; uniform float4 _EdgeColor; uniform float _EdgePower; uniform float4 _LightColor0; // input-output structs between shader stages struct vertexInput { float4 vertex : POSITION; float3 normal : NORMAL; }; struct vertexOutput { float4 pos : SV_POSITION; // SV_ is for DX11 float3 normalDir; float3 viewDir; }; // vertex shader vertexOutput vert(vertexInput v) { vertexOutput o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.normalDir = normalize(mul(float4(v.normal, 0.0), _World2Object)).xyz; o.viewDir = normalize(_WorldSpaceCameraPos.xyz - mul(_Object2World, v.vertex)); return o; } // fragment shader float4 frag(vertexOutput i) : COLOR { //Lambertian float3 lightDir = normalize(_WorldSpaceLightPos0).xyz; float3 diffuseAmount = max(0.0, dot(i.normalDir, lightDir)); float3 finalDiffuse = _LightColor0.xyz * diffuseAmount + UNITY_LIGHTMODEL_AMBIENT; //Edge lighting half edgeAmount = 1 - saturate(dot(i.viewDir, i.normalDir)); float3 finalEdge = pow(edgeAmount, _EdgePower) * _EdgeColor; return float4(finalDiffuse * _Color + finalEdge, 1.0); } ENDCG } } //Fallback "Diffuse" } I've tried to look around for info about what's going on, but with so little information in the error-message, it's kind of hard to even know where to start. Does anyone know why this shader wouldn't run on iOS?

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>