Class NormalMapGenerator
Generates normal map from heightmap using GPU compute shader. Based on EU5's approach - calculates gradients on GPU for maximum performance.
Algorithm:
- Sample heightmap at each pixel and 4 neighbors (LRUD)
- Calculate gradients using central difference
- Construct normal vector from gradients
- Pack normal into RG8 texture (XZ components, reconstruct Y in fragment shader)
Result: High-quality lighting with depth perception at any zoom level
public class NormalMapGenerator
- Inheritance
-
objectNormalMapGenerator
Constructors
NormalMapGenerator()
public NormalMapGenerator()
Methods
GenerateNormalMap(Texture2D, Texture2D, float, bool)
Generates normal map from heightmap texture using GPU compute shader. CRITICAL: Follows GPU coordination patterns from unity-compute-shader-coordination.md
public void GenerateNormalMap(Texture2D heightmapTexture, Texture2D normalMapTexture, float heightScale = 10, bool logProgress = false)