Why Custom Split Normals Data Causes Weird Shadows And Shading In Blender

What are Custom Split Normals and Why Do They Cause Weird Shading?

Custom split normals refer to a Blender feature where vertex normals can be customized on a per-face level instead of being averaged across an entire mesh. This allows for finer control over shading and can help avoid smoothing artifacts. However, incorrectly configured custom split normals can result in weird, unexpected shading issues like sharply split shading across edges and incorrect or flickering shadows.

Definition of Custom Split Normals

Normals are vertex attributes that define the direction a surface is facing, which is used for accurate lighting and shading calculations in 3D graphics. By default in Blender, vertex normals are averaged so that all connected geometry shares smoothed shading based on interpolated normals.

With custom split normals enabled, the vertex normals can be customized per face rather than averaged with surrounding geometry. This allows faces within the same mesh to have independent shading based on their individual configured normals rather than the smoothed interpolated normals.

How Custom Split Normals Affect Shading

Enabling custom split normals allows configuring different normals for adjacent faces, which can lead to sharply split shading between faces meant to share smoothed geometry. If face normals drastically differ despite logically being part of the same surface, it can look like there is a sudden split in the lighting and shading.

Custom split normals also affect shadows, as face normals influence the direction shadows are cast. Faces with misconfigured custom normals may cast shadows in strange directions compared to surrounding geometry or have flickering shadows as the face normal differences cause precision issues in shadow calculations.

When to Use Custom Split Normals

Using custom split normals can be beneficial when you intentionally want geometry within the same mesh to have distinct shading differences, such as for styled cel-shaders with crisp lighting transitions. This avoids having to split geometry into separate objects just for shading differences.

They can also help reduce smoothing artifacts on meshes where averaged vertex normals cause unintended rounded shading across sharp edges or corners. Custom split normals allow sharp edges to remain shaded sharply instead of blending.

Fixing Shadow and Shading Issues Caused by Custom Split Normals

Identifying Issues Caused by Custom Split Normals

If a mesh has strange, unexpected jumps in lighting across the surface without obvious topology differences, it may signal issues with custom split normals. Likewise flickering shadows not aligned with surrounding shadows may indicate custom split normal problems.

Zooming in close, you can visually inspect for odd outright splits between face shading at edges that should logically share smoothed normals. You can also enable the “Face Normal Display” overlay in Blender to visually debug face normals.

Disabling Custom Split Normals

The simplest fix is to disable custom split normals altogether, which reverts back to averaged vertex normals for smooth shading across edges and faces. Select the problematic mesh object, then under Object Data Properties > Geometry Data, disable “Auto Smooth” and “Custom Split Normals”.

This will revert to default calculated vertex normals averaged across connected geometry. While this eliminates the potential of custom normal issues, it removes the added control they provide and may reintroduce unwanted smoothing.

Recalculating and Optimizing Normals

Instead of fully disabling custom split normals, you may want to keep them for added control but fix incorrect face normals causing issues. In Edit Mode, select all faces then press Ctrl + N to have Blender recalculate the face normals.

For better oriented, optimized normals you can use the “Average Normals” modifier to average out any irregularities across multiple faces. This helps align normals cleanly for proper shading while keeping custom splits.

Using Auto Smooth to Improve Shading

A common cause of custom normal shading issues is simply from inadequate “Auto Smooth” angle thresholds. Auto Smooth blends normals between adjacent faces when edge angles are below the set threshold. Increase the angle degrees in Object Data Properties > Normals to smoothly blend more geometry while allowing sharp edges to remain split.

Higher auto smooth thresholds and optimized normals via the techniques above can often fix many shading issues without fully abandoning custom split normals and losing granular control.

Custom Split Normal Best Practices

When utilizing custom split normals it’s important to apply them judiciously and debug carefully to avoid unintended consequences. Below are some best practices.

  • Enable Auto Smooth at reasonable thresholds complementing geometry edges
  • Verify face normals are aligned as expected in Face Normal Display mode
  • Recalculate normals then average split differences with Average Normals modifier
  • Edge split modifier can sharpen edges causing unwanted blending
  • Model cleanly with good topology flow to allow proper auto smoothing

Taking care to analyze face normals, averaging differences, and allowing compliant auto smooth thresholds before resorting to fully disabling custom split normals gives exceptional control with reduced artifacts.

Example Blender Code for Managing Custom Split Normals

Here is some example Python code for interacting with custom split normals data in Blender scripts:

import bpy

# Access mesh custom normal data layer  
mesh = bpy.context.object.data
custom_normals = mesh.has_custom_normals

# Enable/disable custom normals
mesh.use_auto_smooth = True
mesh.has_custom_normals = True 

# Recalculate normals with custom data preserved 
bpy.ops.mesh.normals_make_consistent()

# Average adjacent face normals
mod = bpy.context.object.modifiers.new("AverageNormals", 'AVG_NORMALS')

# Retrieve normal vectors 
mesh.polygons[0].normal # Face 1 normal
mesh.loops[0].normal # First loop normal

# Set custom normal  
mesh.polygons[0].normal = (0.0, 0.0, 1.0) 

# Display normals
bpy.context.space_data.overlay.show_face_orientation = True

Having granular access to configure face normals in code along with utilities like averages and recalculations provides a great deal of flexibility to leverage custom split normals.

Leave a Reply

Your email address will not be published. Required fields are marked *