Normal maps and displacement maps

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
kubatp
Gnome
Posts: 353
Joined: Tue Jan 06, 2009 1:12 pm
x 7

Normal maps and displacement maps

Post by kubatp » Mon Jun 24, 2019 9:26 pm

Hello everyone,
this might be a bit newbie post, but I would like to be sure that I am doing everything right and I understand these two map types correctly.

Normal maps
  1. How are normal maps used in shader? Is it just a colour, which is taken from a prepared 2D sampler and according to the light direction, intensity of diffuse colour is calculated? If so and I am using directional light (sun), can I "bake" this "lit" directly into the textures (if I am not rotating these objects - e.g. terrain textures)? If I am rotating the terrain textures in 4 directions (0°, 90°, 180° and 270°) it won't work if it is baked, correct?
  2. How are normal maps usually created from a texture? Do you have any tips for certain tools? I know that Photoshop has functionality to create normal maps but it did not really work well for me.
  3. I am using atlas texture for terrain and the normal map of it would have the same UV coordinate as the atlas (in another sampler). Would it be worth to use 3D sampler or cube sampler in this case? Aka two "layers", in one would be the diffuse texture, in another would be the normal map. I hope it is understandable what I mean.
Displacement maps
  1. How do displacement maps work with shaders? Is it in fragment or vertex shader calculated?
  2. Are there any examples of using displacement maps in Ogre?
  3. Is there anything needed geometry-wise to use displacement maps? Any changes required of the actual meshes?
  4. Is there a significant drop of performance when using displacement maps?
I hope that these questions do not sound too dumb. I was really trying to watch some tutorials and videos about these and reading sources. I just want to be sure that I didnt omit anything.
Thank you.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1038
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 68

Re: Normal maps and displacement maps

Post by xrgo » Tue Jun 25, 2019 12:46 am

Hello!
Normal maps:
1. yes its stored as a color, but its not used like color, its used as a vector. Lets say you have a normal vector for a particular face/poly, in the pixel shader, when a pixel of that face gets processed we use the geometry normal (that comes from the vertex shader) and using the normal map information (sampled for that pixel using the corresponding uv) the normal vector gets rotated so it points to an another direction, the effect of this is like if the face (the pixel of that face) is actually facing another direction, so light is calculated with that in consideration... not sure if that make sense, maybe look for a video explaining it.. but in summary, you can bake the effect of the lighting+normals in to the albedo... but as soon as you move the camera or move a light its going to look really flat (that's what old games did)

2. usually they are baked from a high res model in a 3d software like blender, you can also obtain it from a bump map (its like a height map, but not so high), there are software that can obtain a normal map from any picture but that does not give very accurate results

3. yes, since normal maps are stored as color you can mix them with any other color textures so you can save some memory/samplers/performance

Displacement maps:
1. Vertex shader
2. I have some *very* basic support for them in my engine using ogre 2.2, I can share some code
3. yes! many polygons, the geometry should be very subdivided... this unless you (or someone) implement tessellation
4. many triangles! but in desktop that's usually not the bottleneck

cheers!
1 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 836
Joined: Sun Mar 30, 2014 2:51 pm
x 147
Contact:

Re: Normal maps and displacement maps

Post by paroj » Tue Jun 25, 2019 10:02 am

kubatp wrote:
Mon Jun 24, 2019 9:26 pm
Are there any examples of using displacement maps in Ogre?
yes, the bumpmap sample when using the torus mesh
0 x

kubatp
Gnome
Posts: 353
Joined: Tue Jan 06, 2009 1:12 pm
x 7

Re: Normal maps and displacement maps

Post by kubatp » Tue Jun 25, 2019 2:49 pm

Hello xrgo,
thank you very much for the answers! I think everything is clear.
0 x

Post Reply