Are these baked light cards? Or is there any technology that allows you to do it programmatically?
1 answer
This shading effect on your picture is called Ambient Occlusion or AO.
It consists in shading surfaces based on information about objects (surfaces) nearby.
There are a lot of AO implementations, for example, a “post effect” in a fragmentary shader ( Screen Space Ambient Occlusion or SSAO) based on information about pixel position and normals. Relatively simple and cheap, which is why it is popular, does not depend on the complexity of the scene .
The disadvantages of the algorithm include the impossibility of processing semi-transparent surfaces + the impossibility of hardware anti-aliasing ( antialiasing ).
SSAO can be attributed to the technique of the so-called deferred rendering or deferred rendering (shading), this is the focus when the so-called G-Buffer is formed into the screen on the screen, which is a few render textures in which the frame is drawn, except for the color in each value pixel information is recorded on:
xyz pixel relative to camera
surface normal vector at this point
any other information (for example, material type, depth, and so on)
Subsequently, a single triangle is drawn on top of the entire screen, so that it covers the entire screen. This is necessary to call the fragment shader for each pixel. All the magic happens in the shader. There, information from the newly formed g-buffer is taken and a frame with shading is formed.
The above is a common part for a variety of algorithms for lighting, shading, image filtering and other strange tricks like screen space reflections operating in screen space. those. their complexity grows not with the complexity of the scene but with the size of the frame.
SSAO
If we take the sum of all photon vectors from the hemisphere as the point illumination:
and suppose that if there is a surface or object nearby, then the photons do not pass through it, then it turns out that they can be ignored when calculating the illumination.
Improving the result is possible by taking into account the normals for processing flat surfaces:
It also gives good results not simple Monte Carlo on neighboring pixels, but for example, poisson sampling :
Here is an example of screen space AO for three.js .
PS: look here, later I will do a living example ..






