I have a 3D plane with a shader material applied. This material should change when the player shoots at it. For this, I need to get the mouse position somehow inside the shader.

So, I shoot a gun, fire a raycast, it hits the plane, and then I need to figure where exactly it landed.

Perhaps I can ignore the Shader part in my question, as that is trivial to figure out once I can get some relative positions of where the raycast hits the plane. How to do this?

    3Dsander while you wait for a real answer, depending on what you need, cant you just overlay another texture at the position where your ray hit using gdscript instead of shader?

    Would help if you atleast had some code to work with posted here so we could see where is bob?

    Id start with this https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
    there is an example for what you look

    const RAY_LENGTH = 1000
    
    func _physics_process(delta):
    	var space_state = get_world_3d().direct_space_state
    	var cam = $Camera3D
    	var mousepos = get_viewport().get_mouse_position()
    
    	var origin = cam.project_ray_origin(mousepos)
    	var end = origin + cam.project_ray_normal(mousepos) * RAY_LENGTH
    	var query = PhysicsRayQueryParameters3D.create(origin, end)
    	query.collide_with_areas = true
    
    	var result = space_state.intersect_ray(query)

    You just need to decide how to get the ray, either from camera or raycast - could be mouse event.