An optical device, comprising: diffraction grating made of dielectric optical material with an index of refraction n and comprising a first surface with a structure having a structure height h and a structure period d, and a second surface; wherein the first surface is covered by hydrophobic material which reduces wettability of the diffraction grating for pre-selected liquids; uniform liquid layer with the index of refraction k comprised of one of said pre-selected liquids, said uniform liquid layer is disposed on said first surface of said diffraction grating, wherein parameters of said optical device are chosen such that: said uniform liquid layer Is configured not to enter an air pocket area formed below a top of said structure when there is no electric field created in said uniform liquid layer, said uniform liquid layer is configured to enter by a predetermined value said air pocket area formed below the top of said structure, due to a capillary effect and increased wettability of said first surface, when there is a predetermined electric field created in said uniform liquid layer, for changing a diffraction efficiency of the diffraction grating for varying an optical intensity of an optical beam transmitted or reflected by said diffraction grating; and an electrode layer of electrically conducting material formed on said second surface, configured to create said electric field; the optical device being characterized in further comprising means for varying said predetermined electric field, for further changing the predetermined value by which said uniform liquid layer enters said air pocket area causing a further change of the diffraction efficiency of the diffraction grating, therefore varying the optical intensity of the optical beam propagating through or reflected from the diffraction grating, and in that said indexes of refraction n and k are substantially equal. diffraction grating made of dielectric optical material with an index of refraction n and comprising a first surface with a structure having a structure height h and a structure period d, and a second surface; wherein the first surface is covered by hydrophobic material which reduces wettability of the diffraction grating for pre-selected liquids; uniform liquid layer with the index of refraction k comprised of one of said pre-selected liquids, said uniform liquid layer is disposed on said first surface of said diffraction grating, wherein parameters of said optical device are chosen such that: said uniform liquid layer Is configured not to enter an air pocket area formed below a top of said structure when there is no electric field created in said uniform liquid layer, said uniform liquid layer is configured to enter by a predetermined value said air pocket area formed below the top of said structure, due to a capillary effect and increased wettability of said first surface, when there is a predetermined electric field created in said uniform liquid layer, for changing a diffraction efficiency of the diffraction grating for varying an optical intensity of an optical beam transmitted or reflected by said diffraction grating; and an electrode layer of electrically conducting material formed on said second surface, configured to create said electric field; the optical device being characterized in further comprising means for varying said predetermined electric field, for further changing the predetermined value by which said uniform liquid layer enters said air pocket area causing a further change of the diffraction efficiency of the diffraction grating, therefore varying the optical intensity of the optical beam propagating through or reflected from the diffraction grating, and in that said indexes of refraction n and k are substantially equal.