Not so long ago, I came across a lesson on Normal Mapping (well, or Bump Mapping) and decided to repeat ..

Well, there is an interesting moment when normals are calculated with Bump corrections from the texture. This happens ..

5 line in normal to go to the new data from the bump of the card but it is not overwritten why?!

If someone owns the information would be glad to listen!

vec3 normal = normalize(fs_in.Normal); if(normalMapping) { // Obtain normal from normal map in range [0,1] normal = texture(normalMap, fs_in.TexCoords).rgb; //Она же должна перезаписаться !!!!?? // Transform normal vector to range [-1,1] normal = normalize(normal * 2.0 - 1.0); } 

enter image description here enter image description here enter image description here

    1 answer 1

    Most likely you need to combine the texture normals with the model normals. Because in the texture, the normals are set relative to the surface normal calculated in the usual way (this texture usually has a light blue color R = 0.5 G = 0.5 B = 1.0, which corresponds to X = 0 Y = 0 Z = 1). For combination, you also need information about the orientation of the texture (where is it before, where is right-left). This is given by TBN vectors. In primitive tutorials this is often omitted, since the render goes to a flat polygon located perpendicular to the camera (TBN thus degenerates into "zero").

    In general, attach a normal texture image to the question and try to find a more complete tutorial.

    • You probably did not understand the essence of the question. I asked why the texture function does not overwrite the data in normal placed early ones. ps everything works for me the proof added above together with normal map. - hays
    • @hays Why do you think so, how should overwriting look like? - Kromster
    • well, because the assignment sign is indicated, but we don’t say * = or + = the data should disappear and new textures should be placed - hays
    • @hays Again, why do you think the current behavior is wrong? Why do you think that "the texture function does not overwrite the data in normal"? - Kromster
    • It is experimentally proven if it overwrites normal textures instead of normals, and if you specify normal = texture (normalMap, fs_in.TexCoords) .rgb, you get a combination of 'world' normals with a normal map from a texture - hays