<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKTexture/generatingNormalMap(withSmoothness:contrast:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKTexture(im)textureByGeneratingNormalMapWithSmoothness:contrast:"
  },
  "title" : "generatingNormalMap(withSmoothness:contrast:)"
}
-->

# generatingNormalMap(withSmoothness:contrast:)

Creates a normal map texture by analyzing the contents of an existing texture.

```
func generatingNormalMap(withSmoothness smoothness: CGFloat, contrast: CGFloat) -> Self
```

## Parameters

`smoothness`

A number between `0.0` and `1.0` indicating how much the texture should be smoothed before the normal map is generated. A value of `0.0` means that the texture is not smoothed at all before being processed.

`contrast`

A value used to magnify the effect of the generated normal map. A value of `1.0` indicates no magnification is applied.

## Return Value

A new texture object that contains a normal map.

## Discussion

A normal map texture is similar to an image texture, but instead of holding image data to be displayed onscreen, every texel represents a normal vector. Normal map textures are used to simulate 3D lighting (see the [`normalTexture`](/documentation/SpriteKit/SKSpriteNode/normalTexture) property) or used to generate velocity values (see [`velocityField(with:)`](/documentation/SpriteKit/SKFieldNode/velocityField(with:))).

You can create normal maps in two different ways. First, you can take an existing image map and use it to generate a normal map. SpriteKit filters the color data in the texture and then uses it to generate a map based on pixel contrast. Alternatively, you can load a regular image file but treat it as a normal map. To do this, provide a texture with 32-bit `RGBx` pixel data. Each component’s 8-bit integer value is mapped to a floating point number between the values of `-1.0` and `1.0`. Use a `0` to represent `-1.0f`, a value of `127` to represent `0.0`, and a value of `255` to represent `+1.0`.

The image below shows two sprite nodes both with the same texture. The node on the right has a normal map from the same noise texture generated using the [`generatingNormalMap()`](/documentation/SpriteKit/SKTexture/generatingNormalMap()) method.

![Comparison of sprites with and without normal mapping](images/com.apple.spritekit/media-3020490@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)