**Toony Colors Pro 2** **Shader Generator 2 Beta - Documentation** v2.4.2 - November 2019 ([See changelog](changelog)) © 2019 Jean Moreno jean.moreno.public+unity@gmail.com ================================================================================================================================ Shader Generator 2 Beta ======================= The *Shader Generator 2* beta is now available to be used in *Toony Colors Pro 2*! The Shader Generator allows you to generate your own shader files for your project, with just the features you need. It has *many more features* than TCP2's default shaders, and can help you create *a wide variety of visual styles*. This new version of the Shader Generator tool improves the flexibility and control that you have over the generated shaders. The goal is to offer an *easy-to-use* tool with features *already implemented* (unlike a node-based tool for example), but where you still have *flexibility* over the generated code, for example choosing what source to use to fetch a color (single color, texture, vertex colors, constant color, etc.). Just toggle the features you want and select their options in the *Features* tab, and tweak the properties further if you need more control in the *Shader Properties* tab. !!! INFO *BETA VERSION NOTES:* • Only the [[Shader Properties]] part of the Shader Generator 2 is considered in beta: there are a lot of combinations possible there, so some complicated combinations might break. • Once a shader is generated and working, there is no reason for it to break later. • If you are starting a new project, I strongly suggest to use this version, unless you need a [template](#templates) that hasn't been made yet (water, terrain...). • This documentation isn't complete yet, and the inline help messages in the tool aren't either. In any case, if you are having bugs or issues, please [contact me](#contact) and I'll help you as soon as possible! Getting Started =============== Open the tool through the top menu: !!! Tools > Toony Colors Pro 2 > Shader Generator 2 (beta) Interface --------- Move your mouse on the different elements to learn about the interface:
Load a shader template here, e.g. Default, LWRP/URP, PBS, Water...
This is the current shader being edited, or 'None' if it's a new one.
You can click on this property to highlight the file in the Project view.
This is the name of the shader as it will appear in Unity's shader menu, in the material inspector.
In the **Features** tab, you can select the features that you want to add for your shader, along with their options.
In the **Shader Properties** tab, you can view most of the properties that will be used in your shader, and modify how they are fetched/calculated.
You can click on this help button to open this documentation in your browser pointing to the relevant feature.
_(Note: they may not all work in the beta!)_
The label for the feature; most of the times you can hover with the mouse to reveal a help tooltip about the feature.
The current value of the feature. If different than the default value, its label will be highlighted.
Features are organized in categories for easier navigation.
Global [[options]] for the Shader Generator 2.
First Steps ----------- First, you might want to load a shader template: - the *Default* template is a **non-?[PBS]((PBS means 'Physically Based Shading' and describes a lighting model that mimics the real world, where the shader will calculate most of its colors based on the lighting and a few parameters describing the physical aspects of the materials. The goal is to have a material that will always look good with all lighting environments, vs. a model where you have to tweak material parameters for each lighting conditions. The drawback is that you generally have less control over the final colors, should you want more stylistic visuals.))** general purpose template with a lot of features - the *LWRP/URP* template is a the equivalent of the *Default* one for the *Lightweight/Universal Render Pipeline (LWRP/URP)* - ~~the *PBS* template is a physically-based general purpose template~~ **_(not available yet in the beta)_** - ~~the *LWRP/URP PBS* template is the equivalent of the *PBS* one for the *Lightweight/Universal Render Pipeline (LWRP/URP)*~~ **_(not available yet in the beta)_** Then, change the *Shader Name*: this will be the name you see in the shader selection menu, in the material inspector. !L[Loading a template and changing the name](images/sg2_main_2.png) Finally, look at the various features and enable the ones you want for your shader. Once you're done, click on `Generate Shader` and the file will be created. You will then be able to use your generated shader by selecting it in a material. !!! INFO Once you click on `Generate Shader`, the generated shader will automatically be loaded in the Shader Generator 2. You can assign it to a material, and then easily test the various features by enabling/disabling them and clicking on `Update Shader` in the Shader Generator: the material will update along with the shader. This is a good way to preview the different features on your own models. !!! INFO You can easily open a generated shader back in the Shader Generator by clicking on the cog icon in the top-right hand corner of the material inspector: ![](images/sg2_material_inspector_cog.png) Once you feel comfortable enough with the *[Features](#featuresreference)* tab, you can look into the [[Shader Properties]] tab for more control. Options ------- Option | Description --------------------------------|-------------------------------------- Select Generated Shader | Once a shader is generated or updated, it will automatically be selected in the Project view. Always overwrite shaders | Do not prompt when you are about to overwrite an existing shader. _This doesn't apply to shaders that have been modified manually, you will always be prompted before overwriting those!_ Reload Shaders from all Project | By default, the tool will only look for generated shaders in the default output directory (`JMO Assets/Toony Colors Pro/Shaders Generated`). When enabled, this makes it search through all the project assets. Automatic Filename | Automatically generate the filename for the output shader, based on its UI name. Automatic sub-directories | Automatically generate sub-directories for the output shader, based on its UI name. Show disabled fields | Show all fields in the UI, even if they are disabled. Can be useful to see all the options available for each feature. Show contextual help | Display contextual blue help boxes in the UI. Dockable Window | Makes the Shader Generator 2 window look like any other Unity window that can be docked anywhere, instead of a separate OS window. You will have to close and open the tool again to see the change. Templates ========= A template will be the basis to generate your shader from. General purpose templates generally share most of their features, and specific templates have their own specialized features, for example vertex wave animations for the ((Water)) template. Here is a quick description of each template and what they are made for. Make sure to also look at the demo scenes to see actual examples. Default ------- The Default template is a general purpose one, that works with the [Legacy Render Pipeline](+https://docs.unity3d.com/Manual/SL-RenderPipeline.html), in *Forward Rendering*. This is the one to use to create shaders for characters, environments, and everything that doesn't require special shader effects. LWRP/URP ---- The LWRP/URP template is the same as the [[Default]] one but working with the [Lightweight/Universal Render Pipeline](+https://unity.com/srp/universal-render-pipeline). Because the pipelines don't work the same internally, some features might render differently between the Legacy and Lightweight/Universal Render Pipelines. ~~Default PBS~~ --------------- Physically-based version of the Default template. It is based on Unity's [Standard Shader](+https://docs.unity3d.com/Manual/shader-StandardShader.html). The advantage of PBS is the possibility to use PBR assets out of the box, and more consistent colors across different lighting conditions, at the expense of precisely controlling the final colors. It is also more expensive in the shader code. It can be a good solution if you already have a project setup with the Standard Shader. Take a look at the [Legacy or Physically-Based?](https://jeanmoreno.com/unity/toonycolorspro/Documentation/#legacy_or_pbs) guide from the old documentation to learn more about the pros and cons of each technique. !!! ERROR The ((Default PBS)) template isn't available yet in the Shader Generator 2! ~~LWRP/URP PBS~~ ------------ Physically-based version of the LWRP/URP template. Is is based on the [Lit Shader](+https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.1/manual/lit-shader.html) from the Lightweight Render Pipeline. It can be a good solution if you already have a project setup with the LWRP/URP Lit Shader. !!! ERROR The ((LWRP/URP PBS)) template isn't available yet in the Shader Generator 2! ~~Water~~ --------- Specialized template to create stylized water shaders. It contains some specialized features such as vertex-displacement based waves, depth-based foam, etc. !!! ERROR The ((Water)) template isn't available yet in the Shader Generator 2! ~~Terrain~~ ----------- Specialized template that will generate the shaders required for a material to work with [Terrains](+https://docs.unity3d.com/Manual/terrain-UsingTerrains.html). !!! ERROR The ((Terrain)) template isn't available yet in the Shader Generator 2! Shader Properties ================= About ----- The *Shader Properties* is a powerful and flexible system used to further customize your shaders. A Shader Property is a property that will be used in the generated shader. They generally correspond to the properties you will see in the material inspector, although that's not always the case. This interface allows you to change their behavior, change how they are fetched and/or calculated, or do advanced combinations such as applying a mask, and reference properties between each other. For example, the `Albedo` property is always available: it corresponds to the main texture. You could change this texture's options to remove the tiling/offset values, or apply UV scrolling to it. The `Albedo` property is a color, meaning that you can change how it is fetched and use something else than a texture: a single color, the mesh's vertex colors, or even a constant color if you don't plan on changing that value: the shader will be better optimized that way. Reading the [tutorials](#shaderpropertiestutorials) from the most simple to the most advanced is a good way to progressively understand how the system works. ================================================================================================================================ Structure --------- A *Shader Property* works with *Implementations*: it has at least one, and can chain more implementations, with an *operator* describing how to combine them: - Shader Property - Implementation 1 - Operator 2 - Implementation 2 - Operator 3 - Implementation 3 - ... In the shader code, the property will generate a variable that will be calculated once at the beginning of its function (`Vertex` or `Fragment`), and then be used in the relevant part(s) of the code. The code will look like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [variable_type] __propertyName = [implementation_1] [operator_2] [implementation_2] [operator_3] [implementation_3] ... ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For example, the default implementations for `Albedo`, `Main Color` and `Alpha` look like this in the shader code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shader float4 __albedo = ( tex2D(_MainTex, (input.texcoord0)).rgba ); float4 __mainColor = ( _Color.rgba ); float __alpha = ( __albedo.a * __mainColor.a ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note that some "Special" implementations are sampled when the variable `__variableName` is _used_ in the code rather than when it is _declared_. This should generally not be of any concern though. ================================================================================================================================ Interface --------- Move your mouse on the different elements to learn about the Shader Properties interface:
View the available properties by clicking on this tab.
The name of the property, generally describing its usage.
The property type, can be `color`, `color (rgba)`, `float`, `float2`, `float3`, `float4`, or `fixed function`.
When available, shows a tooltip that gives some insight on the property's usage.
Where is the property used in the shader code: `Vertex` or `Fragment` program.
Useful to know which properties you can cross-reference, using the `Other Shader Property` implementation.
Shows the implementation menu, where you can copy/paste, import/export, or reset the implementations for this property.
You can also access it by right-clicking on the property name.
This is the current implementation for this property.
See the [[Implementations Reference]] to learn about the different implementations possible.
Use these buttons to add a new implementation, or remove this implementation.
This is one of the parameters of this implementation. It will be highlighted if its value is different than the default one.
Shader Properties are organized in categories, generally themed by the features they are related to.
**Custom Material Properties** allow you to define your own material properties that will show in the inspector, and then use them for any shader properties you want.
The name of the custom property, as it will appear in the material inspector.
The type of the custom property (float/range, vector, color or texture)
The name of the variable of the custom property in the shader code.
This is the name to use if you want to change the value with a script, for example using [`material.SetTexture("_TextureName", myTexture);`](+https://docs.unity3d.com/ScriptReference/Material.SetTexture.html) for a texture.
Use these buttons to add/remove Custom Material Properties.
================================================================================================================================ Interface with multiple implementations --------------------------------------- You can add as many implementations as you want for each property. Here is how the interface looks when there are two implementations for a property:
Drag this handle to reorder the different implementations of a property.
How this implementation will be blended with the previous one:
multiply `×`, divide `÷`, add `+` or subtract `-`
Here we have added a `Custom Material Property` implementation, linked to the "My Specular Mask" property that has been added in the **Custom Material Properties** section below.
The swizzle has been modified to only use the red channel: in this case, its effect is that the red channel of "My Specular Mask" will become a mask for the specular color.
This means that specular will appear on red areas, and be invisible on black areas of the texture.
Note that in this case, you could use a [Single Channel texture](+https://docs.unity3d.com/Manual/TextureTypes.html#SingleChannel) with the Red channel to optimize the memory used by the specular mask.
This section will indicate all the Shader Properties that are referencing this Custom Material Property.
================================================================================================================================ Custom Material Properties -------------------------- Those are material properties that you can define and then easily reference across multiple implementations. A good example would be a mask texture where each R,G,B,A channels are used to mask different features ================================================================================================================================ Implementations Reference ------------------------- -------------------------------------------------------------------------------------------------------------------------------- ### Constant Value The simplest implementation: just use a constant value for the property. Use it when you know that the value doesn't need to change, making the shader faster than if it were a material property for example. Parameter | Description -----------|----------------------- Value | The constant value. Precision | The [type of variable](+https://docs.unity3d.com/Manual/SL-DataTypesAndPrecision.html) to use.
Generally useful for optimization with mobile GPUs. -------------------------------------------------------------------------------------------------------------------------------- ### Material Property / ... Will add a material property, i.e. a value that you will be able to modify in the [material inspector](+https://docs.unity3d.com/Manual/Materials.html). These are common parameters for all Material Property implementations: Parameter | Description -------------------|---------------------------------------------------------------------- Label | The name of the material property as it will appear in the inspector. Variable | The name of the variable for this property in the shader code. This is the name to use if you want to change the material property with a script, using [`material.SetFloat,SetVector,SetTexture,...`](+https://docs.unity3d.com/ScriptReference/Material.html) Property Drawers | Add any [material property drawer](+https://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html) here. Note that the Shader Generator will already add its own for the user interface in the inspector (headers, separators, etc.). GPU Instanced | Allow this material property to be per-instance when using [GPU instancing](+https://docs.unity3d.com/Manual/GPUInstancing.html). This will declare the variable in the `UNITY_INSTANCING_BUFFER_START()` constant buffer. #### Material Property / Float A single float property, that can be used for any kind of shader property type. Parameter | Description -----------|----------------------------------------------------------------------- Default | The default value when the shader is first assigned to a new material. #### Material Property / Range A single float property, displayed as a slider with min/max values. Parameter | Description -----------|----------------------------------------------------------------------- Min | The minimum value for the range. Max | The maximum value for the range. Default | The default value when the shader is first assigned to a new material. #### Material Property / Vector A Vector4 property (`float4` in shader terms). You are not forced to use _all_ of its channels though. Parameter | Description -----------|----------------------------------------------------------------------- Default | The default value when the shader is first assigned to a new material. Swizzle | How/which channels of the vector are used for the shader property. #### Material Property / Color A Color property. Parameter | Description -----------|----------------------------------------------------------------------- Default | The default value when the shader is first assigned to a new material. HDR Color | Allows the color to go over the [0-1] range. Swizzle | How/which channels of the color are used for the shader property. #### Material Property / Texture A Texture property. Parameter | Description -----------------------|------------------------------------------------------------------------ Default | The default value when the shader is first assigned to a new material. Swizzle | How/which channels of the color are used for the shader property. UV | Which UV channel to use from the model, or ?[screen space UV]((Screen Space UV are a special type of UV coordinates that will align the texture to the screen instead of using the model's UV channels.)). └─ Vertex SSUV | _With Screen Space UV enabled_: calculate the screen space UV in the vertex shader. Faster, but can appear distorted. └─ Obj Offset SSUV | _With Screen Space UV enabled_: offset the UV with the object's position, to prevent the texture from "sliding" through the object (also called "shower door" effect). Tiling/Offset | Enable tiling/offset values for this texture. └─ Global | Makes the tiling/offset values global for the selected UV channel.
This also means that the tiling/offset values will be calculated in the vertex shader, rather than in the fragment shader. └─ Variable | Which variable to use for the tiling/offset values.
Change it if you want this texture to inherit from the tiling/offset values of **another texture implementation**. └─ Scale by Texel Size | Scale the texture tiling according to the texel size (i.e. the texture resolution in pixels).
Mostly useful when you use screen space UV and want the pixels of the texture to exactly match the pixels on the screen. UV Animation | Enable different kinds of UV animations: └─ Scrolling | Basic scrolling across the U and V axis. Can be **Global** or linked to another shader property **Variable**, just like the tiling/offset values. └─ Random Offset | Will apply a random offset on the UV, with a material property to define the speed.
Originally designed for the sketch effect, to make the sketch texture move randomly.
Can be **Global** to the selected UV channel. No Tile | Apply a special algorithm to prevent texture repetition.
It's a bit slower: the texture will be sampled twice, and a small cache-friendly noise texture will be sampled once.
Based on [an algorithm from Inigo Quilez](+http://www.iquilezles.org/www/articles/texturerepetition/texturerepetition.htm) (Technique 3, MIT License). ###### No Tile Details The texture needs to have some randomness to it for the effect to work nicely: ![Regular texture tiling](images/texture_notile_rocks_off.png) ![With "No Tile" enabled](images/texture_notile_rocks_on.png) A texture with a regular pattern won't work so well: ![ ](images/texture_notile_checker_off.png) ![ ](images/texture_notile_checker_on.png) -------------------------------------------------------------------------------------------------------------------------------- ### Vertex Color Returns the vertex color of the model. You could use the color directly, or use one of the RGBA channels as a cheap mask for any shader property. Parameter | Description -----------|-------------------------------------------------- Swizzle | Which channel(s) to fetch from the vertex colors. -------------------------------------------------------------------------------------------------------------------------------- ### Other Shader Property Use the value of *another shader property* for this property. Depending on the type, you can also select the swizzle, i.e. only use specific channels of the other property. Some properties might be unavailable: in this case, the reason is stated between parenthesis at the end of the other property's name. For example, you can't reference `Fragment` properties in a `Vertex` property, or you can't have cyclic references (two properties referencing each other). Parameter | Description -----------|---------------------------------------------------------- Swizzle | Which channel(s) to fetch from the other shader property. -------------------------------------------------------------------------------------------------------------------------------- ### Custom Material Property Use a property that you have defined in the *Custom Material Properties* section. This allows you to easily reuse the same custom properties for multiple shader properties. -------------------------------------------------------------------------------------------------------------------------------- ### Special / HSV HSV is a *hue, saturation, value* modifier that is applied to the current state of a `color` property. The relevant material properties will be automatically created. Parameter | Description -----------|------------ HSV Mode | Hue | In *Colorize* mode, enable the *hue* material property. Saturation | In *Colorize* mode, enable the *saturation* material property. Value | In *Colorize* mode, enable the *value* material property. -------------------------------------------------------------------------------------------------------------------------------- ### Special / Custom Code Custom Code allows you to add any kind of shader code to the property. It is suggested to use this when you need to add small modifications, rather than modifying the resulting shader, in case you want to update that shader later with different features or options (in which case you'd lose all manual modifications in the .shader file). The code is inserted right after the previous implementation, if any, and *doesn't have any blending operator* : it's up to you to determine how the code will interact with the previous property. -------------------------------------------------------------------------------------------------------------------------------- ### Special / ... Some special implementations provide you with specific values calculated at different points in the shader code. As such, their availability depend on the context of the Shader Property. For example, the ?[N·L]((Dot product between the model's normals and light direction.
This is the basis for direct lighting shading, giving a value of 1 when a triangle is directly facing the light, and 0 when it points away from the light. Also called Lambert shading.)) value will be available for properties that are used after its calculation, but unavailable for properties that are used before. #### Special Implementations Reference Special Implementation | Description | Available in the template(s) | Screenshot -----------------------------------|------------------------------------------------------------------------------------------------------------------------|------------------------------|--------------- ***N·L*** | The N.L raw value, i.e. how much is the pixel facing the light direction. | ((Default)) ((LWRP/URP)) | ![](images/_special_impl_ndl.png) ***N·L Ramp
(Black and White)*** | The N.L value with the shading ramp applied (without highlight/shadow colors). | ((Default)) ((LWRP/URP)) | ![](images/_special_impl_ndl_ramp.png) ***N·V*** | Dot product between the view direction and the surface normal. This is the basis used to calculate [[rim lighting]]. | ((Default)) ((LWRP/URP)) | ![](images/_special_impl_ndv.png) Features Reference ================== The Features Reference is not complete yet, but eventually you will find the description and screenshots here for them. In the meantime you can refer to the [old documentation](+https://www.jeanmoreno.com/unity/toonycolorspro/Documentation/#shader_generator) for screenshots, and you also have tooltips for most of the features in the Shader Generator 2 window in Unity. !!! INFO Some features have a 'Make Optional' option: this will make the feature an option in the shader, with a checkbox to enable/disable it. Internally it will translate that to a shader keyword using the `#pragma shader_feature` directive. See [Unity documentation on shader program variants](+https://docs.unity3d.com/Manual/SL-MultipleProgramVariants.html) to know more. ## Lighting -------------------------------------------------------------------------------------------------------------------------------- ### Ramp Style ((Default)) ((LWRP/URP)) The ramp style determines how the soft ?[N·L]((Dot product between the model's normals and light direction.
This is the basis for direct lighting shading, giving a value of 1 when a triangle is directly facing the light, and 0 when it points away from the light. Also called Lambert shading.)) value will be converted into a "stylized" look. Option | Description ------------------------------|------------------------------------------------------------------------------------------------------------------------------- Slider Ramp | The material will have two values, ramp threshold and ramp smoothness, to define the position and softness of the ?[terminator]((The terminator is the line at the edge of light and shadow in direct lighting:
)) line. RGB Slider Ramp | Same as slider ramp, but separating the threshold and smoothness values for the red, blue, green channels.
This allows you to define a colored ?[terminator]((The terminator is the line at the edge of light and shadow in direct lighting:
)), e.g. to simulate subsurface scattering (for skin, cloths, ...). Texture Ramp | Use a texture to define the ramp look. Some ramps are included in TCP2, and you can use the [Ramp Generator](+https://www.jeanmoreno.com/unity/toonycolorspro/Documentation/#ramp_generator) to easily create your own. Texture Ramp
└ Offset/Size | Add offset/size controls for the ramp texture, similar to the threshold/smoothness sliders. Texture Ramp
└ 2D Texture | Use a 2D ramp texture instead of a 1D texture. You can control how to sample the V texture axis with the `2D Ramp Lerp` value in the [[Shader Properties]]. Crisp Ramp | Same as Sliders Ramp, but with a smoothness value of 0. This version is faster than manually setting the smoothness to 0, because it uses the `step()` function rather than `smoothstep()`. Crisp Ramp
(Anti-aliased) | Anti-aliased version of the crisp ramp.
Note that this is different than setting a low smoothness with Slider Ramp value because it's screen-space based, and hence ensures that the line is always a few pixels wide (whereas using a low smoothness value will show width inconsistencies depending on the model polygons).
See the `Ramp Crisp Smoothing` property in the [[Shader Properties]] to define the anti-aliasing smoothness. No Ramp | Effectively disable ramp shading, and use the raw N·L value. ![Slider Ramp Varying smoothness](images/desktop_ramp_smoothness.webm) ![Slider Ramp Varying threshold](images/desktop_ramp_threshold.webm) ![Slider Ramp Threshold 0.5 Smoothness 0.1](images/ramp_style_sliders_1.png) ![Slider Ramp Threshold 0.6 Smoothness 0.7](images/ramp_style_sliders_2.png) ![RGB Slider Ramp with blue threshold value](images/ramp_style_rgb_sliders_1.png) ![RGB Slider Ramp with red threshold value to simulate skin subsurface](images/ramp_style_rgb_sliders_skin.png) ![Same example with regular Slider Ramp, notice how the terminator looks duller](images/ramp_style_rgb_sliders_skin_off.png) ![Texture Ramp](images/ramp_style_texture_1.png) ![Texture Ramp](images/ramp_style_texture_2.png) ![Crisp Ramp](images/ramp_style_crisp.png) ![Crisp Ramp (anti-aliased)](images/ramp_style_crisp_aa.png) ![No Ramp](images/ramp_style_noramp.png) -------------------------------------------------------------------------------------------------------------------------------- ### Ramp Control ((Default)) ((LWRP/URP)) Define ramp shading properties to be global, for the main vs other lights, or for each light type (((Default)) template only). This could allow you to have a solid ramp for the main directional light, but make all other lights smooth. ![Global All lights use the same threshold/smoothness values](images/ramp_control_global.png) ![Main + Other Lights Crisp main light Smooth point lights](images/ramp_control_main_other.png) ![Main + Other Lights Varying smoothnesses](images/desktop_ramp_mixed.webm) -------------------------------------------------------------------------------------------------------------------------------- ### Shadow Color Mode ((Default)) ((LWRP/URP)) How the shadow color is blended on the model: either multiplied on top of the albedo color, or it replaces the albedo color entirely (and thus hides any texture detail). ![Shadow Color Mode: Multiply](images/shadow_color_mode_mult.png) ![Shadow Color Mode: Replace](images/shadow_color_mode_replace.png) -------------------------------------------------------------------------------------------------------------------------------- ### Shadow HSV ((Default)) Generate hue, saturation, value controls for the shadowed parts of the material. This means that you can add color variations for shadowed parts of the model, instead of just having a single shadow color multiplied. ![Shadow HSV: the hue of the texture gets redder in the shadows](images/shadow_hsv.png) -------------------------------------------------------------------------------------------------------------------------------- ### Specular ((Default)) ((LWRP/URP)) Enable specular on the material. Specular | Description ------------------------------|------------------------------------------------------------------------------------------------------------------------------- Blinn-Phong | Fast and non-physically-based specular, with color and smoothness controls. The specular falloff is very soft. PBR Blinn-Phong | Physically-based version, where the intensity will decrease as the smoothness increase. GGX | More accurate physically-based version, with a specular falloff closer to real life materials.
This is the most popular specular algorithm used in real-time PBR rendering. Anisotropic | Anisotropic specular based on the [Ward algorithm](+https://en.wikipedia.org/wiki/Specular_highlight#Ward_anisotropic_distribution). Needs the mesh tangents to work properly. ![Specular: Blinn-Phong](images/specular_blinnphong.png) ![Specular: PBR Blinn-Phong](images/specular_blinnphong_pbr.png) ![Specular: GGX](images/specular_ggx.png) ![Specular: Anisotropic](images/specular_aniso.png) Stylized Specular | Description ------------------------------|------------------------------------------------------------------------------------------------------------------------------- Cartoon | Add size and smoothness controls to the specular area, allowing to define a crisper specular shape. Bands | Similar to the cartoon one, with multiple levels, all with a crisp shape. ![Stylized Specular: Cartoon](images/specular_stylized_cartoon.png) ![Stylized Specular: Bands](images/specular_stylized_bands.png) ![Stylized Specular: Texture Ramp](images/specular_stylized_ramp.png) -------------------------------------------------------------------------------------------------------------------------------- ### Emission ((Default)) ((LWRP/URP)) Enables an emissive color on the shader. By default this will be a simple Color property, but you can change or expand it using the [[Shader Properties]] tab to use a Texture instead, or a Texture mask multiplied by a Color for examples. ![Yellow emission color](images/emission_color.png) ![Yellow emission color with a texture mask](images/emission_texture.png) ![Emission with a fixed mask and a scrolling mask on top](images/emission_texture_scroll.webm) -------------------------------------------------------------------------------------------------------------------------------- ### Rim / Fresnel ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Subsurface Scattering ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### MatCap ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Ambient Lighting / Indirect Diffuse ((Default)) ((LWRP/URP)) Option | Description ------------------------------|------------------------------------------------------------------------------------------------------------------------------- Disable Ambient Lighting | Entirely disable ambient lighting provided by the rendering pipeline (as defined in the [Lighting Settings](+https://docs.unity3d.com/Manual/GlobalIllumination.html)). Cubemap Ambient | Provide a cubemap property that will define the ambient colors. Usually used with a blurred cubemap derived from a skybox Directional Ambient | Provide 6 colors property to define the ambient lighting coming from all axis (+X , -X, +Y, -Y, +Z, -Z).
Can be in world or view space. Occlusion | Enable the Occlusion Shader Property to block ambient lighting.
It is set to the Albedo alpha channel by default, but you can change that in the [[Shader Properties]] tab. ## Surface -------------------------------------------------------------------------------------------------------------------------------- ### Normal/Bump Map ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Texture Splatting/Blending ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Triplanar Mapping ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ## Stylization -------------------------------------------------------------------------------------------------------------------------------- ### Stylized Threshold ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Diffuse Tint ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Sketch ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Outline ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ## Special Effects -------------------------------------------------------------------------------------------------------------------------------- ### Silhouette Pass ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Dissolve Map ((Default)) ((LWRP/URP)) Documentation not available yet. ## Transparency/Blending -------------------------------------------------------------------------------------------------------------------------------- ### Blending / Blend Operation ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Depth pre-pass ((Default)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ### Alpha Testing ((Default)) ((LWRP/URP)) Documentation not available yet. -------------------------------------------------------------------------------------------------------------------------------- ## Shader States Enable these options to control various fixed shader states. State | Description -------------------------------------|--------------------------------- Face Culling (double-sided) | Controls front and back faces culling in the GPU. By default, back faces are hidden.
Set the value to `Off` to get double-sided rendering. └─ Backface Lighting | Will modify that normals for back faces so that lighting and other effects look accurate. Depth Write | Controls writing to the depth buffer. Depth Test | Controls test against the depth buffer. This is how the GPU determines whether a face has to be rendered or not, based on its depth compared to the currently existing depth. Stencil | Enable stencil [[shader properties]] to customize the [stencil state](+https://docs.unity3d.com/Manual/SL-Stencil.html). Shader Target | Define to which shader model version the shader should compile to.
Increase that number if you get compile errors such as `Not enough instructions/interpolators...`, if your platform supports it. -------------------------------------------------------------------------------------------------------------------------------- ## Options Various options related to Unity's built-in rendering features. These usually translate to [surface shader optional parameters](+https://docs.unity3d.com/Manual/SL-SurfaceShaders.html) for the ((Default)) template. -------------------------------------------------------------------------------------------------------------------------------- ## Third-Party Plugins Add support to your shader for third-party packages from the Unity Asset Store. - [VertExmotion](+http://www.kalagaan.com/#vertexmotion) - [Curved World](+https://assetstore.unity.com/packages/vfx/shaders/curved-world-26165) Shader Properties Tutorials =========================== These tutorials can help you understand the process and possibilities of modifying [[Shader Properties]] to customize your generated shader. For clarity they are regrouped in an external page: [Shader Generator 2 Tutorials](+tutorials). Tutorials list: - [Use Vertex Colors as Albedo]("tutorials.html#usevertexcolorsasalbedo") - [Add a detail texture (simple)]("tutorials.html#addadetailtexture(simple)") - [Add a detail texture (advanced)]("tutorials.html#addadetailtexture(advanced)") - [Create a hologram shader]("tutorials.html#createahologramshader") Contact ======= If you have questions, bug reports or suggestions please contact me by email at: jean.moreno.public+unity@gmail.com