Is ShaderMaterial affected by AmbientLight or DirectLight?

If so, is it default behavior or what do I have to set so it will be affected?

It is not the default behavior, you will (at least) need to either include snippets of code from THREE.ShaderChunk (as well as some defines) to your custom shader code or write your own code to calculate illumination.

The specifics depend on what material (illumination type) you are trying to replicate.

You can use onBeforeCompile to study the high level structure of the code THREE creates for specific material. You can also look at the final low level code here (see dev console output):

for logged shader objects, right click on the string and choose “copy string content” to copy the full shader code.