Implement roughness parameter for cook torrance

Hi guys I’ve implemented a vertex lit cook torrance which works fine but I want to control the roughness or metalness of the surface with a roughness parameter rather than set values.

Heres my Shader code :

   Shader "Custom/13_CookTorrance_VertexLit" {

    Properties {

       _BaseColour ("Base (RGB)", Color) = (1,1,1,1)

       _Subsurface ("SubSurface" , Range(0.0,1.0)) = 0.5

     	_Metallic ("Metallic",Range(0.0,1.0)) = 0.5

    	_Specular ("Specular",Range(0.0,1.0)) = 0.5

           _SpecularTint ("Specular Tint", Color) = (1,1,1,1)

           _Roughness ("Roughness", Range(0.0,1.0)) = 0.5

      _Anisotropic ("Anisotropic", Range(0.0,1.0))=0.5

      _Sheen ("Sheen" ,Range(0.0,1.0)) = 0.5

      _SheenTint ("Sheen Tint", Color) = (1,1,1,1)

     _Clearcoat ("Clearcoat" ,Range(0.0,1.0)) = 0.5

     _ClearcoatGloss ("Clearcoat Gloss",Range(0.0,1.0)) = 0.5
	
}
  SubShader {
  Pass {	
     Tags { "LightMode" = "Opaque" } 
        // pass for ambient light and first light source

     CGPROGRAM

     #pragma vertex vert  
     #pragma fragment frag 

     #include "UnityCG.cginc"
     uniform float4 _LightColor0; 
        // color of light source (from "Lighting.cginc")

     // User-specified properties
     uniform float4 _BaseColour; 
     uniform float4 _SpecularTint; 
     uniform float _Specular;
     uniform float3 _Roughness;

     struct vertexInput {
        float4 vertex : POSITION;
        float3 normal : NORMAL;
     };
     struct vertexOutput {
        float4 pos : SV_POSITION;
        float4 col : COLOR;
     };

     vertexOutput vert(vertexInput input) 
     {
        vertexOutput output;

        float4x4 modelMatrix = _Object2World;
        float4x4 modelMatrixInverse = _World2Object; 
           // multiplication with unity_Scale.w is unnecessary 
           // because we normalize transformed vectors

        float3 normalDirection = normalize(float3(
           mul(float4(input.normal, 0.0), modelMatrixInverse)));
        float3 viewDirection = normalize(float3(
           float4(_WorldSpaceCameraPos, 1.0) 
           - mul(modelMatrix, input.vertex)));
        float3 lightDirection;
        lightDirection = normalize(float3(_WorldSpaceLightPos0));
        float attenuation;                 
                
        float3 HalfV = normalize(lightDirection + viewDirection);
        float NdotH =max(0.0,dot(input.normal,HalfV));
        
        float3 RoughnessParams = {0.5,0.5,0.5};
        
         
        float Alpha = acos(NdotH);
        float C = RoughnessParams.x;
        float m = RoughnessParams.y;
        float3 D = C*exp(-(pow(Alpha/m,2.0)));
        
        
        float NdotV = dot(normalDirection,viewDirection);
        float VdotH = dot(HalfV,viewDirection);
        float NdotL = dot(lightDirection,normalDirection);
        
        float3 G1 = 2*NdotH * NdotV /NdotH;
        float3 G2 = 2*NdotH * NdotL /NdotH;
        float3 G = min(1.0,max(0.0,min(G1,G2)));
        
        float R0 = RoughnessParams.z;
        float3 F = R0 +(1.0-R0) * pow(1.0 - NdotL,5.0);
        
        output.col = float4(_BaseColour * F *D*G/(NdotL *NdotV),1.0);
                     
      

        
       
        output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
        return output;
        
        
        
        
        
        

    
     }

     float4 frag(vertexOutput input) : COLOR
     {
        return input.col;
     }

     ENDCG
  }

}

}

An image of how it looks

Any Suggestions

I figured out the problem myself something small aswell , before when i replaced the roughnessparams variables values with my Roughness parameter it didn’t work because I had my Roughness parameter as a float3 but when I changed that to a float it worked fine.