An optical sensor based on CMOS technology and comprising: • a semiconductor substrate (21,31); • an array of photocells (2,3), each of which - includes a respective photodetector active area (11,12,22,32) that is formed in the semiconductor substrate (21,31) and is exposed on a given planar surface of said semiconductor substrate (21,31), and - is designed to provide a respective output electrical signal related to incident light impinging on the respective photodetector active area (11,12,22,32); • a multilayer structure (23,33), that includes metal and dielectric layers and is formed on the given planar surface of the semiconductor substrate (21,31); and • light shielding means (14,15,24,35), that are formed in or on the multilayer structure (23,33) and are made of one or more materials reflecting and/or absorbing incident light impinging on said light shielding means (14,15,24,35); wherein each photodetector active area (11,12,22,32) is associated with a corresponding optical path (26,36) extending through the light shielding means (14,15,24,35) and directed towards said photodetector active area (11,12,22,32) to allow incident light with incident direction falling within a given direction range to reach said photodetector active area (11,12,22,32); characterized in that: • all the photocells (2,3) are connected in parallel to provide an overall output electrical signal related to incident light impinging on all the photodetector active areas (11,12,22,32); and • all the optical paths (26,36) are parallel to a given direction thereby causing all the photodetector active areas (11,12,22,32) to be reached by incident light with incident direction parallel to said given direction. • a semiconductor substrate (21,31); • an array of photocells (2,3), each of which - includes a respective photodetector active area (11,12,22,32) that is formed in the semiconductor substrate (21,31) and is exposed on a given planar surface of said semiconductor substrate (21,31), and - is designed to provide a respective output electrical signal related to incident light impinging on the respective photodetector active area (11,12,22,32); - includes a respective photodetector active area (11,12,22,32) that is formed in the semiconductor substrate (21,31) and is exposed on a given planar surface of said semiconductor substrate (21,31), and - is designed to provide a respective output electrical signal related to incident light impinging on the respective photodetector active area (11,12,22,32); • a multilayer structure (23,33), that includes metal and dielectric layers and is formed on the given planar surface of the semiconductor substrate (21,31); and • light shielding means (14,15,24,35), that are formed in or on the multilayer structure (23,33) and are made of one or more materials reflecting and/or absorbing incident light impinging on said light shielding means (14,15,24,35); • all the photocells (2,3) are connected in parallel to provide an overall output electrical signal related to incident light impinging on all the photodetector active areas (11,12,22,32); and • all the optical paths (26,36) are parallel to a given direction thereby causing all the photodetector active areas (11,12,22,32) to be reached by incident light with incident direction parallel to said given direction.