- Home /
Multiple Detail Maps per Ramp Color
Hey all,
I'm trying to create a shader that will allow me to specify static texture maps for a certain alpha range in my heightmap. I already have a shader with a working ramp. Any suggestions? This is all I have so far:
Shader "TerrainTest - Vertex Lit" { Properties { _Heightmap ("Greyscale Heightmap(R) Alpha (A)", 2D) = "gray" {} _ColorRamp ("Colour Palette", 2D) = "gray" {} }
SubShader
{
Pass {
Name "ColorReplacement"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
struct Input {
float2 uv_MainTex;
};
v2f vert (appdata_tan v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
return o;
}
sampler2D _Heightmap;
sampler2D _ColorRamp;
float4 frag(v2f i) : COLOR
{
// SURFACE COLOUR
float greyscale = tex2D(_Heightmap, i.uv).r;
// RESULT
float4 result;
result.rgb = tex2D(_ColorRamp, float2(greyscale, 0.5)).rgb;
result.a = tex2D(_Heightmap, i.uv).a;
return result;
}
ENDCG
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Shader - Using Multiple Pass for different shader target 1 Answer
Multiple materials on same object 0 Answers
Problem with BRDF Shader 1 Answer
Why is my picture distorted? 0 Answers
Sprite Renderer Interaction Between Two Sprite Masks? 0 Answers