Rough around the edges?

Hiyah! I’m just looking to make something rough around the visible edges, based on a texture gradient, using only a shader. (The gradient would be wrapped around the edge as a heightmap for the roughness)

Not quite sure about the effect you’re looking for here. Can you give a bit more detail?

if I understand Flynn, there are two shader only ways to do this :

  • displace the vertices of a highly tesselated object with a noise function
  • use a the gradient to define which range of angle incidence to make transparent, then multiply this transparency by noise to get the roughness.

in 3.0 it would be like this

Shader "RoughAroundTheEdges" 
{
	Properties 
	{
		_MainTex ("Texture", 2D) = "white" {}
		_BumpMap ("Bumpmap", 2D) = "bump" {}
		_Ramp ("Shading Ramp", 2D) = "gray" {}
	}
	SubShader 
	{
		CGPROGRAM
		#pragma surface surf Lambert
		
		struct Input 
		{
			float2 uv_MainTex;
			float2 uv_BumpMap;
			float3 viewDir;
		};
		sampler2D _MainTex;
		sampler2D _BumpMap;
		sampler2D _Ramp;
		
		void surf (Input IN, inout SurfaceOutput o)
		{
			o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
			half incidence = dot (normalize(IN.viewDir), o.Normal);
			half incidenceRamped = tex2D (_Ramp, float2(incidence)).r;
			if (incidenceRamped<0)
				o.Alpha = incidenceRamped * noise( uv_MainTex );
			else
				o.Alpha = incidenceRamped;
			o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * o.Alpha;
		}

		ENDCG
	} 
}