N
N
Nekit Medvedev2020-03-11 03:20:50
Shaders
Nekit Medvedev, 2020-03-11 03:20:50

What is the meaning of dot product in Cel Shading?

I can not understand the principles of the implementation of Cel Shading.
To implement Cel Shading, the scalar product between the normal of the surface (polygon) and the light source is calculated.
The scalar product, in turn, depends on the length of the normal vector, the vector to the light source and the angle between them.
Let's say why the distance to the light source (the length of the vector) is used is understandable, but what kind of light beam falling on the surface (polygon) is used to calculate the angle?
And what is the length of the polygon normal vector, what does it depend on?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2020-03-11
@NIKROTOS

I will answer to the point.
A normal always has a length of 1. Sometimes it is actually a vector perpendicular to the polygon - if we want to light a flat polygon as a plane. Sometimes we want to create the impression of a curved surface from flat polygons and therefore we make (for example, by interpolation or a special texture, the so-called normal map) a continuous field of normals.
A ray vector is a unit vector (or whatever length you want) from the light source to the point you're working with. (Well, or vice versa, depending on how the formula is written.)
If the length of the ray vector is also 1, then the result will be [−1…1]. If it is less than 0 (if the normal is external, and the beam comes from the light source), then we have a coefficient, how many times the actual illumination is less than that provided by the light source. If more, the surface is in its own shadow. (The calculation of drop shadows is a separate and complicated issue.)
It has nothing to do with goal shading, it's generally a lighting base.

S
Sergey Pankov, 2020-03-11
@trapwalker

To implement Cel Shading, the scalar product between the normal of the surface (polygon) and the light source is calculated.
which ray of light falling on the surface (polygon) is used to calculate the angle?

For each point on the surface, this ray is different. Accordingly, for each point, you can calculate your own scalar product of the beam, the source and the normal.
There are also so-called normal maps, when a special texture layer is applied to a smooth polygonal model, each point of which is a normal vector at the corresponding point of the model. So you can provide a smooth box with a texture that will look different under different directions .
In this case, the flat polygon will have its own normal at each point, and they can all be different. Accordingly, at each point of the surface and the direction to the source is different.
what is the length of the polygon normal vector, what does it depend on?

Well, by definition, a normal is a straight line, perpendicular (in this case) to a surface. A line has no length. But the normal vector is already a unit vector. Technically, nothing, probably, prevents TAKE not a single, but a vector of any arbitrary length. You can probably even think of why someone might need it. If you need something, use it.
It is probably interesting to play around by multiplying the normal vector by the values ​​of the second derivative at the corresponding points on the surface. There will be a peculiar measure of surface curvature at a point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question