I'm trying to create a shader that takes a grayscale map as input, and returns a colored albedo that I want to use as texture for my PCG planets, I think that the code below should work, but it only produces flatly white objects.
I'm a total shader noob, so I'm terribly sorry if I'm missing something obvious here.
Shader "Custom/Planet" {
Properties{
_height("HeightMap", 2D) = "white" {}
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
struct Input {
float2 _heightMap;
};
float minHeight = 0;
float maxHeight = 1;
float inverseLerp(float a, float b, float v) {
return saturate((v - a) / (b - a));
}
//UNITY_INSTANCING_CBUFFER_START(Props)
//UNITY_INSTANCING_CBUFFER_END
void surf (Input IN, inout SurfaceOutputStandard o) {
float hv = inverseLerp(minHeight, maxHeight, IN._heightMap);
o.Albedo = hv;
}
ENDCG
}
FallBack "Diffuse"
}
uv_heightMap
andinverseLerp(minHeight, maxHeight,IN.uv_heightMap);
if you need color you should have float4 in Albedo \$\endgroup\$