shader does not work properly on android
Can anyone help me with this shader - it colors mesh using world y position. it works properly on pc, but on android it simply uses last color for all mesh.
Shader "Custom/Terrain" {
Properties {
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 2.0
const static int maxLayerCount = 8;
int layerCount;
float3 baseColours[maxLayerCount];
float baseStartHeights[maxLayerCount];
float minHeight;
float maxHeight;
struct Input {
float3 worldPos;
float3 worldNormal;
};
float inverseLerp(float a, float b, float value) {
return saturate((value-a)/(b-a));
}
void surf (Input IN, inout SurfaceOutput o) {
float heightPercent = inverseLerp(minHeight,maxHeight, IN.worldPos.y);
float drawStrength;
for (int i = 0; i < layerCount; i ++) {
if (i != 0)
drawStrength = saturate(sign(heightPercent - baseStartHeights[i]));
else
drawStrength = 1;
o.Albedo = o.Albedo * (1 - drawStrength) + baseColours[i] * drawStrength;
}
}
ENDCG
}
FallBack "Diffuse"
}
image shows how it works on pc, on mobile mesh is dark green like color with highest index
beztytułu.png
(377.3 kB)
Comment
Your answer

Follow this Question
Related Questions
Shaders don't work properly on android 0 Answers
GPU Instancing works strangely on android 0 Answers
purple(pink) screen on android 0 Answers
Unity Shader Invalid Subscript 'boxMax' 2 Answers