RS RESCUE for Cinema 4D R23
Convert Redshift scenes back to native C4D materials and lights - no Redshift license needed
============================================================================================

SHARED AS-IS. Free to use, change and pass on (MIT License, see LICENSE.txt).
No support is offered and no warranty is given. ALWAYS RUN IT ON A COPY OF YOUR PROJECT.


WHO THIS IS FOR
---------------
You have Cinema 4D scenes whose materials were converted to Redshift, and Redshift
no longer loads (for example you dropped the subscription, or you use a perpetual
C4D license). The materials show as blank "?" placeholders and C4D warns that
plugins are missing.

Tested on: Cinema 4D R23 (perpetual license), macOS. Other versions may work but
have not been tried.


WHAT IS IN THE FOLDER
---------------------
rs_rescue_r23.py         The main script. One run per project.
find_rs_lights_r23.py    Small helper: finds dead Redshift objects buried anywhere
                         in a scene, selects them, and offers to delete them.
rebuild_cameras_r23.py   Small helper: rebuilds cameras whose viewport cone vanished
                         after conversion (RS Rescue already does this itself; this
                         is for scenes you converted another way).


HOW IT WORKS
------------
The script cannot read Redshift's node data (nothing can, without Redshift running).
Instead it rebuilds each material from clues that survive:

  1. The project's "tex" folder: images named after the material, e.g.
     "STONE 249 Color.jpg" / "STONE 249 Bump.jpg" become a native material with
     Color / Bump / Normal / Alpha channels. (Redshift's own converter usually
     leaves textures named this way.)
  2. A library of original model files (optional): point it at your folder of
     downloaded assets (TurboSquid, Xfrog, etc.). If an original .c4d there has a
     native material with the same name, that material is copied in, already wired.
  3. Otherwise, a stand-in guessed from the name: glass, chrome, stainless, rubber,
     "Gray 90%", "Color (r,g,b)", LED, lamp, water... anything else becomes neutral gray.

It then re-points every material tag, deletes the dead Redshift placeholders,
replaces Redshift lights with native lights in the same position, rebuilds
affected cameras, removes dead Redshift tags and switches Render Settings to Physical.
Everything is one undo step. A full report is printed to the Console.


WHAT IT CANNOT DO
-----------------
- Procedural node materials (noise, ramps, blends, color math - no image files):
  the recipe only existed inside Redshift's node graph. These become stand-ins and
  are listed under STAND-INS in the Console so you can rebuild them by hand.
- Generic material names (Default, Material, Texture4, Metal 5, Glass...) are never
  borrowed from the library on purpose - too likely to grab the wrong material.
  They get stand-ins.
- Light brightness, colour and type can't be read back. Lights are placed correctly;
  the type is guessed from the name (Dome -> Sky + HDR from tex, Sun/Infinite,
  Spot, Point, else Area). Adjust intensity afterwards.
- Redshift proxies (.rs files) cannot be converted.


HOW TO USE
----------
1. Duplicate the whole project folder (keep its "tex" folder with it). Open the COPY.
2. Click OK on the "plugins are missing" warning. Do NOT save the file yet.
3. Open the Console (Shift+F10) and clear it.
4. Run rs_rescue_r23.py from the Script Manager (Extensions > Script Manager).
5. It asks whether to borrow materials from a folder of original model files.
   Yes = pick your asset folder (subfolders are searched). No = skip.
   The first run over a big library is slow; the result is cached, later runs are quick.
6. A dialog lists the Redshift leftovers (lights, cameras, tags, render settings).
   Read the Console list, then click Yes.
7. Check the result, especially the STAND-INS listed in the Console.
8. File > Save As, under a new name. Close and reopen: no "missing plugins"
   warning means the file is fully Redshift-free.

Tip: if you replace the script file with a newer version, quit and restart C4D
so the Script Manager doesn't keep running the old copy.


SETTINGS (top of rs_rescue_r23.py, edit in any text editor)
------------------------------------------------------------
LIBRARY_FOLDERS        Your asset folder(s), so it never asks, e.g.
                       ["/Volumes/MyDrive/3D Assets"]. Empty = ask each run.
COLOR_/BUMP_/NORMAL_/ALPHA_SUFFIXES
                       Filename endings that mark each texture channel.
UNKNOWN_LIGHT_KIND     Type for lights whose name gives no hint: "area", "spot",
                       "omni" or "distant".
TURN_OFF_LUMINANCE     True = switch off Luminance on borrowed materials (many
                       downloaded models ship with it on), except glowing things.
REBUILD_CAMERAS        True = rebuild cameras carrying Redshift leftovers.
GRAY_PERCENT_IS_DARK   True = "Gray 90%" means 90% dark.
GENERIC_NAMES          Names that are never borrowed from the library.
PROXY_WORDS            Dead Redshift objects with these words in the name are left alone.
