Help with shader

Hi,

i’m trying to make a shader i added a few stuff but it is doing things that make my eyes go bazurk.

Here’s the shader:

Shader "Exile/Skydome/Animated Clouds" {
	Properties {
		_CloudColor ("Cloud Color", Color) = (0,0,0,1)
		_MainTex ("Cloud pattern", 2D) = "black" {}
		_NormalMap ("Depth Map", 2D) = "white" {}
		_MarbleTex ("Marble Texture", 2D) = "white" {}
		_SunDir ("SunDir", Vector) = (0,0,1,0)
		_RimMultiplier("Rim multiplier", Range (0.0, 1.0)) = 0.3
	}
	SubShader {
		Tags { "RenderType"="Transparent" "Queue"="Transparent"}
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert alpha 

		sampler2D _MainTex;
		sampler2D _NormalMap;
		sampler2D _MarbleTex;
		float4 _CloudColor;
		float4 _SunDir;
		float _RimMultiplier;

		struct Input {
			float2 uv_MainTex;
			float2 uv_NormalMap;
			float2 uv_MarbleTex;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 c = tex2D (_MainTex, IN.uv_MainTex);
			half3 m = tex2D (_MarbleTex, IN.uv_MarbleTex);
			half3 n = UnpackNormal(tex2D(_NormalMap, IN.uv_NormalMap));
			
			float alpha = c.a * _CloudColor.a;
			
			o.Albedo = c;
			o.Alpha = alpha;
			
			if((alpha >= _RimMultiplier))
				o.Normal = n;
				
			else
				o.Normal = 2 * _SunDir;
				//o.Alpha = alpha * m.r;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

Herer’s an image

The model in question is about that ring with the white pathes on it.

Basically i want to check if a alpha value of a pixel is greater than a certain value and just apply the normal map to it.
If the alpha value of the pixel is less than the given constant then give that pixel a normal of 2.

The normal map also reacts to directional lights so at the place where the normal map is not applied (the place where the directional light shining away from it the pixel with alpha less than given value should de 2.0 en multiply that with the sun direction vector.

Now that is working fine.

But adding a color to the albedo adds the color to the normal map and not the diffuse texture underneath it.

Any thoughts on that ?

And also as yo ucan see in the picture the border between the lesser and greater pixel is like alpha testing foliage , is there a way to smoothen that ?

Thanks!

You’re not using _CloudColor.rgb anywhere. What do you want it to do? My guess is you want to multiply c by _CloudColor across all channels.

To smooth out the transition between rim/regular, you should use an interpolation rather than a conditional. Start with lerp().

I will give it a try , thanks

How would i do the lerping then , without the if condition ?

Also the coloring works now , forgot to add it (facepalm)

EDIT:

basically i want to achieve this the outline lighting where the clouds are infront of the sun it works , but it’s radical
it’s need to be more smoothed:

1593732--95808--$OutlineSlope0.jpg