____ _ _ __ _ ____ _ / ___|| |__ (_)/ _| |_ / ___|___ | | ___ _ __ \___ \| '_ \| | |_| __| | | / _ \| |/ _ \| '__| ___) | | | | | _| |_ | |__| (_) | | (_) | | |____/|_| |_|_|_| \__| \____\___/|_|\___/|_| Change the color of any material, no custom shaders needed. Also, shift the camera view. Version 2.0.0 Copyright 2016-2020 Zen Fulcrum LLC https://assetstore.unity.com/packages/tools/particles-effects/shift-color-62162 Need help? https://zenfulcrum.com/contact =========== Quick Start =========== Drop an object with some sort of textured material into a scene. Attach the "Material Color Changer" script to the object. Tweak settings as desired. (Changes are visible when previewing and in play mode.) -or- Create a new scene. Attach the "Camera Color Changer" script to the camera. Tweak settings as desired. (Changes are visible in the game view.) =========== Adjustments =========== There are a number of color-adjusting options available. - Options are applied top-to-bottom, with the lowest enabled item having final say in coloration. - Entire sections can be enabled/disabled by checking/unchecking the checkbox at the top of each section. - You can use the included material, TestPattern, to better understand how a given option affects coloration. Here's what the various controls do: - Basic Adjustments - This allows you to make quick, general adjustments to all colors. Controls are fairly straightforward - if you're not sure what a slider will do, just grab it and see what it does! (Most adjustments have tooltips, too; hover your mouse over the control.) - Color Swaps - You can use this to replace all of one color with another color. For example, you can configure it to replace all the red with green, while leaving blue and orange alone. - You add as many colors swaps as you want. Typically you'll want to start by setting the size to 1 or 2, then set the old/new colors and adjust the settings to your liking. - Hover over the various properties for explanatory tooltips. - Changes are applied incrementally. Each element will act on the results of the previous color change. - Color Isolation - This filter allows you to apply the classic "everything but red turns gray" look. - Hover over the various properties for explanatory tooltips. - Curves - This filter allows you to apply a color ramp/remapping for HSV, RGB, and alpha values. - You can use this for fine color adjustments, or to apply a complete color rework. - There's a lot of fun things you can do with these, here are just a few ideas: - Set the R, G, and B curves to slope from 1 at the left to 0 at the right. This will invert the image. - Bend the middle of the Saturation curve downward to "gray out" all but the strongest colors. - Change the Hue curve to be a flat line, then add a small bump in the middle. Your target will be a single color except a few certain shades. - Alternatively, remap the Hue so it goes from .5 on the left to 1 on the right. This will recolor your target so it's primarily red and blue. - Check out the documentation here for more information on working with curves in the Unity Editor: http://docs.unity3d.com/Manual/script-ColorCorrectionCurves.html - LUT - As a final step, you can apply a look-up texture/look-up table to the target. A LUT can remap any given color to another color and is by far the most powerful of the tools here. - The effect is very similar to the "Color Correction Lookup" script included with Unity's Standard Assets, but: - It can be applied to materials. - You can fade LUTs in/out and even crossfade between two different LUTs. - It works on OpenGL ES targets such as Android and WebGL. - The Demo/LUTs folder contains a handful of LUTs you can get started with. - This folder includes some LUTs provided courtesy of Cinema Suite Inc. You can get a whole bunch more by grabbing their Cinema Themes 2 package here: https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/cinema-themes-2-color-grading-luts-library-20394 - How do LUTs work and how can you make your own? Read here: http://docs.unity3d.com/Manual/script-ColorCorrectionLookup.html - Use the Crossfade slider to smoothly apply or remove a LUT over time, or, with two LUTs assigned, to fade between the LUTs. ======= General ======= - The MaterialColorChanger - At runtime the textures of the material are copied and altered. A new material with these textures is used in place of the original. - The changer will change common RGB texture names (_MainTex, _EmissionMap, etc.). All other textures will be left alone (_BumpMap, _ParallaxMap, etc.). - Non-texture properties (floats, vectors, colors) are left unchanged. - The list of which textures are considered "RGB" can be found near the top of ColorChanger.cs. Edit the list or call ColorChanger.coloredTextureNames.Add("_MyCustomTex") to add your own custom properties to the list. - Be sure to make changes before recoloring any materials. - New textures are created when you change colors. If you plan to have a large number of objects recolored with the same parameters use a SharedMaterialColorChanger to save texture memory. See the documentation in SharedMaterialColorChanger.cs for an explanation on how to use it. - Material Preview - When adjusting parameters on a MaterialColorChanger, a live preview will be shown. You can also enable the preview without adjusting parameters by clicking the "Preview" button in the inspector. - To disable the preview deselect the object or click "Disable Preview". - Due to technical limitation in the Editor, the following will not work correctly when preview is enabled: Duplicate, delete, remove component, change material, apply prefab. Disable preview mode before taking any of these actions. - By default, we'll allocate "normal" textures when recoloring the material. If you are changing color parameters often (~once a frame) enable the "Use Render Textures" option, which will perform much, much faster, but uses render texture memory to back the generated materials. - The CameraColorChanger - This functions like a normal camera image effect. For more information on the Standard Image Effects see http://docs.unity3d.com/Manual/comp-ImageEffects.html - Has the same color adjusting options as MaterialColorChanger. - Tips/misc - Most texture compression algorithms cut corners by making changes that are difficult to see visually. When we alter the coloration, however, those assumptions can be invalidated. If your image appears "blocky" or "low quality" with certain effects applied, consider adjusting or disabling compression on that texture. (Compression in Unity is on by default.) - Most of the color adjustments use shaders partially built in Shader Forge (http://www.acegikmo.com/shaderforge/). The ShaderForge folder contains editable shaders; these aren't used. The Resources/Recolor folder contains the actual shaders, which are modified from the generated versions. =========== Programming =========== A number of APIs are available for scripting color changes with. Some useful classes you may want to look into: - ColorChanger - Contains color alteration settings. - Contains functions for changing the color of individual textures. You can use it directly to make color changes/adjustments to any texture you happen to have your hands on. - Call Apply after making any settings changes and Destroy when you are done using it. - SharedMaterialColorChanger - Consumes a ColorChanger and creates and manages recoloring materials. - Can be used to share a single recolored material among many objects automatically. Take a look at the comments at the top of the file. - Call Destroy when you are done using it. - MaterialColorChanger - MonoBehaviour that changes the color of renderers it's attached to. - Disable the MaterialColorChanger before swapping materials at runtime. Re-enable it to alter the new material. - When altering materialColorChanger.colorSettings (or any ColorChanger instance) call colorSettings.Apply() when you are done making changes. If you don't call Apply, not all of your changes may appear on the recolored items.