**Toony Colors Pro 2** **Main Documentation** v2.9.10 - November 2023 ([See changelog](changelog)) © 2023 Jean Moreno jean.moreno.public+unity@gmail.com ================================================================================================================================ Welcome ======= Thank you for your interest in *Toony Colors Pro 2*! This is the main documentation. Other specific documents are available: - [Shader Generator 2 Documentation](shader_generator_2.html) - [Shader Generator 2 Tutorials](tutorials.html) --- *Toony Colors Pro 2* (abbreviated *TCP2*) is a collection of shaders and tools to help you give a *stylized look* to your Unity game or application. There are currently two base shaders to choose from: - Use the *Hybrid Shader 2*, which is a complete "ubershader" giving a lot of options out of the box to achieve various styles (*Built-in* and *URP* pipelines) - Use the *Standard PBS* shader, based on Unity's Standard shader, to give a stylized look to your PBS materials (*Built-in* render pipeline only) Advanced users will want to take a look at the [[Shader Generator 2]] to generate their own shaders, adding more features and allowing further customization. The [[Shader Generator 2]] is the most complex and powerful tool included with *TCP2*: if you ever feel too constrained or limited by the default shaders, then this is the way to go! Other [[tools]] are provided to help within your stylized pipeline: Shading Ramp Texture Editor, Smoothed Normals Utility... Here are some *examples of styles* that you can achieve with *Toony Colors Pro 2*: ![](images/__examples_cat_1.png) ![](images/__examples_cat_1b.png) ![](images/__examples_cat_2.png) ![](images/__examples_cat_2c.png) ![](images/__examples_cat_sketch_overlay.png) ![](images/__examples_cat_sketch.png) ![](images/__examples_cat_halftone.png) ![](images/__examples_cat_oldschool.png) ![](images/__examples_unitychan_1.png) ![](images/__examples_unitychan_3.png) ![](images/__examples_unitychan_2.png) ![](images/__examples_unitychan_manga.png) ![](images/__examples_unitychan_pastel.png) ![](images/__examples_unitychan_hologram_m.png) Upgrade Notes ============= Version 2.9.0 ------------- - The *Hybrid Shader 2* now replaces the old *Hybrid Shader*.
To facilitate the transition, a script will check for the presence of the old shaders in your project, and propose to automatically convert all your materials to using the new shader, and delete the old shader files afterwards.
If you decline, you can still run the tool again through the menu:
**Tools > Toony Colors Pro > Upgrade Materials > From Hybrid Shader 1 to Hybrid Shader 2** - The old shaders *Legacy/Desktop* and *Legacy/Mobile* have been entirely removed. You can migrate your materials using those old shaders to using the *Hybrid Shader 2* through this menu option:
**Tools > Toony Colors Pro > Upgrade Materials > From Legacy Desktop/Mobile to Hybrid Shader 2**
The script will convert all properties values, but note that the results won't exactly match what you had before, due to features differences in both shaders and how some things are calculated, like specular size or outline width. You may have manual modifications to do afterwards. Quick Start =========== The easiest way to get started is to assign either shader to a material: !!! **Toony Colors Pro 2 / Hybrid Shader 2** for full control over the stylized look **Toony Colors Pro 2 / Standard PBS** for using a PBS pipeline with limited stylization _(**built-in render pipeline only**)_ ...and start tweaking the values, that's it! ---------------------------------------------------------------- ## Hybrid or Physically-Based? Choosing between the two workflows might not be as easy as it seems. Physically-Based Shaders have been created to ease up artists' workflows: by setting up a material once, it is supposed to look good in any lighting and environment conditions by calculating a lot of light interactions automatically. The *TCP2 Standard PBS* shader was built on top of *Unity's Standard shader*, thus it inherits those automatic calculations, and some of the *constraints* that come with it, while still allowing some degree of *stylization* on top of it. Depending on your art style however, you might want to *not have any constraints at all*. In such cases, the *Hybrid Shader 2* should be preferred. Here is a pros/cons list that can help choosing between either workflow:
Hybrid Shader 2 Standard PBS
PROS CONS PROS CONS
***More control***: you can precisely tweak all values to get the exact look wanted ***Longer material setup***: more control means more parameters to adjust! ***Easier material setup*** similar to Unity's Standard shader, with additional stylization options ***Less stylization options***: features are unified and you can't selectively enable or disable one
***More Stylization***: enable the features you need (specular, rim light, etc.) and tweak them however you want ***Less consistency***: you may have to readjust material parameters so that they fit in each environment ***Works in all lighting settings***: no need to do further tweaks to materials once they're properly configured ***Limited value ranges***: you can't go too much outside the "physical" values and get extreme results (that's actually the whole point of PBS!)
***Better Performance***: that depends on the number of features enabled, but generally speaking the computation is less intense than a PBS shader ***Automatic mobile version***: the best shader optimizations are loaded internally depending on the target platform ***Higher Cost***: the Standard shader generally requires more GPU power than the Hybrid one
***Shader Generator***: more features to choose from, and get the ultimate stripped-down shader with just the code you need ***Stylization in 1 click***: the shader will automatically inherit parameters already defined for a material using Unity's Standard shader
The TL;DR version: - **Hybrid Shader 2**: + more control + more styles possible - more parameters tweaking - **Standard PBS**: + less parameters tweaking - less control - a unique visual style that will always be PBS-ish Hybrid Shader 2 =============== The *Hybrid Shader 2* is the latest default shader included in TCP2, which works with both the *Built-in* and *Universal Render Pipelines*. That means that the *same shader file* works with both pipelines, and thus your materials will automatically work if you change the render pipeline. !!!WARNING If you do change the render pipeline, **you will have to manually reimport** the *"Toony Colors Pro/Shaders/Hybrid 2"* directory for the shaders to be compiled and work for the current pipeline (*right-click* on the folder and click on *Reimport*).
This is because the shaders use a custom file format that will only compile the shader code relevant to the currently used pipeline. !!! INFO You might still see differences when using a material with either pipelines, because they have some implementation differences in their architecture, for example: - Point lights fall-off is calculated differently - Shadow maps are calculated differently ## Options Reference Here is a reference of the available options with screenshots to quickly understand how they work. ---------------------------------------------------------------- ### Mobile Mode The *mobile mode* will change the shader to make it faster for mobile devices, notably: - it will skip any branching-based code (e.g. `if` conditions in the shader code) - it will compute certain things in the vertex shader rather than in the pixel shader, at the expense of precision (e.g. the rim lighting calculation) As such, some of the options in the material inspector will be disabled when mobile mode is enabled. Note that high-end mobile devices should work fine without the mobile mode enabled. ---------------------------------------------------------------- ### Transparency #### Rendering Mode Defines whether the material should be opaque or semi-transparent. If not opaque, the *alpha* value will control opacity, i.e. the *main color alpha* multiplied with the *Albedo alpha*, if any. Opaque | Alpha has no effect on opacity Fade | Alpha will control opacity of the full material Transparent | Alpha will control opacity of the diffuse parts, specular/reflections will still be fully visible to emulate physical semi-transparent materials (e.g. glass) Example with specular, rim lighting, and alpha set at 0.3: _(note: the difference is clearer in dark mode, see the button at the top-right hander corner)_ ![Opaque](images/hybrid_shading_opaque.png) ![Fade](images/hybrid_shading_fade.png) ![Transparent](images/hybrid_shading_transparent_m.png) Changing the rendering mode will: - Change the shader's `Blend` factors - Toggle [[depth write]] accordingly, although that can be changed afterwards #### Render Face Defines which faces to render: front, back, both (`Cull Back/Front/Off` in ShaderLab). This corresponds to the hardware face culling parameter. Front | Render the front faces, cull the back faces. Back | Render the back faces, cull the front faces. Rarely used. Both | Render both front and back faces.
Generally used with transparency or [[alpha clipping]], so that the "interior" of a mesh can be seen; or with planar meshes (e.g. a flag). !!! INFO The **Hybrid Shader 2** automatically flips the normals for correct lighting calculation on the back faces when they are visible! #### Depth Write Toggles depth buffer writing (`ZWrite On/Off` in ShaderLab). Generally disabled when using transparency to avoid sorting issues for semi-transparent pixels. It does work with [[alpha clipping]] though, hence why alpha clipping is generally used to draw vegetation as the grass, leaves, etc. need proper sorting. Depth Writing can also be important for some post-processing effects (e.g. Depth of Field). #### Alpha Clipping Toggles binary transparency at the pixel level: a pixel can either be opaque or fully invisible, based on the alpha value and a threshold. Also knows as *alpha testing*, or *cutout* shaders in Unity. ![Alpha Clipping](images/hybrid_ramp_alphaclipping.png) ---------------------------------------------------------------- ### Base #### Color The *main color*, that will be multiplied with the Albedo texture, if any. #### Albedo The *main texture*. Although it's named "albedo", the Hybrid Shader 2 is not a physically-based one, thus it doesn't expect textures that are only pure albedo in the physical sense of the term. #### Highlight Color This is an *additional color* for the *lit parts* of the material only, based on the [[ramp shading]] settings. #### Shadow Color This is an *additional color* for the *unlit parts* of the material only (including cast shadows), based on the [[ramp shading]] settings. This is an easy way to change the tint of the shadowed parts, as commonly seen in 2D animation for example. #### Shadow Albedo Texture This is an *optional texture* that will be used in place of the main albedo one for the *unlit parts* of the material. The [[shadow color]] is still applied on top of it. !!! INFO There are multiple workflows possible with the Shadow Albedo Texture, notably: - Use a **shadow albedo texture** that only changes the **hues** of the main texture, or hides some details, and use the **shadow color** to handle the luminosity - Use a white **shadow color**, and thus the **shadow albedo texture** will contain the **final color** for shadowed parts of the material ![Main Color](images/hybrid_colors_main.png) ![Highlight Color](images/hybrid_colors_highlight.png) ![Shadow Color](images/hybrid_colors_shadow.png) ![Shadow Albedo Texture](images/hybrid_colors_shadow_albedo.png) ---------------------------------------------------------------- ### Ramp Shading The *Ramp Shading* defines how the separation between lit and unlit areas will be handled visually.
The *Hybrid Shader 2* provides multiple options for the *Ramp Type*, to achieve different kind of styles: #### Ramp Type Default | Two parameters will define the ramp shading:
- *Threshold* will move the line between lit and unlit parts.
- *Smoothing* will vary blurring on that line. Crisp | Same as Default, without the "Smoothing" parameter.
- This can be thought as the *Default* type, with a smoothing of 0, but with additional calculation to make sure the line is always anti-aliased. Bands | Same as Default, but the gradient between the min and max value is quantized, visually resulting in clearly defined bands. The smoothing between each band can be adjusted. Bands Crisp | Same as Bands, without the "Bands Smoothing" parameter, but having anti-aliased lines between each band instead. Texture | A 1D ramp texture will define the ramp shading.
- This settings gives the most flexibility. If using a ramp generated with the [[Ramp Generator]], you can even tweak the gradient in real time.
- You can use RGB colors in the texture.
- *Offset* and *Scale* values can be thought as *Threshold* and *Smoothing* values applied to the texture's UVs. ![Default Ramp](images/hybrid_ramp_default.png) ![Crisp Ramp](images/hybrid_ramp_crisp.png) ![Bands](images/hybrid_ramp_bands.png) ![Bands Crisp](images/hybrid_ramp_bands_crisp.png) ![Texture Ramp](images/hybrid_ramp_texture_m.png) ---------------------------------------------------------------- ### Specular Type | Defines the specular lighting model to use. └─ GGX | *GGX* is the main technique used in PBR rendering for specular. It is energy conserving, roughly meaning that as the roughness increases, the specular intensity decreases. └─ Stylized | *Stylized* allows you to directly control the size and smoothing of the specular area. └─ Crisp | *Crisp* is the same as stylized, with a smoothing of 0 but with anti-aliasing applied. Color | A color multiplied with the specular area, to tint it or change its intensity. Specular Map | Enables the use of a specular map: with *GGX*, this will control the *Roughness*, whereas for *Stylized/Crisp* this will control the *Size*. ![Specular GGX  ](images/hybrid_specular_ggx.png) ![Specular GGX with map](images/hybrid_specular_ggx_map.png) ![Specular Stylized  ](images/hybrid_specular_stylized.png) ![Specular Stylized with map](images/hybrid_specular_stylized_map.png) ![Specular Crisp  ](images/hybrid_specular_crisp.png) ![Specular Crisp with map](images/hybrid_specular_crisp_map.png) ---------------------------------------------------------------- ### Normal Mapping Toggles tangent-space *normal mapping*. Normal Map | The normal map texture in tangent space (the classic blue-ish looking normal maps). Scale | Controls the strength of the normal map, also allowing you to reverse it by using negative values. ![Checker normal map](images/hybrid_normal.png) ![Scale at -1 The normals appear reversed](images/hybrid_normal_sm1.png) ![Scale at 0.25  ](images/hybrid_normal_sm025.png) ![Normal map with specular and rim lighting](images/hybrid_normal_spec.png) ---------------------------------------------------------------- ### Emission Toggles *emission*, which essentially represents colors not affected by lighting on top of everything else. Texture Channel | Enables the emission texture and selects which channel to use for it. Color | The emission color, multiplied by the emission texture if any. ![Yellow Emission Color](images/hybrid_emission.png) ![Emission with texture mask](images/hybrid_emission_tex.png) ![Emission from RGB texture](images/hybrid_emission_tex_rgb.png) ---------------------------------------------------------------- ### Rim Lighting Adds a fake *rim light* around the model, based on the dot vector between its normals and the view direction. This is an easy way to emphasize the silhouette of objects. Color | The color of the rim lighting effect, which also controls its strength since the effect is additive (i.e. black color = invisible rim lighting). Min | The minimum value of the view-based threshold. Max | The maximum value of the view-based threshold. Light-based Mask | Will add one rim effect per light affecting the material, and masked based on the [[ramp shading]] options. ![Default Rim Lighting Min 0.5 / Max 1.0](images/hybrid_rim.png) ![Light-based Mask Min 0.5 / Max 1.0](images/hybrid_rim_lightmask.png) ![Light-based Mask with an orange point light Min 0.5 / Max 1.0](images/hybrid_rim_lightmask_pt.png) ![Close min/max values will result in a crisp looking rim Min 0.7 / Max 0.75](images/hybrid_rim_crisp.png) ![Inverting the values will make an inner glow effect Min 0.65 / Max 0.0](images/hybrid_rim_inverted.png) ---------------------------------------------------------------- ### MatCap Toggles *matcap* shading on top of the regular shading.
"MatCap" is a technique that uses a single small texture to define a view-dependent shading model: for each pixel on the material, its view-space normal will define where to sample the provided matcap texture. It is a very cheap and effective technique to add some reflectivity to a material. The word is an abbreviation for *"Material Capture"*. MatCap Blending | How the MatCap colors will be blended with the rest: *additive* will add the colors, *replace* will replace the albedo color entirely. Texture | The MatCap texture. Some are included in the Textures/MatCap folder. Color | An HDR color multiplied with the MatCap colors, that can also increase its brightness if set to values over 1.0. Enable Mask | An HDR color multiplied with the MatCap colors, that can also increase its brightness if set to values over 1.0. └─ Texture Channel | An HDR color multiplied with the MatCap colors, that can also increase its brightness if set to values over 1.0. ![MatCap Additive](images/hybrid_matcap_add.png) ![MatCap Additive with Mask](images/hybrid_matcap_add_mask.png) ![MatCap Replace](images/hybrid_matcap_replace.png) ![MatCap Replace with Mask](images/hybrid_matcap_replace_mask.png) ![MatCap applied to another mesh](images/matcap_cat_2.png) ---------------------------------------------------------------- ### Global Illumination Provides parameters to control how *global illumination* affects the material. There are two main sources for global illumination: **Indirect Diffuse** | Also called *ambient* or *environment lighting*, physically corresponds to light bouncing around surfaces and thus providing indirect lighting.
In Unity, this is generally provided by lightmaps for static objects, and light probes for dynamic/moving objects. **Indirect Specular** | Corresponds to the *reflections* from the environment around an object.
In Unity, this is generally provided by *reflection probes*. #### Indirect Diffuse Strength | How much should indirect diffuse affect the material. Set to 0 to disable indirect diffuse entirely. Single Indirect Color | Use the view vector instead of the normals to sample the indirect diffuse/ambient color, so that it is the same for the whole material. The *Single Indirect Color* option can help to maintain a flat appearance on objects when using *Skybox* or *Gradient* as the *Environment Lighting Source* in the [Lighting Settings](+https://docs.unity3d.com/Manual/lighting-window.html). It has no effect when using a single color as the environment lighting source. ![Indirect diffuse Strength set to 1](images/hybrid_ramp_default.png) ![Indirect diffuse Strength set to 0](images/hybrid_gi_id_0.png) ![Indirect diffuse set to 0 with a black [[shadow color]]](images/hybrid_gi_id_0_black.png) ![Env. Lighting set to Skybox Regular](images/hybrid_gi_id_skybox.png) ![Env. Lighting set to Skybox Single Indirect Color](images/hybrid_gi_id_skybox_single.png) #### Indirect Specular Color | A color multiplied with the indirect specular colors, which can also be used to decrease its intensity when using values towards black. Smoothness | Defines how smooth the surface is, and thus how clear should the reflections appear: the lower the value, the blurrier reflections will look. Reflection Map | Toggles a smoothness map, which will multiply the smoothness value based on the selected texture and relevant color channel. Fresnel Reflections | Toggles Fresnel reflections, meaning that the edges of the object will be more reflective than its center, based on the view.
This is a natural effect in the real world, but the calculation used here is not physically accurate. It is based on the same calculations done for [[rim lighting]], and you can tweak the min/max values. └─ Fresnel Min | The minimum value of the view-based threshold, similar to the [[rim lighting]] parameters. └─ Fresnel Max | The maximum value of the view-based threshold, similar to the [[rim lighting]] parameters. ![Indirect Specular Smoothness set to 1  ](images/hybrid_gi_is.png) ![Indirect Specular with Reflection Map  ](images/hybrid_gi_is_map.png) ![Indirect Specular with Fresnel Reflections  ](images/hybrid_gi_is_fresnel.png) ![Indirect Specular with Fresnel Reflections and Reflection Map](images/hybrid_gi_is_fresnel_map.png) #### Occlusion The *occlusion texture* is meant to control the small shadowing caused by a model onto itself. This can be thought as a mask for the global illumination (thus it affects indirect diffuse _and_ indirect specular). Most DCC/3D authoring softwares provide a way to generate an occlusion map, preferably from a high-resolution 3D model. Strength | Defines the strength of the occlusion. 0 is effectively the same as turning occlusion off. Texture | The occlusion texture. Texture Channel | Defines which color channel to use as the occlusion map. Also allows using the [[albedo]] alpha channel as the occlusion source. ![Occlusion Map applied to indirect diffuse](images/hybrid_gi_occlusion_id.png) ![Occlusion Map applied to indirect specular](images/hybrid_gi_occlusion_is.png) ![Occlusion Map applied to both indirect diffuse and specular](images/hybrid_gi_occlusion.png) ---------------------------------------------------------------- ### Outline Toggles rendering an *outline* for the material. The technique used is the classic *"inverted hull"* outline, which is based on rendering the object in an *additional shader pass* with front-face culling and then rendering the object regularly on top of it. Since this is merely an illusion rather than a screen-space outline, some artifacts can show depending on the cases. One common artifact is the outline mesh appearing broken when using *hard edge shading*. TCP2 provides the [[Smoothed Normals Utility]] to solve that particular problem. Color | The main color of the outline, which will be multiplied with the rest. Texture | Toggles sampling the [[albedo]] texture for the outline color:
- **Vertex Shader**: will sample the texture at the vertex level, faster but loses a lot of precision (dependending on the vertex count)
- **Pixel Shader**: will sample the texture for each pixel, which can show all the texture's details depending on the *Texture LOD* value. └─ Texture LOD | Defines the mip level at which to sample the texture. Useful if you want the outline color to vaguely look like the [[albedo]] texture without showing all its details. Width | Defines the base size of the outline. Pixel Size | Defines how the outline size should behave in screen-space:
- **Disabled**: don't apply any correction
- **Constant**: the outline will always have the defined *width* in pixels on the screen
- **Minimum**: the outline will have a minimum pixel size on screen. This ensures that it will always encompass the object even when viewed from far away
See the video below for a visual example.
- **Min Max**: the outline will have a minimum and maximum pixel size on screen Outline Normals Source | Defines which data to use as normals when expanding the outline mesh.
Should be set according to the settings used in the [[Smoothed Normals Utility]]. └─ UV Data Type | Defines how the normal data is encoded when using an UV channel as the normals source.
Should be set according to the settings used in the [[Smoothed Normals Utility]]. Lighting | Enables lighting on the outline:
- **Main Directional Light**: outline will be lit by the main directional light and the indirect diffuse from [[global illumination]]
- **All Lights**: outline will be lit by all real-time lights and the indirect diffuse _(Universal Render Pipeline only)_
- **Indirect Only**: the outline will only receive lighting from indirect diffuse └─ Direct Strength | Defines the intensity from direct lighting. └─ Indirect Strength | Defines the intensity from indirect lighting (ambient/indirect diffuse from [[global illumination]]). !!! WARNING Because the outline is an illusion using front-face culling in another shader pass, the lighting received might not look like what you would expect from a 2D drawing. ![Simple black outline  ](images/hybrid_outline.png) ![Vertex Texture enabled  ](images/hybrid_outline_tex_vertex.png) ![Pixel Texture enabled  ](images/hybrid_outline_tex_pixel.png) ![Lighting enabled with Main Directional Light](images/hybrid_outline_lighting.png) #### Pixel Size examples: ![Comparison of the different pixel size values Outline width is set at **4** Minimum width is set at **1** for the right Sphere](images/outline_pixel_size.mp4) ![Same comparison without the video artifacts](images/outline_pixel_size.png) ---------------------------------------------------------------- ### Options Receive Shadows | Defines whether this material will receive shadows from shadow maps or not.
Note that this option also exists on the *Renderer component*. Render Queue | Defines when to render this material. See [Unity's documentation](+https://docs.unity3d.com/Manual/SL-SubShaderTags.html) for more information about the render queue. Enable GPU Instancing | As its name implies, enables [GPU instancing](+https://docs.unity3d.com/Manual/GPUInstancing.html) support. ================================================================ ## Features Stripping The *Hybrid Shader 2* allows you to strip out certain parts of the code entirely, mainly to reduce the number of shader variants compiled in your builds, and also to hide in the user interface anything you know you won't use in your project. Just select the *"TCP2 Hybrid Shader 2"* and/or *"TCP2 Hybrid Shader 2 Outline"* files, and this interface will show up: ![](images/hybrid2_options.png) You can uncheck any option here to *entirely exclude it from the shader* (make sure to hit *"Apply"* after your changes). The statistics at the top will indicate how many [variants](+https://docs.unity3d.com/Manual/shader-variants.html) the shader will compile into (the "currently used" number excludes any unused [`shader_feature`](+https://docs.unity3d.com/Manual/SL-MultipleProgramVariants.html) keywords). Reducing the number of variants can improve build times, file sizes, runtime memory usage, and loading times. !!! WARNING By default, *Lightmap* support is disabled because it dramatically reduces the number of shader variants (from ~400k to ~25k). If you need lightmap support with the Hybrid Shader 2, you will have to enable it back here. !!! WARNING By default, *DOTS Instancing (Entities Graphics)* support is disabled, you need to enable it explicitly to get support for DOTS/Entities rendering. ================================================================ ## Specific notes / Troubleshooting ### 1. Main texture and color variables The main texture and color variables are named *_BaseMap* and *_BaseColor* as in URP, instead of being named *_MainTex* and *_Color* as it historically was the case for Unity shaders. This means that C# APIs like [material.mainTexture](https://docs.unity3d.com/2019.2/Documentation/ScriptReference/Material-mainTexture.html) will not work properly when using *Unity 2019.2 or lower* (a fix was introduced for that in *2019.3+*). ### 2. Outline in URP The Universal Render Pipeline requires an additional step to render the outline, when enabled in the material, because URP - by design - won't render additional passes within a same shader file. Simply edit the *URP Renderer Asset* that is linked to your main *URP Asset*: - add a new *Renderer Feature*. - in the *Filters* section, add a *Shader Pass* named "*Outline*" I recommend setting the *Event* to "*After Rendering Opaques*", although other values might suit your situation better. You can also easily change which objects will use an outline by using the *Layer Mask* setting and placing GameObjects in the appropriate layer(s). ![](images/urp_renderer_features.png) Standard PBS Shader =================== The *Standrad PBS* shader is based on Unity's *Standard shader*, with additional *stylization options*. The Standard Properties are the same that you will find on the Standard shader: - Rendering Mode (opaque, transparent, cutout) - Albedo Map & Color - Metallic/Specular Maps (depending on workflow) - Smoothness - Specular - Reflection (using Reflection Probes) - Normal Map (enables Bump Mapping) - Height Map (enables Parallax mapping) - Occlusion Map - Emission Map & Color - Secondary Maps (Albedo + Normal) Please refer to the [Unity manual](+https://docs.unity3d.com/Manual/StandardShaderMaterialParameters.html) for more information about the Standard Properties.

Toony Colors Pro 2 adds the following *stylization properties*: - [[Highlight/Shadow Color]] - [[Ramp Style]] - [[Main and Additional Lights Ramp Control]] - [[Stylized Specular]] - [[Stylized Fresnel]] - [Outline](#standardpbsshader/optionsreference/outline) ## Options Reference Here is a reference of the available options with screenshots to quickly understand how they work. !!! INFO All examples have two additional point lights (blue and orange) to better highlight how some settings affect each light. ### Base Properties #### Highlight/Shadow Color Additional color tints for the *lit* and *unlit* parts of the material respectively. ![Highlight Color  ](images/pbs_colors_highlight.png) ![Shadow Color  ](images/pbs_colors_shadow.png) ![Shadow Color without additional lights](images/pbs_colors_shadow_main.png) !!! INFO For historical reasons (read: I wasn't doing things properly years ago), you will notice that when additional lights are active, the shadow color will also affect lit parts of the model! #### Ramp Style The *Ramp Shading* defines how the separation between lit and unlit areas will be handled visually.
The *Standard PBS* shader uses a threshold/smoothing based ramp by default, or you can toggle the texture ramp option. Disable Wrapped Lighting | Disables light wrapping, i.e. light that encompass the whole model rather than stopping at a 90° angle between the light and normal vectors.
This setting exists for historical and backward compatibility reasons.
_I recommend leaving it on and using the *threshold* setting to change how lights wraps around the model instead._ Use Ramp Texture | Enables the texture ramp to calculate the ramp shading. ![Sliders Ramp  ](images/pbs_ramp_default.png) ![Texture Ramp  ](images/pbs_ramp_texture_m.png) ![Wrapped Lighting Enabled](images/pbs_wrapped_on.png) ![Wrapped Lighting Disabled (recommended)](images/pbs_wrapped_off.png) #### Main and Additional Lights Ramp Control When not using a ramp texture, you have an additional setting to define a separate smoothing for the additional lights. Threshold | Defines the separation between shadows and highlights. Main Light Smoothing | Smoothing of the separation between shadows and highlights for the main directional light. Other Lights Smoothing | Smoothing of the separation between shadows and highlights for additional lights. ![Main Light = 0.1 Additional Lights = 0.1](images/pbs_ramp_default.png) ![Main Light = 1.0 Additional Lights = 0.1](images/pbs_ramp_smooth_main.png) ![Main Light = 0.1 Additional Lights = 1.0](images/pbs_ramp_smooth_other.png) ### Stylization Options #### Stylized Specular Will add a smoothing value allowing to get a crisper specular term. You can also blend between the regular and the stylized specular to get an hybrid look. Specular Smoothing | Defines how crisp the specular highlights should look. Specular Blend | Blending value between the Standard and Stylized specular visuals. ![Stylized Specular disabled](images/pbs_specular_off.png) ![Stylized Specular enabled](images/pbs_specular_on.png) ![Stylized Specular with 0.5 blending](images/pbs_specular_blend.png) #### Stylized Fresnel Will add an enhanced Fresnel effect linked to lights around the model. Fresnel Strength | Defines how visible is the enhanced Fresnel effect (note that the strength is also dependent on the Smoothness of the material) Fresnel Min/Max | Defines the threshold values for the Fresnel effect (similar to the Rim effect) ![Stylized Fresnel disabled](images/pbs_fresnel_off.png) ![Stylized Fresnel enabled](images/pbs_fresnel_on.png) #### Outline Enables the additional shader pass to render an outline. See the Hybrid Shader 2 [[outline]] section to learn more about the technique used and its caveats. ![Black Outline  ](images/pbs_outline.png) ![Blended Outline with 50% opacity](images/pbs_outline_blended.png) Outline Color | The main outline color. Outline Width | The outline size. Textured Outline | Toggles sampling the [[albedo]] texture for the outline color, in the vertex shader. └─ Texture LOD | Defines the mip level at which to sample the texture. Constant Screen Size | Scales the outline's width based on the distance from camera, so that it always appears at the same size on the screen. Z Smooth | Provides parameters to slightly change the Z position of the vertices to try and correct outline artifacts that could appear. Blended Outline | Enables blending for the outline pass, so that it can be blended with the scene. It might cause sorting issues though. Outline Normals | Defines which data to use as normals when expanding the outline mesh.
Should be set according to the settings used in the [[Smoothed Normals Utility]]. Tools ===== Shader Generator 2 ------------------ The *Shader Generator 2* is the most complex and powerful tool included with *TCP2*. It allows you to *generate your own stylized shaders*, using exactly the features you need. It provides many more options than the *Hybrid* or *Standard PBS* shaders, and allows further customization (e.g. optimizing and re-arranging your data texture to not waste GPU memory, applying UV scrolling to any texture used, etc.). There are a lot of features available, and its customization system using the *Shader Properties* is quite deep, so there is a dedicated documentation for it:
**See the [Shader Generator 2 Documentation](shader_generator_2.html).** You can also take a look at the [tutorials page](tutorials.html) to see what it can achieve. !!! INFO The **Shader Generator 2** doesn't have feature parity with the old Shader Generator 1 yet, e.g. the PBS template is missing. You can still use and read the [Shader Generator 1 documentation here](+https://jeanmoreno.com/unity/toonycolorspro/Documentation/#shader_generator). ================================================================ Smoothed Normals Utility ------------------------ ![Hard edges break the outline effect](images/smoothed_normals_hard.png) ![Smoothed normals stored in UV2 (hard edge shading is preserved)](images/smoothed_normals_smoothed.png) ### How it works The outlining technique is based on the mesh normals. When a vertex has multiple normals (aka *hard edge shading*), it can break the outline as shown above. The *Smoothed Normals Utility* will calculate the *average normals* for each vertex of your mesh, and assign them to an unused part of your mesh data (vertex colors, tangents, or other UV coordinates). By enabling the corresponding option in the *Outline Normals Source property* in the material inspector of your TCP2 shader, the shader will take this data as the new normals to draw the outline. This way you get a correctly outlined mesh with hard edge shading preserved, as pictured above. ### Usage Open the utility via the menu: !!! Tools > Toony Colors Pro 2 > Smoothed Normals Utility In Unity, select: - meshes or models assets from the Project view - GameObjects with a *MeshFilter* or *SkinnedMeshRenderer* attached The list of meshes ready to be processed should then appear in the Smoothed Normals Utility window. Select the vertex data target to stored the smoothed normals: - *Vertex Colors* - *Tangents* - *UV1-UV4* If using UV data, you can select how to store the smoothed normals: - *Full XYZ*: will store the data as-is - *Compressed XY*: will store the data compressed into the XY channels - *Compressed ZW*: will store the data compressed into the ZW channels Using compressed types loses precision, but it can be handy to optimize storage. For example, you could keep the regular texture coordinates in UV1.xy, and store smoothed normals in UV1.zw, and thus not need any extra TEXCOORD in the vertex data (or keep them free for other usages). Click on `Generate Smoothed Mesh` to generate a copy of the mesh with smoothed normals in the selected mesh data. The new mesh will automatically be assigned if you had MeshFilters or SkinnedMeshRenderers selected. You will then have to select the correct option in the *Outline Normals Source* of the *Material Inspector* so that the shader knows where and how to interpret the outline normal data. !!! INFO Smoothed Normals will only be stored in **tangents** for **skinned meshes**. This is because normals need to be affected by bones, and in the 3 options available only tangents are affected by bones (vertex colors and UV data are not). This means that smoothed normals can't work with normal map, anisotropic specular, or other features requiring tangent data on skinned meshes. !!! WARNING If a copy of the mesh has already been made, it will be overwritten with the new settings defined. You can recognize the generated meshes with the **[TCP2 Smoothed]** suffix, and they are all stored in the 'Smoothed Meshes' folder by default. You can customize the suffix in the tool. ================================================================ Ramp Generator -------------- The *Ramp Generator* allows you to create a ramp texture (to be used with the [texture ramp](#hybridshader/optionsreference/rampshading) feature) very easily from a gradient. Simply edit the gradient and set a texture width size. The texture height will always be 4 pixels tall. ![Ramp Generator](images/ramp_generator_1.png) The Ramp Generator can also *edit ramps* generated with it, allowing you to edit the gradient and *see the results in real-time* on your models/materials. You can edit a gradient ramp either by: - Loading a texture in the Ramp Generator directly - Clicking on `Edit Gradient` in a TCP2 material that uses ramp textures ![Ramp Editor for a ramp texture used in a material](images/ramp_generator_edit.mp4) !!! INFO If your ramp is grayscale, then it is useless to set a width higher than 256, because an 8-bit image can only represent at most 256 shades of gray. Render Pipelines Information ============================ *TCP2* supports the *Built-in* and *Universal* render pipelines. Here are the supported shaders/tools for each pipeline: - **Built-in Render Pipeline** - *Hybrid Shader 2* - *Standard PBS* - *Shader Generator 2* with the [Default Template](shader_generator_2.html#templates/default) - *Shader Generator 1* (legacy) - **Universal Render Pipeline** - *Hybrid Shader 2* - *Shader Generator 2* with the [URP Template](shader_generator_2.html#templates/lwrp/urp) Third-Party Plugins =================== *TCP2* supports a few third-party plugins, using the [Shader Generator 2](shader_generator_2.html): - [VertExmotion](+http://www.kalagaan.com/#vertexmotion) - [Curved World](+https://assetstore.unity.com/packages/vfx/shaders/curved-world-26165) You just have to enable the relevant options in the *THIRD PARTY PLUGINS* section of the [Shader Generator 2](shader_generator_2.html). !!! INFO When using either plugin with the **Built-in render pipeline**, make sure to also enable **Add Shadow/Depth Pass** in the **OPTIONS** for the shadow maps to work properly! Contact ======= If you have questions, bug reports or suggestions please contact me by email at: jean.moreno.public+unity@gmail.com I'll do my best to answer as quickly as possible.