Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
0.8.4:normalmap-material [2022/06/15 19:34] admin0.8.4:normalmap-material [2022/06/17 10:45] (current) – [Normal Maps] admin
Line 4: Line 4:
 The **TGorillaNormalMapMaterialSource** is inherited from TGorillaDefaultMaterialSource, supports multiple light sources and enables normal mapping functionality in vertex- and fragmentshader: **GORILLA_GLSL_DEFINE_NORMALMAP** The **TGorillaNormalMapMaterialSource** is inherited from TGorillaDefaultMaterialSource, supports multiple light sources and enables normal mapping functionality in vertex- and fragmentshader: **GORILLA_GLSL_DEFINE_NORMALMAP**
  
 +{{:0.8.4:mat_normalmap.jpg?nolink|}}
 +
 +===== Definition =====
 + 
 In 3D computer graphics, normal mapping (or Dot3 bump mapping) is a technique used for faking the lighting of bumps and dents – an implementation of bump mapping. It is used to add details without using more polygons. A common use of this technique is to greatly enhance the appearance and details of a low polygon model by generating a normal map from a high polygon model or height map. In 3D computer graphics, normal mapping (or Dot3 bump mapping) is a technique used for faking the lighting of bumps and dents – an implementation of bump mapping. It is used to add details without using more polygons. A common use of this technique is to greatly enhance the appearance and details of a low polygon model by generating a normal map from a high polygon model or height map.
  
Line 9: Line 13:
  
 [source: https://en.wikipedia.org/wiki/Normal_mapping] [source: https://en.wikipedia.org/wiki/Normal_mapping]
 +
 +===== In General =====
  
 The shading model configured by default is the Blinn-Phong algorithm. The shading model configured by default is the Blinn-Phong algorithm.
Line 14: Line 20:
 Using this material source will provide a new published property called **NormalMap**. Using this material source will provide a new published property called **NormalMap**.
 It also supplies the optional **DisplacementMap** property to apply a vertex manipulation texture. It also supplies the optional **DisplacementMap** property to apply a vertex manipulation texture.
 +
 +===== Normal Maps =====
 +
 +Using normal maps is quite easy. You can find example textures everywhere and many graphic tools like Photoshop or GIMP are able to build them.
 +
 +They have a blueish-greenish look, like this example:
 +
 +{{:0.8.4:brick-n.jpg?nolink|400}}
 +
 +__WARNING:__ Because Gorilla3D is using OpenGL you have to be careful with the source. NormalMaps are different between OpenGL and DirectX.
 +In a naive way they are flipped. But the result can be very different.
 +
 +__NOTICE:__ We do only support normal maps for OpenGL. In case you have a DirectX normal map in your texture set, you need to convert it yourself.
 +
 +For conversion have a closer look at this article: [[https://help.ambientcg.com/02-Using%20the%20assets/Normal_map_styles.html#:~:text=Editing%20the%20map%20itself,color%20channel%20and%20invert%20it.]]
 +
 +===== Example =====
 +
 +<file pascal>
 +uses
 +  Gorilla.Material.NormalMap;
 +  
 +var FNormalMapMaterial : TGorillaNormalMapMaterialSource;
 +
 +FNormalMapMaterial := TGorillaNormalMapMaterialSource.Create(GorillaViewport1);
 +FNormalMapMaterial.Parent := GorillaViewport1;
 +FNormalMapMaterial.Texture.LoadFromFile('layingrock-c.jpg');
 +FNormalMapMaterial.NormalMap.LoadFromFile('layingrock-n.jpg');
 +
 +FNormalMapMaterial.NormalIntensity := 1.0;
 +</file>
 +