KatsBits Community

Circular Reference in Texture Stack error

kat · 1 · 20657

0 Members and 1 Guest are viewing this topic.

Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 3140
    • KatsBits

How to fix the "Circular reference in texture stack" error message when baking Normal maps to low resolution meshes.

Problem
When baking a Normal map from models where the low resolution mesh has been UV mapped and textured, the "Texture Bake" process will fail showing an incomplete render in the UV/Image Editor and an error message in the main application Header/Info bar which reads "Circular reference in texture stack", temporarily replacing text relating to the Scene (note: for Blender 2.64 to 2.67 the message displayed read as "Feedback loop detected", else for Blender 2.68 and above it reads as "Circular....").

Information
Due to a change introduced in Blender 2.64, the Texture Bake process for rendering Normal Maps requires an empty Texture slot[1] for successful map generation. If not and the slot contains data, usually in the form of a bitmap image or generated UV Grid mapped to the UV/object, the process fails because it cannot overwrite data already present in the slot (the slot is occupied); essentially the process 'loops' because it's trying to both 'read' data that's already present, and 'write' (overwrite) at the same time (as was the previous behavior available in Blender 2.63 and below). In other words the process of baking Normal maps is akin to generating a 'UV Grid' texture, the 'virtual' texture data (the results of a bake or 'generation process') is the 'image' associated with the Texture slot.

Solution
To fix the problem two steps should be taken. 1) if the low resolution mesh has a Texture slot active in Texture Properties and it contains a texture (bitmap) image, deactivate it by clicking the checkbox to the right of the listing (shown below, third from the top). And 2) create a new slot, set it to "Image or Movie" and make sure it's selected (active) before then baking the Normal map (shown below, third from the top again). This should then allow Blender to generate the temporary data it needs to the empty slot which can be saved once the process is complete. Once the image is saved it should not be necessary to repeat the above, as data can be rewritten to the same slot and saved as required [2].

Section of a low-resolution lantern mesh with UV and Texture (bitmap) assigned

When baking a Normal map from a high-resolution mesh, the process fails, displaying an incomplete map and error message "Circular reference in texture stack"

The 'fix' is to create a 'blank' or empty texture slot to which the temporary bake data can be written

When re-processed the bake completes and produces and Normal map that can then be saved (note discolouration in normal map is due to section of high resolution being left to one side for illustrative purposes).


[1] Content for game use typically has a Material containing THREE slots; 1) a Material, 2) a Texture, and 3) an Image slot. Within Blender, i.e. whilst working on a project, the latter, "3" can be virtual - a 'generated' UV Grid image, or 'real' - an actual bitmap. If the 'image' assigned to the Material is either a bitmap OR generate, the error will occur because the process cannot read/write to the Texture slot when it contains ANY data.

[2] The baking process fails because the slot is occupied. It is possible therefore to simply remove all references to there being an associated 'Image', be that an actual bitmap or generated UV Grid, and bake to the resulting empty slot. However, it's typically more convenient to simply add a new slot leaving it empty (don't assign a generated image or bitmap) and bake to it directly.