How would I apply a normal map to mesh deformation

So the title kind of explains it. I have a mesh deformation script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.ProBuilder;
using UnityEngine.UIElements;

public class MeshesDeformation : MonoBehaviour
{
    [SerializeField] private MeshFilter[] meshFilters = default;
    [SerializeField] private MeshCollider[] colliders = default;
    [SerializeField] private float impactDamage = 1f;
    [SerializeField] private float deformationRadius = 0.5f;
    [SerializeField] private float maxDeformation = 0.5f;
    [SerializeField] private float minVelocity = 2f;
    private float delayTimeDeform = 0.5f;
    private float minVertsDistanceToRestore = 0.05f;
    private float vertsRestoreSpeed = 5f;
    private Vector3[][] originalVertices;
    private float nextTimeDeform = 1f;
    private bool isRepairing = false;
    private bool isRepaired = false;

    private Texture2D noiseTex;
    float sample;
    float xCoord;
    float yCoord;
    private void Start()
    {
        noiseTex = new Texture2D(24, 24);

        originalVertices = new Vector3[meshFilters.Length][];

        for (int i = 0; i < meshFilters.Length; i++)
        {
            originalVertices _= meshFilters*.mesh.vertices;*_

meshFilters*.mesh.MarkDynamic();*
}
}

private void Update()
{
if (Input.GetKeyDown(KeyCode.U))
{
if (!isRepairing)
{
isRepairing = true;
}
}

RestoreMesh();
}

private void DeformationMesh(Mesh mesh, Transform localTransform, Vector3 contactPoint, Vector3 contactVelocity, int i)
{
bool hasDeformated = false;

Vector3 localContactPoint = localTransform.InverseTransformPoint(contactPoint);
Vector3 localContactForce = localTransform.InverseTransformDirection(contactVelocity);
Vector3[] vertices = mesh.vertices;

for (int j = 0; j < vertices.Length; j++)
{
float distance = (localContactPoint - vertices[j]).magnitude;

if (distance <= deformationRadius)
{
vertices[j] += (localContactForce) * (deformationRadius - distance) * impactDamage;
Vector3 deformation = vertices[j] - originalVertices*[j];*

if (deformation.magnitude > maxDeformation)
{
vertices[j] = originalVertices_[j] + deformation.normalized * maxDeformation;
}_

hasDeformated = true;
}
}

if (hasDeformated)
{
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();

if (colliders.Length > 0)
{
if (colliders != null)
{
colliders*.sharedMesh = mesh;*
}
}
}
}

private void OnCollisionEnter(Collision collision)
{
if (Time.time > nextTimeDeform)
{
if (collision.relativeVelocity.magnitude > minVelocity)
{

isRepaired = false;

Vector3 contactPoint = collision.contacts[0].point;
Vector3 contactVelocity = collision.relativeVelocity * 0.01f;

for (int i = 0; i < meshFilters.Length; i++)
{
if (meshFilters != null)
{
DeformationMesh(meshFilters_.mesh, meshFilters*.transform, contactPoint, contactVelocity, i);
}
}*_

nextTimeDeform = Time.time + delayTimeDeform;
}
}
}

private void RestoreMesh()
{
if (!isRepaired && isRepairing)
{
isRepaired = true;

for (int i = 0; i < meshFilters.Length; i++)
{
Mesh mesh = meshFilters*.mesh;*
Vector3[] vertices = mesh.vertices;
Vector3[] origVerts = originalVertices*;*

for (int j = 0; j < vertices.Length; j++)
{
vertices[j] += (origVerts[j] - vertices[j]) * Time.deltaTime * vertsRestoreSpeed;

if ((origVerts[j] - vertices[j]).magnitude > minVertsDistanceToRestore)
{
isRepaired = false;
}
}

mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();

if (colliders != null)
{
colliders*.sharedMesh = mesh;*
}
}

if (isRepaired)
{
isRepairing = false;

for (int i = 0; i < meshFilters.Length; i++)
{
if (colliders != null)
{
colliders_.sharedMesh = meshFilters*.mesh;
}
}
}
}
}
}*

and I want to add some noise to the deformed area of the mesh. making the effect more realistic. I am shore its simple enough but I cant do it. Thanks._

To apply a normal map to the deformed mesh, you will need to modify the DeformationMesh function. After calculating the new vertices positions and applying the deformation, you can sample the normal map at the UV coordinates of each vertex and use the sampled normal to offset the vertex position.

Here is an example of how you can do this:

private void DeformationMesh(Mesh mesh, Transform localTransform, Vector3 contactPoint, Vector3 contactVelocity, int i)
{
    bool hasDeformated = false;

    Vector3 localContactPoint = localTransform.InverseTransformPoint(contactPoint);
    Vector3 localContactForce = localTransform.InverseTransformDirection(contactVelocity);
    Vector3[] vertices = mesh.vertices;
    Vector2[] uv = mesh.uv;

    // Create a normal map sampler
    NormalMapSampler normalMapSampler = new NormalMapSampler(noiseTex);

    for (int j = 0; j < vertices.Length; j++)
    {
        float distance = (localContactPoint - vertices[j]).magnitude;

        if (distance <= deformationRadius)
        {
            vertices[j] += (localContactForce) * (deformationRadius - distance) * impactDamage;
            Vector3 deformation = vertices[j] - originalVertices*[j];*

if (deformation.magnitude > maxDeformation)
{
vertices[j] = originalVertices_[j] + deformation.normalized * maxDeformation;_
}

// Sample the normal map at the UV coordinates of the vertex
Vector3 offset = normalMapSampler.SampleNormalMap(uv[j]);

// Offset the vertex position using the sampled normal
vertices[j] += offset;

hasDeformated = true;
}
}

if (hasDeformated)
{
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();

if (colliders.Length > 0)
{
if (colliders != null)
{
colliders*.sharedMesh = mesh;*
}
}
}
}

You will also need to define a NormalMapSampler class that takes a Texture2D as input and has a SampleNormalMap method that takes in a Vector2 representing the UV coordinates and returns a Vector3 representing the normal offset. Here is an example of how you could implement this class:
public class NormalMapSampler
{
private Texture2D normalMap;

public NormalMapSampler(Texture2D normalMap)
{
this.normalMap = normalMap;
}

public Vector3 SampleNormalMap(Vector2 uv)
{
// Sample the normal map at the given UV coordinates
Color color = normalMap.GetPixelBilinear(uv.x, uv.y);

// Convert the sampled color to a normal vector
Vector3 normal = new Vector3(color.r, color.g, color.b);
normal = 2 * normal - Vector3.one;

return normal;

This class has a constructor that takes in a Texture2D representing the normal map and stores it in a private field. It also has a SampleNormalMap method that takes in a Vector2 representing the UV coordinates and returns a Vector3 representing the normal offset. The method first samples the normal map at the given UV coordinates using GetPixelBilinear, then converts the sampled color to a normal vector by scaling and shifting it.